-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
173 lines (153 loc) · 3.64 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
#########
# Reuse #
#########
variables:
RUNNER_IMAGE: docker:20
SCRATCH_ARTIFACT_IMAGE: registry.gitlab.com/gisleburt-homelab/usb_status_lights
ALPINE_ARTIFACT_IMAGE: registry.gitlab.com/gisleburt-homelab/usb_status_lights/alpine
RUST_RUNNER: registry.gitlab.com/gisleburt-homelab/rust-builder:1.61.0.0
.tags: &tags
tags:
- linux
- arm64
- gisleburt
- homelab
##########
# Stages #
##########
stages:
- format
- lint
- test
- build
format-cli:
<<: *tags
stage: format
image: $RUST_RUNNER
needs: []
script:
- (cd status_lights_cli && cargo fmt --check)
format-messages:
<<: *tags
stage: format
image: $RUST_RUNNER
needs: []
script:
- (cd status_lights_messages && cargo fmt --check)
format-neo-trinkey:
<<: *tags
stage: format
image: $RUST_RUNNER
needs: []
script:
- (cd status_lights_neo_trinkey && cargo fmt --check)
lint-cli:
<<: *tags
stage: lint
image: $RUST_RUNNER
needs: []
script:
- (cd status_lights_cli && cargo clippy)
lint-messages:
<<: *tags
stage: lint
image: $RUST_RUNNER
needs: []
script:
- (cd status_lights_messages && cargo clippy)
lint-neo-trinkey:
<<: *tags
stage: lint
image: $RUST_RUNNER
needs: []
before_script:
- rustup target add thumbv6m-none-eabi
script:
- (cd status_lights_neo_trinkey && cargo clippy)
test-cli:
<<: *tags
stage: test
image: $RUST_RUNNER
needs: []
script:
- (cd status_lights_cli && cargo test)
test-messages:
<<: *tags
stage: test
image: $RUST_RUNNER
needs: []
script:
- (cd status_lights_messages && cargo test)
test-neo-trinkey:
<<: *tags
stage: test
image: $RUST_RUNNER
needs: []
before_script:
- rustup target add thumbv6m-none-eabi
script:
- (cd status_lights_neo_trinkey && cargo test)
#########
# Build #
#########
.docker-build: &docker-build
stage: build
image: docker:20-dind
variables:
DOCKER_HOST: tcp://localhost:2376
DOCKER_DRIVER: overlay2
DOCKER_TLS_CERTDIR: "/certs"
DOCKER_CERT_PATH: "$DOCKER_TLS_CERTDIR/client"
DOCKER_TLS_VERIFY: 1
services:
- name: docker:dind
command: [ "--mtu=1300" ]
before_script:
- wget google.com # test dns is working
- while [ ! -f /certs/client/ca.pem ]; do sleep 1; done
- ls -R /certs
- while ! docker info; do sleep 1; done
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
.build-cli-linux-arm64-base: &build-cli-linux-arm64-base
<<: *docker-build
<<: *tags
stage: build
needs:
- format-cli
- format-messages
- lint-cli
- lint-messages
- test-cli
- test-messages
build-cli-linux-arm64-scratch-latest:
<<: *build-cli-linux-arm64-base
except:
- tags
script:
- docker build . -t $SCRATCH_ARTIFACT_IMAGE
- docker push $SCRATCH_ARTIFACT_IMAGE
build-cli-linux-arm64-scratch-tag:
<<: *build-cli-linux-arm64-base
only:
- tags
script:
- docker build . -t $SCRATCH_ARTIFACT_IMAGE
- docker push $SCRATCH_ARTIFACT_IMAGE
- docker tag $SCRATCH_ARTIFACT_IMAGE $SCRATCH_ARTIFACT_IMAGE:$CI_COMMIT_TAG
- docker push $SCRATCH_ARTIFACT_IMAGE:$CI_COMMIT_TAG
build-cli-linux-arm64-alpine-latest:
<<: *build-cli-linux-arm64-base
except:
- tags
script:
- docker build . -t $ALPINE_ARTIFACT_IMAGE --build-arg BASE=alpine
- docker push $ALPINE_ARTIFACT_IMAGE
build-cli-linux-arm64-alpine-tag:
<<: *build-cli-linux-arm64-base
only:
- tags
script:
- docker build . -t $ALPINE_ARTIFACT_IMAGE --build-arg BASE=alpine
- docker push $ALPINE_ARTIFACT_IMAGE
- docker tag $ALPINE_ARTIFACT_IMAGE $ALPINE_ARTIFACT_IMAGE:$CI_COMMIT_TAG
- docker push $ALPINE_ARTIFACT_IMAGE:$CI_COMMIT_TAG