This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
forked from brndnmtthws/labhub
-
Notifications
You must be signed in to change notification settings - Fork 1
/
.gitlab-ci.yml
202 lines (190 loc) · 4.99 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
---
stages:
- dependencies
- build
- test
- checks
- publish
variables:
SCCACHE_GCS_BUCKET: btm-build-cache
SCCACHE_GCS_RW_MODE: READ_WRITE
SCCACHE_GCS_KEY_PATH: /tmp/storage-key.json
DOCKER_DRIVER: overlay2
CARGO_HOME: $CI_PROJECT_DIR/.cargo
before_script:
- echo $GCS_STORAGE_KEY > $SCCACHE_GCS_KEY_PATH
create builder:
stage: dependencies
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
- api_failure
allow_failure: true
image: docker:stable
only:
refs:
- master
services:
- docker:dind
before_script:
- set -- $CI_JOB_NAME
- export DOCKER_HOST="${DOCKER_HOST:-tcp://localhost:2375/}"
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
- docker pull $CI_REGISTRY_IMAGE/builder:latest || true
- docker pull rustlang/rust:nightly || true
script:
- >
docker build -f Dockerfile.builder
--cache-from $CI_REGISTRY_IMAGE/builder:latest
--cache-from rustlang/rust:nightly
--tag $CI_REGISTRY_IMAGE/builder:latest
.
- docker push $CI_REGISTRY_IMAGE/builder:latest
.build_script: &build_script
stage: build
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
- api_failure
image: $CI_REGISTRY_IMAGE/builder:latest
script:
- set -- $CI_JOB_NAME
- export TARGET=$1
- echo Running build for TARGET=$TARGET
- cargo build --verbose --all
artifacts:
paths:
- target/
expire_in: 30 days
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cargo/registry
i686-apple-darwin build: *build_script
i686-pc-windows-gnu build: *build_script
i686-pc-windows-msvc build: *build_script
i686-unknown-linux-gnu build: *build_script
x86_64-apple-darwin build: *build_script
x86_64-pc-windows-gnu build: *build_script
x86_64-pc-windows-msvc build: *build_script
x86_64-unknown-freebsd build: *build_script
x86_64-unknown-linux-gnu build: *build_script
.test_script: &test_script
stage: test
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
- api_failure
image: $CI_REGISTRY_IMAGE/builder:latest
script:
- set -- $CI_JOB_NAME
- export TARGET=$1
- cargo test --verbose --all --target $TARGET
- |
if [[ "$TARGET" == "x86_64-unknown-linux-gnu" ]]; then
cargo tarpaulin --out Xml && bash <(curl -s https://codecov.io/bash)
fi
coverage: '/(\d+.\d+%) coverage,/'
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cargo/registry
x86_64-unknown-linux-gnu test:
<<: *test_script
dependencies:
- x86_64-unknown-linux-gnu build
clippy:
stage: checks
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
- api_failure
image: $CI_REGISTRY_IMAGE/builder:latest
script:
- cargo clippy --all-targets --all-features -- -D warnings
dependencies:
- x86_64-unknown-linux-gnu build
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cargo/registry
rustfmt:
stage: checks
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
- api_failure
image: $CI_REGISTRY_IMAGE/builder:latest
script:
- cargo fmt --all -- --check
dependencies:
- x86_64-unknown-linux-gnu build
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cargo/registry
cargo publish:
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
- api_failure
only:
- tags
variables:
CARGO_HOME: /usr/local/cargo
stage: publish
image: $CI_REGISTRY_IMAGE/builder:latest
script:
- cargo publish --token $CRATESIO_TOKEN
dependencies:
- x86_64-unknown-linux-gnu build
.github_deploy: &github_deploy
retry:
max: 2
when:
- runner_system_failure
- stuck_or_timeout_failure
- unknown_failure
- api_failure
only:
- tags
stage: publish
image: $CI_REGISTRY_IMAGE/builder:latest
script:
- set -- $CI_JOB_NAME
- export TARGET=$1
- cargo build --release
- RELEASE_NAME="labhub-$CI_COMMIT_TAG-$TARGET"
- mkdir $RELEASE_NAME
- cp target/release/labhub $RELEASE_NAME/
- cp README.md LICENSE $RELEASE_NAME/
- tar czvf $RELEASE_NAME.tar.gz $RELEASE_NAME
- echo -n $(shasum -ba 256 "$RELEASE_NAME.tar.gz" | cut -d " " -f 1) > $RELEASE_NAME.tar.gz.sha256
- github-release release -u brndnmtthws -r labhub -t $CI_COMMIT_TAG --name "LabHub $CI_COMMIT_TAG"
- github-release upload -u brndnmtthws -r labhub -t $CI_COMMIT_TAG --name $RELEASE_NAME.tar.gz -f $RELEASE_NAME.tar.gz
- github-release upload -u brndnmtthws -r labhub -t $CI_COMMIT_TAG --name $RELEASE_NAME.tar.gz.sha256 -f $RELEASE_NAME.tar.gz.sha256
dependencies:
- x86_64-unknown-linux-gnu build
cache:
key: ${CI_COMMIT_REF_SLUG}
paths:
- .cargo/registry
x86_64-unknown-linux-gnu publish: *github_deploy