.gitlab-ci.yml 1.78 KB
Newer Older
okhin's avatar
okhin committed
1 2 3 4 5
variables:
    PIP_CACHE_DIR: "$CI_PROJECT_DIR/pip-cache"

cache:
    paths:
6 7
        - "pip-cache"
        - "env"
okhin's avatar
okhin committed
8 9 10 11 12 13 14 15 16 17
    key: "$CI_PROJECT_ID"

stages:
    - test
    - build
    - deploy

unit tests:
    stage: test
    script:
okhin's avatar
okhin committed
18
        - virtualenv -p python3 env
okhin's avatar
okhin committed
19 20 21 22 23 24
        - 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
25
        - ./manage.py migrate
okhin's avatar
okhin committed
26
        - pytest apps/ --cov=apps/
okhin's avatar
okhin committed
27 28 29 30
    artifacts:
        paths:
            - env/
        expire_in: 1 day
okhin's avatar
okhin committed
31
    tags: [preprod]
32 33

static build:
okhin's avatar
okhin committed
34
    stage: build
35
    script:
36
        - virtualenv -p python3 env
37 38
        - source ./env/bin/activate
        - pip install -r requirements.txt
39 40 41
        - yarn install
        - webpack
        - echo "DEBUG = False" > ./project/settings/env.py
42 43 44
        - echo "SECRET_KEY = '$(pwgen 20 1)'" >> ./project/settings/env.py
        - ./manage.py collectstatic
    tags: [preprod]
okhin's avatar
okhin committed
45 46
    dependencies:
        - unit tests
47 48 49 50
    artifacts:
        paths:
            - static/
        expire_in: 1 day
okhin's avatar
okhin committed
51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67

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 requirements.txt
        - pip install --upgarde 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]