.gitlab-ci.yml 2.66 KiB
# Change pip's cache directory to be inside the project directory since we can
# only cache local items.
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
cache:
paths:
- .cache/pip
- venv/
stages:
- build
- test
- deploy
build-job:
stage: build
image: python:latest
script:
- python -V
- pip install virtualenv
- virtualenv venv
- source venv/bin/activate
- pwd
- ls -lisah
- git config --global url."https://gitlab-ci-token:${CI_JOB_TOKEN}@gitlab.pik-potsdam.de/".insteadOf "ssh://git@gitlab.pik-potsdam.de/"
- pip install -r requirements.txt
- pip install -r requirements_dev.txt
test-job1:
stage: test
image: python:latest
script:
- source venv/bin/activate
- flake8 --config .flake8
test-job2:
stage: test
image: python:latest
script:
- source venv/bin/activate
- mypy --config-file=pyproject.toml server
deploy-to-production:
stage: deploy
tags:
- bare-metal
script:
# - echo "Run as nacsos user"
# - sudo -u nacsos bash ./deploy.sh $CI_JOB_TOKEN
- echo "Current working directory and user"
- pwd
- whoami
- groups
# - echo "Becoming 'nacsos' user"
# - sudo -u nacsos -s
- echo "Go to deployment location"
- cd /home/nacsos/nacsos-core
- ls -lisah
- sudo chown -R gitlab-runner /home/nacsos/nacsos-core
- sudo chgrp -R gitlab-runner /home/nacsos/nacsos-core
- ls -lisah
- echo "Stopping NACSOS-core service"
- sudo systemctl stop nacsos-core.service
- echo "Dropping virtual environment"