.gitlab-ci.yml 2.45 KB
Newer Older
1
job test python:
okhin's avatar
okhin committed
2 3 4
    script:
        - virtualenv --python=python3 env
        - source env/bin/activate
okhin's avatar
okhin committed
5
        - pip install django
okhin's avatar
okhin committed
6
        - pip install coverage
okhin's avatar
okhin committed
7 8
        - python setup.py develop
        - cp picampaign/settings.py.sample picampaign/settings.py
okhin's avatar
okhin committed
9
        - ${VIRTUAL_ENV}/bin/coverage run --source='.' manage.py test
okhin's avatar
okhin committed
10
        - ${VIRTUAL_ENV}/bin/coverage report --omit="${VIRTUAL_ENV}/*",'*__init__.py'
okhin's avatar
okhin committed
11 12 13 14
    stage: test
    tags: [preprod]
    only:
        - master
15 16 17 18
    artifacts:
        paths:
            - env
        expire_in: 1 day
okhin's avatar
okhin committed
19

20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42
job build:
    script:
        - source env/bin/activate
        - python setup.py develop
        - cp picampaign/settings.py.sample picampaign/settings.py
        - python manage.py collectstatic --noinput
        - python manage.py compilemessages --exclude env
        - python manage.py makemessages --exclude env fr
        - python manage.py makemessages --exclude env en
        - python manage.py makemessages --exclude env de
    artifacts:
        paths:
            - campaign/static
            - campaign/locale
        expire_in: 1 day
    stage: build
    tags: [preprod]
    only:
        - master
    dependencies:
        - job test python

job deploy preprod:
okhin's avatar
okhin committed
43 44 45
    environment:
        preprod
    variables:
46
        BASE_DIR: /srv/piphone/campaign
okhin's avatar
okhin committed
47
    script:
48
        - rsync -ruvC ./ ${BASE_DIR}
okhin's avatar
okhin committed
49 50 51
        - 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
52
        - python /srv/piphone/campaign/manage.py collectstatic --noinput
okhin's avatar
okhin committed
53 54
        - python /srv/piphone/campaign/manage.py compilemessages
        - touch /srv/piphone/campaign.ready
okhin's avatar
okhin committed
55
    stage: deploy
okhin's avatar
okhin committed
56 57 58
    tags: [preprod]
    only:
        - master
59 60
    dependencies:
        - job build
Okhin's avatar
Okhin committed
61 62 63 64 65 66 67 68

job deploy prod:
    environment:
        prod
    variables:
        GIT_DIR: '/srv/piphone/campaign/.git'
        GIT_WORK_DIR: '/srv/piphone/campaign/'
    script:
69
        - rsync -ruvC ./ ${BASE_DIR}
Okhin's avatar
Okhin committed
70 71 72 73 74 75 76 77 78 79 80
        - 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
    when: manual
81 82
    dependencies:
        - job build