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

job deploy:
    environment:
        preprod
    variables:
        GIT_DIR: '/srv/piphone/campaign/.git'
        GIT_WORK_DIR: '/srv/piphone/campaign/'
    script:
okhin's avatar
okhin committed
25
        - git reset --hard
okhin's avatar
okhin committed
26 27 28
        - git pull origin master
        - source /srv/piphone/campaign/env/bin/activate
        - pip install --upgrade pip
okhin's avatar
okhin committed
29
        - pip install django
okhin's avatar
okhin committed
30 31
        - python /srv/piphone/campaign/setup.py install
        - python /srv/piphone/campaign/manage.py migrate
okhin's avatar
okhin committed
32
        - python /srv/piphone/campaign/manage.py collectstatic --noinput
okhin's avatar
okhin committed
33 34
        - python /srv/piphone/campaign/manage.py compilemessages
        - touch /srv/piphone/campaign.ready
okhin's avatar
okhin committed
35
    stage: deploy
okhin's avatar
okhin committed
36 37 38
    tags: [preprod]
    only:
        - master
Okhin's avatar
Okhin committed
39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62

job deploy prod:
    environment:
        prod
    variables:
        GIT_DIR: '/srv/piphone/campaign/.git'
        GIT_WORK_DIR: '/srv/piphone/campaign/'
    script:
        - git reset --hard
        - git pull origin master
        - source /srv/piphone/campaign/env/bin/activate
        - pip install --upgrade pip
        - pip install django
        - 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