-
Notifications
You must be signed in to change notification settings - Fork 4
/
.gitlab-ci.yml
211 lines (197 loc) · 6.26 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
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
variables:
GIT_SUBMODULE_STRATEGY: recursive
HASKELL_OPTIM: "-O0"
workflow:
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
variables:
HASKELL_OPTIM: "-O2"
- if: $CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS == null
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_COMMIT_TAG
variables:
HASKELL_OPTIM: "-O2"
stages:
- prerequisites
- check
- build
- test
- push
.docker:
image:
name: docker:cli
tags:
- dind
before_script:
- apk add curl
- docker login -u "${CI_REGISTRY_USER}" -p "${CI_JOB_TOKEN}" "${CI_REGISTRY}"
# --oci-worker-gc=false: see https://github.com/moby/buildkit/issues/4327#issuecomment-1772968980
- docker buildx create --driver=docker-container --buildkitd-flags '--oci-worker-gc=false' --use
- cp "${BLAZE_BINJA_LICENSE_FILE}" license.dat
- '
curl >BinaryNinja.zip -fsSL --proto "=https" --tlsv1.2
--header "JOB-TOKEN: ${CI_JOB_TOKEN}"
"${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/binaryninja-distribution/3.5.4526/BinaryNinja.zip"
|| { ls -l BinaryNinja.zip >&2; head -c1000 BinaryNinja.zip >&2; exit 1; }
'
after_script:
# See https://github.com/moby/buildkit/issues/4327#issuecomment-1772968980
- docker buildx stop || true
- docker buildx rm -f || true
# Grr, we randomly get weird docker/buildx/buildkit/gitlab container registry issues
retry: 2
base-images:
stage: prerequisites
needs: []
extends: .docker
script:
# --provenance=false: see https://gitlab.com/gitlab-org/gitlab/-/issues/388865#workaround
- docker buildx build --push
--pull
--provenance=false
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/haskell:cache
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/haskell:latest
--cache-to type=registry,ref="${CI_REGISTRY_IMAGE}"/haskell:cache
--target haskell
-t "${CI_REGISTRY_IMAGE}"/haskell:pipeline-"${CI_PIPELINE_ID}"
.
just-deps:
stage: prerequisites
needs:
- base-images
extends: .docker
script:
- docker buildx build --push
--pull
--provenance=false
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/just-deps:cache
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/just-deps:latest
--cache-to type=registry,ref="${CI_REGISTRY_IMAGE}"/just-deps:cache
--target just-deps
-t "${CI_REGISTRY_IMAGE}"/just-deps:pipeline-"${CI_PIPELINE_ID}"
.
install-hlint:
stage: prerequisites
needs:
- base-images
extends: .docker
script:
- docker buildx build --push
--pull
--provenance=false
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/hlint:cache
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/hlint:latest
--cache-to type=registry,ref="${CI_REGISTRY_IMAGE}"/hlint:cache
--target hlint
-t "${CI_REGISTRY_IMAGE}"/hlint:pipeline-"${CI_PIPELINE_ID}"
.
# stage: check
include:
project: 'blaze/filter-check'
file: '/filtercheck.gitlab-ci.yml'
hlint:
stage: check
needs:
- install-hlint
image: ${CI_REGISTRY_IMAGE}/hlint:pipeline-${CI_PIPELINE_ID}
script:
- just hlint --color=always
allow_failure: true
ghc-warnings:
stage: check
needs:
- just-deps
image: ${CI_REGISTRY_IMAGE}/just-deps:pipeline-${CI_PIPELINE_ID}
script:
- stack clean
- stack --color always build --test --no-run-tests --pedantic --fast
allow_failure: true
build:
stage: build
needs:
- just-deps
extends: .docker
script:
- docker buildx build --push
--pull
--provenance=false
--target builder
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/builder:cache
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}"/builder:latest
--cache-to type=registry,ref="${CI_REGISTRY_IMAGE}"/builder:cache
--build-arg OPTIM=${HASKELL_OPTIM}
-t "${CI_REGISTRY_IMAGE}"/builder:pipeline-"${CI_PIPELINE_ID}"
.
- docker buildx build --push
--pull
--provenance=false
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}":cache
--cache-from type=registry,ref="${CI_REGISTRY_IMAGE}":latest
--cache-to type=registry,ref="${CI_REGISTRY_IMAGE}":cache
-t "${CI_REGISTRY_IMAGE}":pipeline-"${CI_PIPELINE_ID}"
.
test:
stage: test
needs:
- build
image: ${CI_REGISTRY_IMAGE}/builder:pipeline-${CI_PIPELINE_ID}
script:
- mkdir -p /root/.binaryninja
- cp "${BLAZE_BINJA_LICENSE_FILE}" /root/.binaryninja/license.dat
- /out/run-tests --color
push:latest:
stage: push
extends: .docker
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
needs:
- test
variables:
GIT_STRATEGY: none
GIT_CLEAN_FLAGS: none
script:
- images="${CI_REGISTRY_IMAGE}/haskell ${CI_REGISTRY_IMAGE}/hlint ${CI_REGISTRY_IMAGE}/builder ${CI_REGISTRY_IMAGE}"
- |-
set -euxo pipefail
for image in ${images}; do
docker pull "${image}:pipeline-${CI_PIPELINE_ID}"
docker tag "${image}:pipeline-${CI_PIPELINE_ID}" "${image}:latest"
docker push "${image}:latest"
done
push:tag:
stage: push
extends: .docker
rules:
- if: $CI_COMMIT_TAG
needs:
- test
variables:
GIT_STRATEGY: none
GIT_CLEAN_FLAGS: none
script:
- images="${CI_REGISTRY_IMAGE}/haskell ${CI_REGISTRY_IMAGE}/hlint ${CI_REGISTRY_IMAGE}/builder ${CI_REGISTRY_IMAGE}"
- |-
set -euxo pipefail
for image in ${images}; do
docker pull "${image}:pipeline-${CI_PIPELINE_ID}"
docker tag "${image}:pipeline-${CI_PIPELINE_ID}" "${image}:tag-${CI_COMMIT_TAG}"
docker push "${image}:tag-${CI_COMMIT_TAG}"
done
cleanup:
stage: .post
extends: .docker
when: always
variables:
GIT_STRATEGY: none
GIT_CLEAN_FLAGS: none
script:
- docker buildx rm blaze-platform-builder || true
- images="${CI_REGISTRY_IMAGE}/haskell ${CI_REGISTRY_IMAGE}/hlint ${CI_REGISTRY_IMAGE}/builder ${CI_REGISTRY_IMAGE}"
- |-
set -euxo pipefail
for image in ${images}; do
docker image rm "${image}:pipeline-${CI_PIPELINE_ID}" || true
if [ -n "${CI_COMMIT_TAG+x}" ]; then
docker image rm "${image}:tag-${CI_COMMIT_TAG}" || true
fi
done