This repository has been archived by the owner on Jan 12, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path.gitlab-ci.yml
97 lines (88 loc) · 3.51 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
# Copyright 2021 ItJustWorksTM
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
image: registry.git.chalmers.se/courses/dit638/students/2021-group-09/docker:20.10.5
variables:
DOCKER_HOST: tcp://docker:2375
DOCKER_TLS_CERTDIR: ""
DOCKER_CLI_EXPERIMENTAL: enabled
services:
- name: registry.git.chalmers.se/courses/dit638/students/2021-group-09/docker:20.10.5-dind
alias: docker
stages:
- deps
- build
- qemu
- deploy
before_script:
- apk add bash grep wget git tar gnuplot font-noto
- mkdir -p ~/.docker/cli-plugins/
- wget -O ~/.docker/cli-plugins/docker-buildx https://github.com/docker/buildx/releases/download/v0.5.1/buildx-v0.5.1.linux-amd64
- chmod a+x ~/.docker/cli-plugins/docker-buildx
- docker info
- docker login -u $CI_REGISTRY_USER -p $CI_REGISTRY_PASSWORD $CI_REGISTRY
- docker buildx create --name platformbuilder --use
- docker buildx inspect --bootstrap
update-deps-images:
stage: deps
tags:
- docker-build
script:
- bash ./update-deps-images.sh
build-and-test:
stage: build
tags:
- docker-build
script:
- awk '{sub(/rt-base:latest/, "rt-base:latest as built")}1' Dockerfile > Dockerfile.patched
- echo 'FROM scratch' >> Dockerfile.patched
- echo 'COPY --from=builder /opt/copycurve-coverage.xml /' >> Dockerfile.patched
- echo 'COPY --from=builder /opt/accuracy /accuracy' >> Dockerfile.patched
- DOCKER_BUILDKIT=1 docker build --progress=plain --output type=local,dest=out -f Dockerfile.patched --build-arg COVERAGE=On --build-arg ACCURACY=On .
- ls out/
- echo 'FROM scratch' > Dockerfile.accuracy
- echo 'ADD ./out/accuracy/* /' >> Dockerfile.accuracy
- DOCKER_BUILDKIT=1 docker build --progress=plain -f Dockerfile.accuracy -t "${CI_REGISTRY_IMAGE}/accuracy:${CI_COMMIT_SHA}" .
- docker push "${CI_REGISTRY_IMAGE}/accuracy:${CI_COMMIT_SHA}"
- mkdir accuracy accuracy/current accuracy/previous
- mv out/accuracy/* accuracy/current
- export PREVIOUS_COMMIT="$(git rev-parse HEAD~1)"
- docker pull "$CI_REGISTRY_IMAGE/accuracy:${PREVIOUS_COMMIT}"
- docker save -o accuracy/previous/ark.tar "$CI_REGISTRY_IMAGE/accuracy:${PREVIOUS_COMMIT}"
- (cd accuracy/previous; tar xf ark.tar; rm ark.tar; mv "$(find . -name '*.tar')" .; tar xf layer.tar)
- test/make_graphs.sh accuracy/ accuracy-out
- mv out/copycurve-coverage.xml coverage.xml
- >
echo -n "Coverage: " && echo "100 * $(grep -oPm1 'line-rate="\K\d+\.\d+(?=")' coverage.xml)" | bc
coverage: /^\s*Coverage:\s*\d+.\d+/
artifacts:
name: ${CI_JOB_NAME}-${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHA}
paths:
- accuracy-out
reports:
cobertura: coverage.xml
test-multiarch:
stage: qemu
tags:
- docker-build
script:
- docker buildx build --platform "linux/arm/v7" -f Dockerfile .
release:
stage: deploy
tags:
- docker-build
only:
- /^v[0-9]+(?:.[0-9]+)+[-0-9A-Za-z_]*$/
script:
- docker buildx build --platform "linux/amd64,linux/arm/v7" -f Dockerfile -t "$CI_REGISTRY_IMAGE":"$CI_COMMIT_TAG" --push .