-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path.gitlab-ci.yml
122 lines (110 loc) · 3.43 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
variables:
LC_ALL: C.UTF-8
GIT_SUBMODULE_STRATEGY: recursive
GIT_STRATEGY: clone # sometimes unclean submodule dirs otherwise
DNSJIT_IMAGE_NAME: knot/shotgun/ci/dnsjit
stages:
- docker
- test
- deploy
.rebuild-image-rule: &rebuild-image-rule
if: $CI_PIPELINE_SOURCE == "push"
changes:
- ci/dnsjit/**/*
- .gitlab-ci.yml
dnsjit-image:
stage: docker
services:
- docker:23-dind
image: docker:23-dind
tags:
- amd64
- dind
rules:
- <<: *rebuild-image-rule
script:
# We concatenate '$CI_COMMIT_TAG$CI_COMMIT_TAG' here - they are exclusive,
# only one of them should apply
- docker login -u "$CI_REGISTRY_USER" -p "$CI_JOB_TOKEN" "$CI_REGISTRY"
- docker pull "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:latest" || true # to use as many cached layers as possible (allowed to fail)
- docker pull "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_BRANCH$CI_COMMIT_TAG" || true # to use as many cached layers as possible (allowed to fail)
- docker build --build-arg "CI_REGISTRY=$CI_REGISTRY" --tag "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_SHORT_SHA" ci/dnsjit
- test "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH"
&& docker tag "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:latest"
&& echo "Created 'latest' tag"
|| echo "Not on '$CI_DEFAULT_BRANCH' branch - skipping"
- test -n "$CI_COMMIT_BRANCH$CI_COMMIT_TAG"
&& docker tag "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_BRANCH$CI_COMMIT_TAG"
&& docker push "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_BRANCH$CI_COMMIT_TAG"
&& echo "Pushed '$CI_COMMIT_BRANCH$CI_COMMIT_TAG' tag"
|| echo "Not on a branch/tag"
- test "$CI_COMMIT_BRANCH" == "$CI_DEFAULT_BRANCH"
&& docker tag "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_SHORT_SHA" "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:latest"
&& docker push "$CI_REGISTRY/$DNSJIT_IMAGE_NAME:latest"
&& echo "Pushed 'latest' tag"
|| echo "Not on '$CI_DEFAULT_BRANCH' branch - skipping"
.debian: &debian
# Concatenating
image: $CI_REGISTRY/$DNSJIT_IMAGE_NAME:$CI_COMMIT_BRANCH$CI_COMMIT_TAG
# This is unsupported in GitLab <16.1
#needs: []
#rules:
# - <<: *rebuild-image-rule
# needs:
# - job: dnsjit-image
# artifacts: false
# - when: on_success
tags:
- docker
- linux
- amd64
black:
<<: *debian
stage: test
script:
- python3 -m black --check . --extend-exclude 'replay/dnssim/vendor'
mypy:
<<: *debian
stage: test
script:
- ./ci/mypy-run.sh
pylint:
<<: *debian
stage: test
script:
- pip3 install -r requirements.txt
- ./ci/pylint-run.sh
luacheck:
<<: *debian
stage: test
script:
- ./ci/luacheck-run.sh
.dnssim-build: &dnssim-build
<<: *debian
stage: test
script:
- mkdir replay/dnssim/build
- cd replay/dnssim/build
- echo "ASAN=$DNSSIM_ASAN UBSAN=$DNSSIM_UBSAN"
- cmake .. -DASAN=${DNSSIM_ASAN} -DUBSAN=${DNSSIM_UBSAN}
- make
dnssim-build:
<<: *dnssim-build
variables:
DNSSIM_ASAN: 0
DNSSIM_UBSAN: 0
dnssim-build-sanitizers:
<<: *dnssim-build
variables:
DNSSIM_ASAN: 1
DNSSIM_UBSAN: 1
docker:
stage: deploy
script:
- docker login -u gitlab-ci-token -p $CI_BUILD_TOKEN $CI_REGISTRY
- docker build --no-cache -t "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG" .
- docker push "$CI_REGISTRY_IMAGE:$CI_COMMIT_TAG"
tags:
- dind
only:
- tags