.gitlab-ci.yml 2.33 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
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

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

job deploy prod:
    environment:
        prod
    variables:
        GIT_DIR: '/srv/piphone/campaign/.git'
        GIT_WORK_DIR: '/srv/piphone/campaign/'
    script:
65
        - rsync -ruvC ./ ${BASE_DIR}
okhin's avatar
okhin committed
66 67 68 69 70 71 72 73 74 75
        - 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
76
    when: manual