.gitlab-ci.yml 2.58 KB
Newer Older
okhin's avatar
okhin committed
1 2 3 4 5
stages:
    - test
    - build
    - deploy

6
job test python:
okhin's avatar
okhin committed
7 8 9
    script:
        - virtualenv --python=python3 env
        - source env/bin/activate
okhin's avatar
okhin committed
10
        - pip install django
okhin's avatar
okhin committed
11
        - pip install coverage
okhin's avatar
okhin committed
12 13
        - python setup.py develop
        - cp picampaign/settings.py.sample picampaign/settings.py
okhin's avatar
okhin committed
14
        - ${VIRTUAL_ENV}/bin/coverage run --source='.' manage.py test
okhin's avatar
okhin committed
15
        - ${VIRTUAL_ENV}/bin/coverage report --omit="${VIRTUAL_ENV}/*",'*__init__.py'
okhin's avatar
okhin committed
16 17 18 19
    stage: test
    tags: [preprod]
    only:
        - master
okhin's avatar
okhin committed
20

21 22
job build:
    script:
23
        - virtualenv --python=python3 env
24
        - source env/bin/activate
25 26
        - pip install django
        - pip install coverage
27 28 29
        - python setup.py develop
        - cp picampaign/settings.py.sample picampaign/settings.py
        - python manage.py collectstatic --noinput
okhin's avatar
okhin committed
30 31 32
        - python manage.py makemessages --exclude env --locale fr
        - python manage.py makemessages --exclude env --locale en
        - python manage.py makemessages --exclude env --locale de
33 34 35 36 37 38 39 40 41 42 43 44
        - python manage.py compilemessages --exclude env
    artifacts:
        paths:
            - campaign/static
            - campaign/locale
        expire_in: 1 day
    stage: build
    tags: [preprod]
    only:
        - master

job deploy preprod:
okhin's avatar
okhin committed
45 46 47
    environment:
        preprod
    variables:
48
        BASE_DIR: /srv/piphone/campaign
okhin's avatar
okhin committed
49
    script:
50
        - rsync -ruvC ./ ${BASE_DIR}
51
        - virtualenv --python=python3 ${BASE_DIR}/env
okhin's avatar
okhin committed
52
        - source ${BASE_DIR}/env/bin/activate
53 54
        - pip install django
        - pip install coverage
okhin's avatar
okhin committed
55 56
        - python /srv/piphone/campaign/setup.py install
        - python /srv/piphone/campaign/manage.py migrate
okhin's avatar
okhin committed
57
        - python /srv/piphone/campaign/manage.py collectstatic --noinput
okhin's avatar
okhin committed
58 59
        - python /srv/piphone/campaign/manage.py compilemessages
        - touch /srv/piphone/campaign.ready
okhin's avatar
okhin committed
60
    stage: deploy
okhin's avatar
okhin committed
61 62 63
    tags: [preprod]
    only:
        - master
okhin's avatar
okhin committed
64 65 66 67 68

job deploy prod:
    environment:
        prod
    variables:
okhin's avatar
okhin committed
69
        BASE_DIR: /srv/piphone/campaign
okhin's avatar
okhin committed
70
    script:
71
        - rsync -ruvC ./ ${BASE_DIR}
72
        - virtualenv --python=python3 ${BASE_DIR}/env
okhin's avatar
okhin committed
73
        - source ${BASE_DIR}/env/bin/activate
74 75
        - pip install django
        - pip install coverage
okhin's avatar
okhin committed
76 77 78 79 80 81 82 83 84
        - python /srv/piphone/campaign/setup.py install
        - python /srv/piphone/campaign/manage.py migrate
        - python /srv/piphone/campaign/manage.py collectstatic --noinput
        - python /srv/piphone/campaign/manage.py compilemessages
        - touch /srv/piphone/campaign.ready
    stage: deploy
    tags: [piphone]
    only:
        - master
okhin's avatar
okhin committed
85
    when: manual