-
Notifications
You must be signed in to change notification settings - Fork 3
424 lines (404 loc) Β· 13.7 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
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
# TODO:
# * Use a real changelog for the release (see https://github.com/urbica/martin/blob/master/.github/workflows/ci.yml#L198)
# * Nightly run for cargo audit
# * Centralize Rust version into a single env variable (possible?)
# * Possible to centralize OS versions into env variable?
# https://stackoverflow.com/questions/58981442/how-can-i-centralize-dry-a-string-in-github-actions-config-yaml
on: [push]
name: Build and Test
env:
RUST_BACKTRACE: 1
jobs:
fmt:
name: Rustfmt
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.59.0
steps:
- uses: actions/checkout@v1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Install rustfmt
run: |
rustup component add rustfmt
rustfmt --version
- uses: actions-rs/cargo@v1
with:
command: fmt
args: --all -- --check
check:
name: Check
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.59.0
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
# - name: Cache (cargo registry)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/registry
# key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo index)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/git
# key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo build)
# uses: actions/cache@v1
# with:
# path: target
# key: cargo-build-target-Linux-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: check
test:
name: Test Suite
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
build:
- linux-musl
- linux-gnu
- macos
- win-gnu
- win-msvc
include:
- build: linux-musl
os: ubuntu-latest
rust: 1.59.0
target: x86_64-unknown-linux-musl
- build: linux-gnu
os: ubuntu-latest
rust: 1.59.0
target: x86_64-unknown-linux-gnu
- build: macos
os: macOS-latest
rust: 1.59.0
target: x86_64-apple-darwin
- build: win-gnu
os: windows-latest
rust: 1.59.0
target: x86_64-pc-windows-gnu
- build: win-msvc
os: windows-latest
rust: 1.59.0
target: x86_64-pc-windows-msvc
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
steps:
- name: Git checkout
uses: actions/checkout@v1
with:
fetch-depth: 1
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Install additional packages (linux-musl)
if: contains(matrix.target, 'x86_64-unknown-linux-musl')
run: sudo apt-get install musl-tools
- name: Copy crt2.o from mingw (windows-gnu)
if: contains(matrix.target, 'x86_64-pc-windows-gnu')
# See:
# https://github.com/rust-lang/rust/issues/49078
# https://github.com/rust-lang/rust/issues/53454
# https://www.reddit.com/r/rust/comments/cvyuqk/uptodate_way_to_crosscompile_from_osx_to_windows/
run: |
$crt2="C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\x86_64-w64-mingw32\lib\crt2.o"
Copy-Item $crt2 -Destination C:\Rust\.rustup\toolchains\1.59.0-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\crt2.o -Force
# - name: Cache (cargo registry)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/registry
# key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo index)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/git
# key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo build)
# uses: actions/cache@v1
# with:
# path: target
# key: cargo-build-target-${{ runner.os }}-${{ hashFiles('**/Cargo.lock') }}
- name: Build (cargo build)
uses: actions-rs/cargo@v1
with:
command: build
args: --all
- name: Build tests (cargo test)
uses: actions-rs/cargo@v1
with:
command: test
args: --no-run
- name: Upload hygeia as artifact (Linux)
uses: actions/upload-artifact@v1
if: contains(matrix.os, 'ubuntu')
with:
name: hygeia-${{ matrix.target }}-${{github.sha}}
path: target/${{ matrix.target }}/debug/hygeia
- name: Upload hygeia as artifact (macOS)
uses: actions/upload-artifact@v1
if: contains(matrix.os, 'macOS')
with:
name: hygeia-${{ matrix.target }}-${{github.sha}}
path: target/${{ matrix.target }}/debug/hygeia
- name: Upload hygeia.exe as artifact (Windows)
uses: actions/upload-artifact@v1
if: "contains(matrix.os, 'windows')"
with:
name: hygeia-${{ matrix.target }}-${{github.sha}}
path: target/${{ matrix.target }}/debug/hygeia.exe
- name: Unit Tests (cargo test)
uses: actions-rs/cargo@v1
with:
command: xtask
args: test unit
- name: Integration Tests (cargo test integration)
uses: actions-rs/cargo@v1
with:
command: xtask
args: test integration commands
# Don't run this in CI since it's way too long (manually stopped after 1h45)
# - name: Integration Tests (install all Python 3)
# uses: actions-rs/cargo@v1
# with:
# command: xtask
# args: test integration all-versions
clippy:
name: Clippy
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.59.0
steps:
- uses: actions/checkout@v1
with:
fetch-depth: 1
- uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- run: rustup component add clippy
# - name: Cache (cargo registry)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/registry
# key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo index)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/git
# key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo build)
# uses: actions/cache@v1
# with:
# path: target
# key: cargo-build-target-Linux-${{ hashFiles('**/Cargo.lock') }}
- uses: actions-rs/cargo@v1
with:
command: clippy
args: -- -D warnings
audit:
name: Security Audit
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- 1.59.0
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Install Rust toolchain
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
override: true
- name: Print Rust versions
run: |
rustup --version
rustc --version
cargo --version
- name: Install 'cargo-deny'
# See https://github.com/embarkstudios/cargo-deny
run: |
curl -L "https://github.com/EmbarkStudios/cargo-deny/releases/download/0.11.3/cargo-deny-0.11.3-x86_64-unknown-linux-musl.tar.gz" | tar -zxv
mv *-x86_64-*/cargo-* ~/.cargo/bin/
rm -fr *-x86_64-*
cargo deny --help
- name: Print licenses
run: cargo deny list
- name: Verify security advisories
run: cargo deny check advisories
coverage:
name: Code coverage
runs-on: ubuntu-latest
container:
image: xd009642/tarpaulin@sha256:0d0ab09cc0ee15af5a9de46547647191d6fb4e7cf2d24767e71483ac2b22a85f
env:
RUST_BACKTRACE: 1
volumes:
- ${{ github.workspace }}:/volume
options: --security-opt seccomp=unconfined
steps:
- uses: actions/checkout@v1
# - name: Cache (cargo registry)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/registry
# key: cargo-registry-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo index)
# uses: actions/cache@v1
# with:
# path: ~/.cargo/git
# key: cargo-index-${{ hashFiles('**/Cargo.lock') }}
# - name: Cache (cargo build)
# uses: actions/cache@v1
# with:
# path: target
# key: cargo-build-target-tarpaulin-${{ hashFiles('**/Cargo.lock') }}
- name: Run tarpaulin
run: cargo tarpaulin --out Xml --verbose --exclude-files "tests/integration/*" --exclude-files "xtask/*" --exclude-files "hygeia_test_helpers/*" integration_tests -- "tests::"
- name: Upload coverage to codecov.io
# run: bash <(curl -s https://codecov.io/bash)
uses: codecov/codecov-action@v1
with:
token: ${{ secrets.CODECOV_TOKEN }} #required
file: ./cobertura.xml
# flags: unittests #optional
# name: codecov-umbrella #optional
# yml: ./codecov.yml #optional
# Inspired by:
# https://github.com/BurntSushi/ripgrep/blob/8cb7271b647f63420530ac04bc13ed8ea7353690/.github/workflows/ci.yml#L10-L101
# https://github.com/actions/create-release/issues/14
create_release:
name: Create GitHub release
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: [fmt, check, test, clippy, coverage]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Create GitHub release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # This token is provided by Actions
with:
tag_name: ${{ github.ref }}
release_name: ${{ github.ref }}
body: |
Changes in this Release
- First Change
- Second Change
draft: true
prerelease: true
- name: Output release URL file
run: echo "${{ steps.create_release.outputs.upload_url }}" > release_url.txt
- name: Save Release URL File for publish
uses: actions/upload-artifact@v1
with:
name: release_url
path: release_url.txt
release:
name: Build release binary
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/v')
needs: create_release
runs-on: ${{ matrix.os }}
strategy:
matrix:
build:
- musl
- macos
- win-gnu
- win-msvc
include:
- build: musl
os: ubuntu-latest
rust: 1.59.0
target: x86_64-unknown-linux-musl
- build: macos
os: macOS-latest
rust: 1.59.0
target: x86_64-apple-darwin
- build: win-gnu
os: windows-latest
rust: 1.59.0
target: x86_64-pc-windows-gnu
- build: win-msvc
os: windows-latest
rust: 1.59.0
target: x86_64-pc-windows-msvc
env:
CARGO_BUILD_TARGET: ${{ matrix.target }}
steps:
- name: Git checkout
uses: actions/checkout@v1
- name: Load Release URL File from release job
uses: actions/download-artifact@v1
with:
name: release_url
- name: Install Rust
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: ${{ matrix.rust }}
target: ${{ matrix.target }}
override: true
- name: Install Rust Target
run: rustup target add ${{ matrix.target }}
- name: Install musl-gcc
if: contains(matrix.target, 'musl')
run: |
sudo apt-get install musl-tools
- name: Copy crt2.o from mingw (windows-gnu)
if: contains(matrix.target, 'x86_64-pc-windows-gnu')
# See:
# https://github.com/rust-lang/rust/issues/49078
# https://github.com/rust-lang/rust/issues/53454
# https://www.reddit.com/r/rust/comments/cvyuqk/uptodate_way_to_crosscompile_from_osx_to_windows/
run: |
$crt2="C:\ProgramData\Chocolatey\lib\mingw\tools\install\mingw64\x86_64-w64-mingw32\lib\crt2.o"
Copy-Item $crt2 -Destination C:\Rust\.rustup\toolchains\1.59.0-x86_64-pc-windows-msvc\lib\rustlib\x86_64-pc-windows-gnu\lib\crt2.o -Force
- name: Build release
uses: actions-rs/cargo@v1
with:
command: build
args: --release
- name: Package artifacts
id: package
run: |
cargo xtask package-artifacts --target release --target-triple ${{ matrix.target }}
echo "::set-output name=git_describe::$(git describe --always --tags --long --dirty=-modified)"
- name: Get release file name and upload URL
id: get_release_info
run: cargo xtask release-url
- name: Upload assets
uses: actions/[email protected]
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
upload_url: ${{ steps.get_release_info.outputs.upload_url }}
asset_path: ./hygeia-${{ steps.package.outputs.git_describe }}-${{ matrix.target }}.zip
asset_name: hygeia-${{ steps.package.outputs.git_describe }}-${{ matrix.target }}.zip
asset_content_type: application/zip