-
Notifications
You must be signed in to change notification settings - Fork 3
/
.gitlab-ci.yml
84 lines (77 loc) · 2.44 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
stages:
- build
- deploy
# tests are run against the dev server, so deploy stage should complete first
- test
services:
- docker:20.10.19-dind
- postgres:alpine
variables:
POSTGRES_USER: "gkadmin"
POSTGRES_PASSWORD: "gkadmin"
POSTGRES_DB: "gkdata"
GKCORE_DB_URL: "postgres://gkadmin:gkadmin@postgres:5432/gkdata"
# test run gkcore on creating or updating merge requests
gkcore:
image: python:3.8-slim-buster
stage: test
script:
- apt update && apt install -y build-essential libpq-dev
- pip3 install -r requirements.txt
- python3 setup.py develop
- python3 initdb.py
- python3 db_migrate.py
- prequest development.ini /state
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# runs the api tests against the dev server
api_tests:
image: digitalfreedom/nexial-core:latest
stage: test
# this job runs with a delay to make sure the dev server
# is updated to latest commit
script: |
cd tests/artifact
nexial.sh -plan plan/GNUKhata-plan.xlsx || true
allow_failure: true
# this job runs only on the master branch
rules:
- if: $CI_COMMIT_BRANCH == 'master'
when: delayed
start_in: 2 minutes
artifacts:
paths:
- /builds/gnukhata/gkcore/tests/output
# build gkcore docker image from devel commits & upload it to docker hub
docker-devel:
image: docker:20.10.19
stage: build
script:
# build the docker image & push to the dockerhub
- docker login -u digitalfreedom -p $DOCKERHUB_PWD
- docker build -t digitalfreedom/gkcore:devel --build-arg VERSION=$CI_COMMIT_SHORT_SHA .
- docker push digitalfreedom/gkcore:devel
rules:
- if: $CI_COMMIT_BRANCH == 'devel'
# build gkcore docker image on a release/tags & push it to the docker hub
docker-prod:
image: docker:20.10.19
stage: build
script:
# build the docker image & push to the dockerhub
- docker login -u digitalfreedom -p $DOCKERHUB_PWD
- docker build -t digitalfreedom/gkcore:$CI_COMMIT_TAG --build-arg VERSION=$CI_COMMIT_TAG .
- docker push digitalfreedom/gkcore:$CI_COMMIT_TAG
# create alias for the latest tag
- docker tag digitalfreedom/gkcore:$CI_COMMIT_TAG digitalfreedom/gkcore:latest
- docker push digitalfreedom/gkcore:latest
rules:
- if: $CI_COMMIT_TAG
# deploy devel branch changes to gkcore test server
update_test_server:
stage: deploy
image: curlimages/curl:latest
script:
- curl -f $TEST_SERVER_HOOK
rules:
- if: $CI_COMMIT_BRANCH == 'devel'