-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
95 lines (87 loc) · 2.66 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
85
86
87
88
89
90
91
92
93
94
95
include:
- project: gfbio/cicd
file:
- ".create_merge_request_v3.yml"
- ".tag_release.yml"
- ".web_test_v2.yml"
- ".hotfix_workflow.yml"
stages:
- check_issue_type
- create_merge_request
- create_hotfix_merge_request
- unit_tests
- web_test_check
- web_test_update
- web_test_stop
- update_staging
- tag_release_check
- tag_release
create_merge_request:
variables:
PROJECT_NAME: "submissions"
tags:
- dev-denbi
run unit tests:
stage: unit_tests
rules:
- if: $CI_COMMIT_BRANCH
variables:
PROJECT_NAME: "submissions"
script:
- SHORT_REF_NAME="${CI_COMMIT_REF_NAME:0:9}"
- ISSUE_ID=$(awk -F - '{print $2}' <<< "$CI_COMMIT_REF_NAME")
- if [[ -z "$ISSUE_ID" ]]; then DOCKER_NAME="$PROJECT_NAME-$SHORT_REF_NAME"; else DOCKER_NAME="$ISSUE_ID-$PROJECT_NAME"; fi
- docker compose -f local.yml build
- CURRENT_UID="$(id -u):$(id -g)" docker stack deploy -c cicd/local.yml "$DOCKER_NAME-tests"
- while [[ $(docker ps -a | grep "$DOCKER_NAME-tests_django" | grep -c Exited) == 0 ]]; do sleep 1; done
- docker logs "$(docker ps -a | grep -oP "$DOCKER_NAME-tests_django.+\s?")"
- if [[ $(docker logs "$(docker ps -a | grep -oP "$DOCKER_NAME-tests_django.+\s?")" --tail 2 2>&1 | grep -c FAILED) == 1 ]]; then docker stack rm "$DOCKER_NAME-tests" && exit 1; fi
- docker stack rm "$DOCKER_NAME-tests"
after_script:
- docker compose -f cicd/local.yml run --rm django rm -rf staticfiles
- docker compose -f cicd/local.yml down
environment:
name: review/$CI_COMMIT_REF_NAME
tags:
- dev-denbi
web_test_update:
variables:
PROJECT_NAME: "submissions"
COMPOSE_FILE: "cicd/production.yml"
script:
- ISSUE_ID=$(awk -F- '{print $2}' <<< ${CI_COMMIT_REF_NAME})
- TEST_NAME=$ISSUE_ID-$PROJECT_NAME
- TEST_NAME=${TEST_NAME} ADMIN_URL=${ADMIN_URL} ./cicd/createWebTest.sh
- docker compose -f $COMPOSE_FILE build
- ./web_test_deploy.sh
web_test_stop:
variables:
MAIN_BRANCH_NAME: "master"
PROJECT_NAME: "submissions"
update staging:
stage: update_staging
needs: ["run unit tests"]
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
script:
- ./cicd/updateStaging.sh
environment:
name: staging
url: https://submissions.gfbio.dev/
tags:
- staging-denbi
tag_release_check:
variables:
MAIN_BRANCH_NAME: "production"
tags:
- development-denbi
tag_release:
variables:
GIT_SUBMODULE_STRATEGY: normal
script:
- HOST=${CI_PROJECT_URL} CI_PROJECT_ID=${CI_PROJECT_ID} PRIVATE_TOKEN=${PRIVATE_TOKEN} cicd/tagRelease.sh
environment:
name: production
url: https://submissions.gfbio.org
tags:
- production