forked from waldur/waldur-mastermind
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
157 lines (149 loc) · 5.41 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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
include:
- project: "waldur/waldur-pipelines"
file: "/templates/stages.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/check-merge-compatibility.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/release/publish.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/release/sync-to-github.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/validate/docker-compose-trigger.yml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-docker-image.yaml"
- project: "waldur/waldur-pipelines"
file: "/templates/test/lint-dockerfile.yaml"
- project: "waldur/waldur-pipelines"
file: "/templates/deploy/dev-env-update.yml"
variables:
GITHUB_OPENNODE_REPO_URL: "[email protected]:opennode/waldur-mastermind.git"
GITHUB_WALDUR_REPO_URL: "[email protected]:waldur/waldur-mastermind.git"
before_script:
- export
Run linters:
image: "$CI_REGISTRY/waldur/waldur-pipelines/python:3.8"
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
- if: '$CI_COMMIT_BRANCH == "master"'
# If tagged release
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
# If event is related to a created merge request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
script:
- pip install pre-commit
- pre-commit run --all
Run unit tests:
image: $CI_REGISTRY/$WALDUR_MASTERMIND_TEST_IMAGE
stage: test
interruptible: true
rules:
# Skip tests if said so
- if: '$SKIP_TESTS == "true" || $SKIP_TESTS == "yes"'
when: never
- if: '$CI_COMMIT_BRANCH == "develop"'
- if: '$CI_COMMIT_BRANCH == "master"'
# If tagged release
- if: '$CI_COMMIT_TAG =~ /^v\d+\.\d+\.\d+$/'
# If event is related to a created merge request
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
services:
- name: "$CI_REGISTRY/waldur/waldur-pipelines/postgres:12-alpine"
alias: postgres
command:
[
"postgres",
"-cfsync=off",
"-cfull_page_writes=off",
"-cmax_connections=1000",
"-cshared_buffers=1GB",
"-ceffective_cache_size=4GB",
"-cwork_mem=32MB",
"-cmaintenance_work_mem=32MB",
"-ctemp_buffers=16MB",
"-cwal_buffers=48MB",
]
variables:
POSTGRES_DB: test_waldur
POSTGRES_USER: runner
POSTGRES_PASSWORD: waldur
script:
- |
# Check merge compatibility only it is not a tagged release
if [ "$CI_PIPELINE_SOURCE" == "merge_request_event" ]; then
echo "[+] Add dummy user $GIT_USER_NAME ($GIT_USER_EMAIL)"
git config user.name $GIT_USER_NAME
git config user.email $GIT_USER_EMAIL
echo "[+] Merging branches $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME and origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME"
git merge --no-ff origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
fi
- gitlab-ci-test/waldur-test
- coverage xml
- coverage report
coverage: "/TOTAL.+ ([0-9]{1,3}%)/"
artifacts:
when: always
reports:
junit: report.xml
cobertura: coverage.xml
parallel: 10
Build docker image for tests:
stage: build
interruptible: true
rules:
# If scheduled pipeline for 'develop' branch is set up
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
services:
- name: "$CI_REGISTRY/waldur/waldur-pipelines/docker:19.03.12-dind"
alias: docker
command: ["--mtu=1400"]
variables:
DOCKER_REGISTRY: registry.hpc.ut.ee/mirror/
script:
- echo $CI_COMMIT_SHA > docker/rootfs/COMMIT
- cat docker/rootfs/COMMIT
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker build . -f gitlab-ci-test/Dockerfile -t $CI_REGISTRY/$WALDUR_MASTERMIND_TEST_IMAGE --build-arg DOCKER_REGISTRY=$DOCKER_REGISTRY
- docker push $CI_REGISTRY/$WALDUR_MASTERMIND_TEST_IMAGE
Lint docker image:
extends: .Lint docker image template
variables:
IMAGE: opennode/waldur-mastermind:latest
Lint dockerfile:
extends: .Lint dockerfile template
variables:
DOCKERFILE: Dockerfile
HADOLINT_CONFIG: |
ignored:
- DL3003 # "WORKDIR" warning
- DL3008 # "versions for `apt install`" warning
- DL3015 # "--no-install-recommends" info
- SC2094 # "read and write the same file in the same pipeline" info
Upload configuration guide:
stage: deploy
interruptible: true
rules:
- if: '$CI_COMMIT_BRANCH == "develop" && $CI_PIPELINE_SOURCE == "schedule"'
image: $CI_REGISTRY/$WALDUR_MASTERMIND_TEST_IMAGE
variables:
CONF_GUIDE_PATH: docs/admin-guide/mastermind-configuration/configuration-guide.md
CLI_GUIDE_PATH: docs/admin-guide/mastermind-configuration/cli-guide.md
DJANGO_SETTINGS_MODULE: waldur_core.server.test_settings
script:
- poetry install
- cd /tmp/
- git clone "https://gitlab-ci-token:$GITLAB_TOKEN@$CI_SERVER_HOST/waldur/waldur-docs.git"
- git config --global user.name "$GITLAB_USER_NAME"
- git config --global user.email "$GITLAB_USER_EMAIL"
- cd waldur-docs
- waldur print_settings > $CONF_GUIDE_PATH
- waldur print_commands > $CLI_GUIDE_PATH
- git add $CONF_GUIDE_PATH $CLI_GUIDE_PATH
- git commit -m "Update configuration and CLI guide" || exit 0
- git branch new-configuration-guide
- git push --set-upstream origin new-configuration-guide:master
before_script: []