-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
136 lines (124 loc) · 4.02 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
image: docker:latest
variables:
BARBERINI_ANALYTICS_CONTEXT: CI
GITLAB_OAUTH_TOKEN: $GITLAB_OAUTH_TOKEN
workflow:
rules:
- if: $CI_MERGE_REQUEST_IID
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
# Stages are required a) to priorize jobs and b) to avoid concurrency issues.
stages:
- build
- test
- analyze
- post-anything
build:
stage: build
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
script:
- docker build -t ${USER}_test ./docker $(
[[ -n $"CI_MERGE_REQUEST_TARGET_BRANCH_NAME" ]] && [[ -n $"CI_MERGE_REQUEST_DIFF_BASE_SHA" ]]
&& git fetch origin ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME} && git diff --name-only "origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}" "${CI_COMMIT_SHA}" | grep -q docker/
&& echo '--no-cache'
)
unittest:
stage: test
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
- make startup
script:
- docker exec --env FULL_TEST=$FULL_TEST $USER-barberini_analytics_luigi make coverage 2> >(tee -a unittest.log >&2)
after_script:
- # Workaround for https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3088
USER="gitlab_runner_${CI_JOB_ID}"
- if [ "$CI_COMMIT_REF_NAME" = "$CI_DEFAULT_BRANCH" ] && grep -q "Gomus version number in HTML string has changed!" unittest.log; then
docker exec --env CI_PROJECT_ID=$CI_PROJECT_ID --env CI_PROJECT_PATH=$CI_PROJECT_PATH --env CI_SERVER_HOST=$CI_SERVER_HOST --env CI_SERVER_URL=$CI_SERVER_URL --env GITLAB_OAUTH_TOKEN=$GITLAB_OAUTH_TOKEN $USER-barberini_analytics_luigi make patch-gomus-version-mr;
fi
- make docker-cleanup
coverage: '/TOTAL\s+\d+\s+\d+\s+(\d+%)/'
artifacts:
paths:
- htmlcov
minimal-mining-pipeline:
stage: test
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
script:
- ./scripts/tests/run_minimal_mining_pipeline.sh
lint-python:
stage: analyze
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
- make startup
script:
- docker exec --env FULL_TEST=$FULL_TEST $USER-barberini_analytics_luigi make lint-python
after_script:
- # Workaround for https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3088
USER="gitlab_runner_${CI_JOB_ID}"
- make docker-cleanup
python-bandit:
stage: analyze
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
- make startup
script:
- docker exec --env FULL_TEST=$FULL_TEST $USER-barberini_analytics_luigi make python-bandit
after_script:
- # Workaround for https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3088
USER="gitlab_runner_${CI_JOB_ID}"
- make docker-cleanup
shellcheck:
stage: analyze
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
- make startup
script:
- docker exec --env FULL_TEST=$FULL_TEST $USER-barberini_analytics_luigi make shellcheck
after_script:
- # Workaround for https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3088
USER="gitlab_runner_${CI_JOB_ID}"
- make docker-cleanup
lint-markdown:
stage: analyze
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
- make startup
- docker exec $USER-barberini_analytics_luigi git config --global --add safe.directory /app
script:
- docker exec --env FULL_TEST=$FULL_TEST $USER-barberini_analytics_luigi make lint-markdown
after_script:
- # Workaround for https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3088
USER="gitlab_runner_${CI_JOB_ID}"
- make docker-cleanup
send-failure-mail:
stage: post-anything
when: on_failure
only:
- schedules
tags:
- barberini
before_script:
- USER="gitlab_runner_${CI_JOB_ID}"
- make startup
script:
- docker exec $USER-barberini_analytics_luigi /app/scripts/running/notify_ci_failure.py "${CI_PIPELINE_URL}"
after_script:
- # Workaround for https://gitlab.com/gitlab-org/gitlab-runner/-/issues/3088
USER="gitlab_runner_${CI_JOB_ID}"
- make docker-cleanup