.gitlab-ci.yml 2.35 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
20 21 22 23
    artifacts:
        paths:
            - env
        expire_in: 1 day
okhin's avatar
okhin committed
24

25 26 27 28 29 30
job build:
    script:
        - source env/bin/activate
        - python setup.py develop
        - cp picampaign/settings.py.sample picampaign/settings.py
        - python manage.py collectstatic --noinput
Okhin's avatar
Okhin committed
31 32 33
        - python manage.py makemessages --exclude env --locale fr
        - python manage.py makemessages --exclude env --locale en
        - python manage.py makemessages --exclude env --locale de
34 35 36 37 38 39 40 41 42 43 44 45
        - 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
46 47 48
    environment:
        preprod
    variables:
49
        BASE_DIR: /srv/piphone/campaign
okhin's avatar
okhin committed
50
    script:
51
        - rsync -ruvC ./ ${BASE_DIR}
okhin's avatar
okhin committed
52 53 54
        - source /srv/piphone/campaign/env/bin/activate
        - python /srv/piphone/campaign/setup.py install
        - python /srv/piphone/campaign/manage.py migrate
okhin's avatar
okhin committed
55
        - python /srv/piphone/campaign/manage.py collectstatic --noinput
okhin's avatar
okhin committed
56 57
        - python /srv/piphone/campaign/manage.py compilemessages
        - touch /srv/piphone/campaign.ready
okhin's avatar
okhin committed
58
    stage: deploy
okhin's avatar
okhin committed
59 60 61
    tags: [preprod]
    only:
        - master
Okhin's avatar
Okhin committed
62 63 64 65 66

job deploy prod:
    environment:
        prod
    variables:
Okhin's avatar
Okhin committed
67
        BASE_DIR: /srv/piphone/campaign
Okhin's avatar
Okhin committed
68
    script:
69
        - rsync -ruvC ./ ${BASE_DIR}
Okhin's avatar
Okhin committed
70 71 72 73 74 75 76 77 78 79
        - source /srv/piphone/campaign/env/bin/activate
        - 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
80
    when: manual