.gitlab-ci.yml 2.67 KB
Newer Older
Zack Wong's avatar
Zack Wong committed
1
stages:
Zack Wong's avatar
Zack Wong committed
2 3
  - test
  - deploy
Zack Wong's avatar
Zack Wong committed
4

Zack Wong's avatar
Zack Wong committed
5
variables:
Zack Wong's avatar
Zack Wong committed
6
  DB_ENGINE : django.db.backends.sqlite3
Zack Wong's avatar
Zack Wong committed
7

Zack Wong's avatar
Zack Wong committed
8
before_script:
Zack Wong's avatar
Zack Wong committed
9 10 11 12 13 14
  - echo "preparing environment"
  - virtualenv env -p `which python3`
  - . env/bin/activate
  - pip install -r pip-packages.txt
  
  
Zack Wong's avatar
Zack Wong committed
15
run_tests:
Zack Wong's avatar
Zack Wong committed
16 17 18 19 20
  stage: test
  script:
    - echo "Running tests"
    - envsubst < src/gms/settings_local.example.py > src/gms/settings_local.py
    - python src/manage.py check
Zack Wong's avatar
Zack Wong committed
21 22 23 24
  only:
    - /^.*-test(ing)?$/
    - /^(test|devops)\/.*$/
    - master
Zack Wong's avatar
Zack Wong committed
25

Zack Wong's avatar
Zack Wong committed
26
deploy_testing:
Zack Wong's avatar
Zack Wong committed
27 28 29 30
  stage: deploy
  tags:
    - test
  variables:
coffee's avatar
coffee committed
31 32 33 34
    AD_DOMAIN : ad.v.ucc.asn.au
    AD_BASEDN : DC=AD,DC=v,DC=ucc,DC=asn,DC=AU
    DB_NAME : /var/www/test/$CI_COMMIT_REF_SLUG/.db/members.db
    DEPLOY_HOST : $CI_COMMIT_REF_SLUG.test.ucc.asn.au
Zack Wong's avatar
Zack Wong committed
35 36 37
    SHORT_ENV_NAME : TEST
  script:
    - echo "Deploy to test"
coffee's avatar
coffee committed
38 39
    - rm -f /var/www/test/$CI_COMMIT_REF_SLUG
    - rm -f /etc/uwsgi/vassals/$CI_COMMIT_REF_SLUG.ini
Zack Wong's avatar
Zack Wong committed
40 41
    - mkdir .db
    - envsubst < src/gms/settings_local.example.py > src/gms/settings_local.py
coffee's avatar
coffee committed
42
    - chmod 600 src/gms/settings_local.py
coffee's avatar
coffee committed
43
    - ln -srT ./ /var/www/test/$CI_COMMIT_REF_SLUG
Zack Wong's avatar
Zack Wong committed
44 45 46
    - python src/manage.py collectstatic
    - python src/manage.py makemigrations
    - python src/manage.py migrate --run-syncdb
coffee's avatar
coffee committed
47
    - ln -s /etc/uwsgi/vassals/test.skel /etc/uwsgi/vassals/$CI_COMMIT_REF_SLUG.ini
Zack Wong's avatar
Zack Wong committed
48
  environment:
coffee's avatar
coffee committed
49 50
    name: test/$CI_COMMIT_REF_SLUG
    url: https://$CI_COMMIT_REF_SLUG.test.ucc.asn.au
Zack Wong's avatar
Zack Wong committed
51
    on_stop: stop_testing
coffee's avatar
coffee committed
52
  only:
Zack Wong's avatar
Zack Wong committed
53 54
    - /^.*-test(ing)?$/
    - /^(test|devops)\/.*$/
Zack Wong's avatar
Zack Wong committed
55 56
  except:
      - master
frekk's avatar
frekk committed
57
      - merge_requests
Zack Wong's avatar
Zack Wong committed
58
  
Zack Wong's avatar
Zack Wong committed
59
deploy_staging:
Zack Wong's avatar
Zack Wong committed
60 61 62 63
  stage: deploy
  tags:
    - stage
  variables:
coffee's avatar
coffee committed
64 65
    AD_DOMAIN : ad.v.ucc.asn.au
    AD_BASEDN : DC=AD,DC=v,DC=ucc,DC=asn,DC=AU
Zack Wong's avatar
Zack Wong committed
66
    DB_NAME : /var/www/stage/.db/members.db
Zack Wong's avatar
Zack Wong committed
67
    DEPLOY_HOST : stage.test.ucc.asn.au
Zack Wong's avatar
Zack Wong committed
68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
    SHORT_ENV_NAME : STAGE
  script:
    - echo "Deploy to staging"
    - rm -f /services/$CI_PROJECT_NAME
    - rm -f /etc/uwsgi/vassals/stage.ini
    - ln -srT ./ /services/$CI_PROJECT_NAME
    - envsubst < src/gms/settings_local.example.py > src/gms/settings_local.py
    - chmod 600 src/gms/settings_local.py
    - python src/manage.py collectstatic
    - python src/manage.py makemigrations
    - python src/manage.py migrate --run-syncdb
    - ln -s /etc/uwsgi/vassals/stage.skel /etc/uwsgi/vassals/stage.ini
  environment:
    name: stage
    url: https://stage.test.ucc.asn.au
  only:
      - master
Zack Wong's avatar
Zack Wong committed
85

Zack Wong's avatar
Zack Wong committed
86
stop_testing:
Zack Wong's avatar
Zack Wong committed
87 88 89 90 91
  stage: deploy
  variables:
    GIT_STRATEGY: none
  when: manual
  environment:
coffee's avatar
coffee committed
92
    name: test/$CI_COMMIT_REF_SLUG
Zack Wong's avatar
Zack Wong committed
93
    action: stop
coffee's avatar
coffee committed
94
  only:
Zack Wong's avatar
Zack Wong committed
95 96
    - /^.*-test(ing)?$/
    - /^(test|devops)\/.*$/
Zack Wong's avatar
Zack Wong committed
97 98 99
  except: 
    - master
  script:
coffee's avatar
coffee committed
100 101
    - rm -f /var/www/test/$CI_COMMIT_REF_SLUG
    - rm -f /etc/uwsgi/vassals/$CI_COMMIT_REF_SLUG.ini