This repository has been archived by the owner on Nov 21, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
119 lines (101 loc) · 3.93 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
default:
interruptible: true
image: registry.gitlab.com/kage-yami/dockerfile/rust:1.50.0-main
retry:
max: 2
when:
- runner_system_failure
stages:
- test
- check
- build
- publish
cache:
key: $CI_COMMIT_REF_SLUG.$CI_JOB_NAME
paths:
- target
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
#################################################### JOB TEMPLATES #####################################################
.test: &test
stage: test
rules:
- if: $CI_COMMIT_TAG
when: never
- when: on_success
.check: &check
stage: check
rules: &publish-rules
- if: $CI_COMMIT_TAG
when: on_success
- when: never
.build: &build
stage: build
rules:
- if: $CI_COMMIT_TAG
when: on_success
- if: $CI_COMMIT_REF_SLUG == "main"
when: on_success
- if: $CI_COMMIT_REF_SLUG == "develop"
when: on_success
- when: never
.publish: &publish
stage: publish
rules: *publish-rules
###################################################### TEST JOBS #######################################################
## These don't run for tagged pipelines (as tests should've already been run when the commit was made).
########################################################################################################################
test:
<<: *test
script:
- cargo test
lint:
<<: *test
script:
- cargo clippy &> >(tee lint.txt)
- test $(grep --count '^warning' lint.txt) -eq 0
coverage:
<<: *test
script:
- cargo tarpaulin --verbose
format:
<<: *test
script:
- cargo fmt -- --check
###################################################### BUILD JOBS ######################################################
## These run for tagged and untagged pipelines, but only for "main" and "develop" branches.
########################################################################################################################
# Runs after `check::version` (below) in tagged pipelines
builds:
<<: *build
image: alpine:3.13.2
script:
- chmod u+x ./scripts/fetch-github-artifacts.sh
- ./scripts/fetch-github-artifacts.sh
##################################################### PUBLISH JOBS #####################################################
## These don't run for untagged pipelines (as there's no point; no additional testing is done).
########################################################################################################################
version:
<<: *check
script:
- version=$(grep -Eo '^version = "[^"]*"$' Cargo.toml | sed -E 's|.+ = "([^"]+)"$|\1|')
- test $version = $CI_COMMIT_TAG
release:
<<: *publish
image: registry.gitlab.com/gitlab-org/release-cli:v0.6.0
variables:
REGISTRY: $CI_API_V4_URL/projects/$CI_PROJECT_ID/packages/generic
PACKAGE: $CI_COMMIT_TAG/ddns-for-cloudflare
script:
- |
release-cli create --tag-name $CI_COMMIT_TAG --description "./changelog/$CI_COMMIT_TAG.md" \
--assets-link "{ \"name\": \"linux-x86_64\", \"url\": \"$REGISTRY/linux-x86_64/$PACKAGE\", \"type\": \"package\" }" \
--assets-link "{ \"name\": \"linux-i686\", \"url\": \"$REGISTRY/linux-i686/$PACKAGE\", \"type\": \"package\" }" \
--assets-link "{ \"name\": \"linux-aarch64\", \"url\": \"$REGISTRY/linux-aarch64/$PACKAGE\", \"type\": \"package\" }" \
--assets-link "{ \"name\": \"linux-armv7hf\", \"url\": \"$REGISTRY/linux-armv7hf/$PACKAGE\", \"type\": \"package\" }" \
--assets-link "{ \"name\": \"linux-armhf\", \"url\": \"$REGISTRY/linux-armhf/$PACKAGE\", \"type\": \"package\" }" \
--assets-link "{ \"name\": \"windows-x86_64\", \"url\": \"$REGISTRY/windows-x86_64/$PACKAGE.exe\", \"type\": \"package\" }" \
--assets-link "{ \"name\": \"windows-i686\", \"url\": \"$REGISTRY/windows-i686/$PACKAGE.exe\", \"type\": \"package\" }" \
--assets-link "{ \"name\": \"macos-x86_64\", \"url\": \"$REGISTRY/macos-x86_64/$PACKAGE\", \"type\": \"package\" }"