This repository has been archived by the owner on Jun 22, 2023. It is now read-only.
forked from mozilla/sccache
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
157 lines (139 loc) · 5.04 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
# .gitlab-ci.yml
#
# sccache
stages:
- check
- test
- build
- publish
variables:
GIT_STRATEGY: fetch
GIT_DEPTH: 100
CARGO_INCREMENTAL: 0
RUST_BACKTRACE: 1
# this var is changed to "-:staging" when the CI image gets rebuilt
# read more https://github.com/paritytech/scripts/pull/244
CI_IMAGE: "paritytech/sccache-ci-ubuntu:staging" # temporary override
workflow:
rules:
- if: $CI_COMMIT_TAG
- if: $CI_COMMIT_BRANCH
.docker-env: &docker-env
image: "${CI_IMAGE}"
before_script:
- which gcc && gcc --version
- which clang && clang --version
- rustc +stable --version
- rustc +nightly --version
- sccache -s
retry:
max: 2
when:
- runner_system_failure
- unknown_failure
- api_failure
interruptible: true
tags:
- linux-docker
.kubernetes-env: &kubernetes-env
tags:
- kubernetes-parity-build
interruptible: true
.build-refs: &build-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^[0-9]+$/ # PRs
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
.publish-refs: &publish-refs
rules:
- if: $CI_PIPELINE_SOURCE == "web"
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_COMMIT_REF_NAME == "master"
- if: $CI_COMMIT_REF_NAME == "tags"
- if: $CI_COMMIT_REF_NAME =~ /^v[0-9]+\.[0-9]+.*$/ # i.e. v1.0, v2.1rc1
.collect-artifacts: &collect-artifacts
artifacts:
name: "${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
when: on_success
expire_in: 7 days
paths:
- artifacts/
#### stage: check
fmt:
<<: *docker-env
stage: check
script:
- cargo fmt -- --check
allow_failure: true
clippy:
<<: *docker-env
stage: check
script:
- cargo clippy --all-targets
allow_failure: true
#### stage: test
nightly-test:
<<: *docker-env
stage: test
variables:
FEATURES: "unstable"
script:
- cargo +nightly build --verbose --features="${FEATURES}" || exit 1
- cargo +nightly test --workspace --verbose --features="${FEATURES}"
stable-test:
<<: *docker-env
stage: test
variables:
FEATURES: ""
script:
- cargo +stable build --verbose --features="${FEATURES}" || exit 1
- cargo +stable test --workspace --verbose --features="${FEATURES}"
build:
<<: *docker-env
<<: *collect-artifacts
<<: *build-refs
stage: build
variables:
FEATURES: "openssl/vendored,dist-server"
script:
- cargo +stable build --locked --release --verbose --bin sccache-dist --target x86_64-unknown-linux-musl --features=${FEATURES}
# collect artifacts
- mkdir -p ./artifacts/sccache/
- mv ./target/x86_64-unknown-linux-musl/release/sccache-dist ./artifacts/sccache/.
- mv ./systemd/Dockerfile.vendor.sccache-dist ./artifacts/sccache/.
.build-push-docker-image: &build-push-docker-image
<<: *kubernetes-env
image: quay.io/buildah/stable
variables: &docker-build-vars
GIT_STRATEGY: none
DOCKERFILE: Dockerfile.vendor.sccache-dist
IMAGE_NAME: docker.io/paritytech/sccache-dist
before_script:
- cd ./artifacts/sccache/
- VERSION=${CI_COMMIT_REF_NAME}-${CI_COMMIT_SHORT_SHA}
script:
- test "$Docker_Hub_User_Parity" -a "$Docker_Hub_Pass_Parity" ||
( echo "no docker credentials provided"; exit 1 )
- buildah bud
--format=docker
--build-arg VCS_REF="${CI_COMMIT_SHA}"
--build-arg BUILD_DATE="$(date -u '+%Y-%m-%dT%H:%M:%SZ')"
--tag "$IMAGE_NAME:$VERSION"
--tag "$IMAGE_NAME:latest"
--file "$DOCKERFILE" .
- echo "$Docker_Hub_Pass_Parity" |
buildah login --username "$Docker_Hub_User_Parity" --password-stdin docker.io
- buildah info
- buildah push --format=v2s2 "$IMAGE_NAME:$VERSION"
after_script:
- buildah logout --all
publish-sccache-dist:
stage: publish
<<: *publish-refs
<<: *build-push-docker-image
needs:
- job: build
artifacts: true