This repository has been archived by the owner on Feb 28, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 13
315 lines (287 loc) · 11.8 KB
/
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
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
name: ci
on:
pull_request:
push:
# Run periodic nightly checks to catch unrelated possible breakages
# in the meantime (e.g. some not pinned Docker image being updated or
# a change in the CI environment)
schedule:
- cron: '0 0 * * *'
jobs:
lint:
name: ${{ matrix.component }} ${{ matrix.os }}
runs-on: ${{ matrix.os }}
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macOS-latest, windows-latest]
component: [clippy]
include:
- component: rustfmt
cargo_cmd: fmt -- --check
os: ubuntu-latest
- component: clippy
cargo_cmd: clippy --locked --all-targets -- -D warnings
steps:
- name: Clone repository
uses: actions/checkout@v1
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
components: ${{ matrix.component }}
toolchain: 1.56.1
- name: clippy version
run: cargo clippy --version
if: ${{ matrix.component == 'clippy' }}
- name: Check
run: cargo ${{ matrix.cargo_cmd }}
test:
name: test ${{ matrix.os }} rust ${{ matrix.rustc || 'stable' }} ${{ matrix.extra_desc }} ${{ matrix.dist_exec_strategy }}
runs-on: ${{ matrix.os }}
continue-on-error: ${{ matrix.allow_failure || false }}
timeout-minutes: 30
strategy:
matrix:
include:
- os: ubuntu-20.04
rustc: 1.56.1 # Oldest supported version, keep in sync with README.md
- os: ubuntu-20.04
rustc: 1.56.1
extra_desc: dist-worker
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
cachepot_log: cachepot=trace
dist_exec_strategy: docker
- os: ubuntu-20.04
rustc: 1.56.1
extra_desc: dist-worker
extra_args: --no-default-features --features=dist-tests test_dist_ -- --test-threads 1
cachepot_log: cachepot=trace
cachepot_sandbox: userns
dist_exec_strategy: spawn
- os: ubuntu-20.04
rustc: stable
- os: ubuntu-20.04
rustc: beta
- os: ubuntu-20.04
rustc: nightly
allow_failure: true
extra_args: --features=unstable
- os: macOS-10.15
- os: windows-2019
env:
RUST_BACKTRACE: 1
DIST_EXEC_STRATEGY: ${{ matrix.dist_exec_strategy }}
CACHEPOT_SANDBOX: ${{ matrix.cachepot_sandbox }}
CACHEPOT_LOG: ${{ matrix.cachepot_log }}
steps:
- name: Clone repository
uses: actions/checkout@v1
- name: Install bubblewrap (needed for dist test suite)
if: contains(matrix.extra_desc, 'dist-worker')
run: sudo apt install bubblewrap -y
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: ${{ matrix.rustc }}
- name: Build tests
run: cargo test --no-run --locked --all-targets --verbose ${{ matrix.extra_args }}
- name: Run tests
run: cargo test --locked --all-targets --verbose ${{ matrix.extra_args }}
smoke:
name: smoke test ${{ matrix.rustc || 'stable' }} ${{ matrix.target_repository }}
needs: [build]
runs-on: ubuntu-20.04
continue-on-error: ${{ matrix.allow_failure || false }}
strategy:
matrix:
include:
- target_repository: paritytech/polkadot
# Pin a well-known nightly version to avoid upstream breakage
rustc: nightly-2021-11-01
target: wasm32-unknown-unknown
allow_failure: true
- target_repository: paritytech/substrate
rustc: nightly-2021-11-01
target: wasm32-unknown-unknown
allow_failure: true
- target_repository: serde-rs/serde
- target_repository: serde-rs/json
env:
RUST_BACKTRACE: 1
steps:
- name: Clone repository
uses: actions/checkout@v1
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: ${{ matrix.rustc }}
target: ${{ matrix.target }}
- name: Fetch current git tag/sha
id: id
shell: bash
run: echo "::set-output name=id::${ID#refs/tags/}"
env:
ID: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || github.sha }}
# To cut down on the workflow execution time, we re-use pre-compiled binaries
# here and simply vendor the `cachepot-dist` in the container via
# `CACHEPOT_IN_DOCKERFILE: vendor` rather than build separately it via Dockerfile
- name: Download artifacts (cachepot)
uses: actions/download-artifact@v2
with:
name: cachepot-${{ steps.id.outputs.id }}-x86_64-unknown-linux-musl
path: artifacts/
- name: Download artifacts (cachepot-dist)
uses: actions/download-artifact@v2
with:
name: cachepot-dist-${{ steps.id.outputs.id }}-x86_64-unknown-linux-musl
path: artifacts/
- name: Set up pre-built artifact binaries
run: |
cp artifacts/cachepot ~/.cargo/bin/cachepot
cp artifacts/cachepot-dist systemd/cachepot-dist
chmod +x ~/.cargo/bin/cachepot systemd/cachepot-dist
ls -la ~/.cargo/bin/cachepot systemd/cachepot-dist
- name: Set up local distributed cachepot stack
env:
RUST_LOG: cachepot=trace
CACHEPOT_IN_DOCKERFILE: vendor
run: docker-compose --file systemd/docker-compose.yaml up -d
# TODO: Wait until the stack is up/ready
- run: docker ps -a
- name: Clone the project repository being tested
uses: actions/checkout@v2
with:
repository: ${{ matrix.target_repository }}
path: target_repo
- name: Double-check that cachepot is not running
run: cachepot --stop-coordinator || true
- name: Start the local cachepot server daemon
run: cachepot --start-coordinator
# This is the main server that's going to send the compilation requests
# so logging is more important for this than for subsequent (client)
# cachepot invocations
env:
CACHEPOT_CONF: ${{ github.workspace }}/systemd/config/client.conf
CACHEPOT_LOG: cachepot=trace
CACHEPOT_ERROR_LOG: ${{ github.workspace }}/cachepot.err.log
- name: Verify that the local distributed cachepot stack is running
run: test $(cachepot --dist-status | jq ".SchedulerStatus[1].num_servers") -gt 0
- name: Run a smoke check build
env:
RUSTC_WRAPPER: cachepot
working-directory: target_repo
run: cargo check --verbose ${{ matrix.extra_args }}
- run: cachepot --show-stats
- name: Verify that the distribution compilation *did* take place
run:
test $(cachepot --show-stats --stats-format json | jq ".stats.dist_compiles | to_entries[].value") -gt 0
- name: Dump Compose logs
run: docker-compose --file systemd/docker-compose.yaml logs
if: failure()
- name: Dump local cachepot daemon server logs
run: cat ${{ github.workspace }}/cachepot.err.log
if: failure()
build:
name: build ${{ matrix.binary || 'cachepot' }} ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 30
strategy:
matrix:
include:
- os: ubuntu-20.04
target: x86_64-unknown-linux-musl
extra_args: --features="dist-worker"
- os: ubuntu-20.04
binary: cachepot-dist
extra_args: --features="dist-worker"
target: x86_64-unknown-linux-musl
- os: ubuntu-20.04
target: aarch64-unknown-linux-musl
- os: macOS-10.15
target: x86_64-apple-darwin
macosx_deployment_target: 10.13
developer_dir: /Applications/Xcode_10.3.app
sdkroot: /Applications/Xcode_10.3.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.14.sdk
- os: macOS-10.15
target: aarch64-apple-darwin
macosx_deployment_target: 11.0
developer_dir: /Applications/Xcode_12.2.app
sdkroot: /Applications/Xcode_12.2.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX11.0.sdk
- os: windows-2019
target: x86_64-pc-windows-msvc
rustflags: -Ctarget-feature=+crt-static
steps:
- name: Clone repository
uses: actions/checkout@v1
- uses: actions/cache@v2
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-build-v2-${{ matrix.target }}-${{ hashFiles('**/Cargo.lock') }}
- name: Install rust
uses: ./.github/actions/rust-toolchain
with:
toolchain: ${{ matrix.target == 'aarch64-apple-darwin' && 'beta' || 'stable' }}
target: ${{ matrix.target }}
- name: Install musl-tools
run: sudo apt-get install musl-tools
if: ${{ matrix.target == 'x86_64-unknown-linux-musl' }}
- name: Install musl-tools
run: |
set -x
echo deb [arch=arm64] http://azure.ports.ubuntu.com/ubuntu-ports/ $(lsb_release -c -s) main restricted universe multiverse | sudo tee /etc/apt/sources.list.d/99ports.list > /dev/null
sudo dpkg --add-architecture arm64
sudo apt-get update --fix-missing || true
sudo apt-get install musl-dev:arm64 binutils-multiarch gcc-10-aarch64-linux-gnu libc6-dev-arm64-cross
apt-get download musl-tools:arm64
sudo dpkg-deb -x musl-tools_*_arm64.deb /
sed 2iREALGCC=aarch64-linux-gnu-gcc-10 /usr/bin/musl-gcc | sudo tee /usr/bin/aarch64-linux-musl-gcc > /dev/null
sudo chmod +x /usr/bin/aarch64-linux-musl-gcc
if: ${{ matrix.target == 'aarch64-unknown-linux-musl' }}
- name: Build
run: cargo build --locked --release --verbose --bin ${{ matrix.binary || 'cachepot' }} --target ${{ matrix.target }} --features=openssl/vendored ${{ matrix.extra_args }}
env:
CARGO_TARGET_AARCH64_UNKNOWN_LINUX_MUSL_LINKER: aarch64-linux-musl-gcc
MACOSX_DEPLOYMENT_TARGET: ${{ matrix.macosx_deployment_target }}
DEVELOPER_DIR: ${{ matrix.developer_dir }}
SDKROOT: ${{ matrix.sdkroot }}
RUSTFLAGS: ${{ matrix.rustflags }}
# Workaround for the lack of substring() function in github actions expressions.
- name: Id
id: id
shell: bash
run: echo "::set-output name=id::${ID#refs/tags/}"
env:
ID: ${{ startsWith(github.ref, 'refs/tags/') && github.ref || github.sha }}
- name: Upload artifacts
uses: actions/upload-artifact@v2
with:
name: ${{ matrix.binary || 'cachepot' }}-${{ steps.id.outputs.id }}-${{ matrix.target }}
path: target/${{ matrix.target }}/release/${{ matrix.binary || 'cachepot' }}${{ endsWith(matrix.target, '-msvc') && '.exe' || '' }}
if-no-files-found: error
release:
name: release
runs-on: ubuntu-latest
needs: [build, lint, test, smoke]
if: ${{ startsWith(github.ref, 'refs/tags/') }}
steps:
- name: Clone repository
uses: actions/checkout@v1
- name: Get artifacts
uses: actions/download-artifact@v2
- name: Create release assets
run: |
for d in cachepot-*; do
cp README.md LICENSE $d/
tar -zcvf $d.tar.gz $d
echo -n $(shasum -ba 256 $d.tar.gz | cut -d " " -f 1) > $d.tar.gz.sha256
done
- name: Create release
run: |
tag_name=${GITHUB_REF#refs/tags/}
hub release create -m $tag_name $tag_name $(for f in cachepot-*.tar.gz*; do echo "-a $f"; done)
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}