variables: PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache" cache: paths: - "pip-cache" - "env" key: "$CI_PROJECT_ID" stages: - test - build - deploy unit tests: stage: test script: - virtualenv -p python3 env - source ./env/bin/activate - pip install -U -r requirements.txt - pip install -U -r requirements-dev.txt - pip install -U -r requirements-tests.txt - echo "DEBUG = True" > ./project/settings/env.py - echo "SECRET_KEY = '$(pwgen 20 1)'" >> ./project/settings/env.py - ./manage.py migrate --run-syncdb - pytest apps/ --cov=apps/ tags: [preprod] static build: stage: build script: - virtualenv -p python3 env - source ./env/bin/activate - pip install -r requirements.txt - yarn install - webpack - echo "DEBUG = False" > ./project/settings/env.py - echo "SECRET_KEY = '$(pwgen 20 1)'" >> ./project/settings/env.py - ./manage.py collectstatic tags: [preprod] artifacts: paths: - static/ expire_in: 1 day deploy preprod: variables: BASE_PATH: /srv/rp/rp-rp2 VIRTUALENV: /srv/rp/env stage: deploy script: - rsync --exclude 'env' --exclude 'pip-cache' --exclude '.git' -r --chown rp:www-data --chmod g+srw ./ ${BASE_PATH} - source ${VIRTUALENV}/bin/activate - pip install --upgrade pip - pip install --upgrade -r requirements.txt - pip install --upgrade -r requirements-dev.txt - echo "DEBUG = True" > ${BASE_PATH}/project/settings/env.py - echo "SECRET_KEY = '$(pwgen 20 1)'" >> ${BASE_PATH}/project/settings/env.py - echo "SITE_ID = 2" >> ${BASE_PATH}/project/settings/env.py - ${BASE_PATH}/manage.py migrate --run-syncdb - ${BASE_PATH}/manage.py init_groups - touch /etc/uwsgi-emperor/vassals/rp.ini only: - rp2 tags: [preprod]