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 -r requirements.txt - pip install -r requirements-dev.txt - pip install -r requirements-tests.txt - echo "DEBUG = True" > ./project/settings/env.py - echo "SECRET_KEY = '$(pwgen 20 1)'" >> ./project/settings/env.py - ./manage.py migrate - pytest apps/ --cov=apps/ artifacts: paths: - env/ expire_in: 1 day 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] dependencies: - unit tests artifacts: paths: - static/ expire_in: 1 day deploy preprod: variables: BASE_PATH: /srv/rp2/src/ VIRTUALENV: /srv/rp2/rp2-env stage: deploy script: - rsync -ruvC ./ ${BASE_PATH} - source ${VIRTUALENV}/bin/activate - pip install --upgrade pip - pip install --upgrade -r requirements.txt - pip install --upgarde -r requirements-dev.txt - echo "DEBUG = True" > ${BASE_PATH}/project/settings/env.py - echo "SECRET_KEY = '$(pwgen 20 1)'" >> ../project/settings/env.py - $[BASE_PATH}/manage.py migrate - touch ${BASE_PATH}/ready tags: [preprod]