-
Notifications
You must be signed in to change notification settings - Fork 0
215 lines (215 loc) · 6.71 KB
/
rust.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
# rust.yml
#
# github workflows action file for si_trace_print
---
name: Rust
on:
push:
pull_request:
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
jobs:
# MSRV check
job_msrv:
name: build on ${{ matrix.msrv }} on ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# first `msrv` value should match Cargo.toml:[package]:rust-version
msrv: [1.56.0, 1.58.1, 1.60.0, 1.62.1, 1.64.0, 1.66.1, 1.68.2, 1.70.0]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- uses: moonrepo/setup-rust@v1
with:
channel: ${{ matrix.msrv }}
- name: Build using rust ${{ matrix.msrv }} on ${{ matrix.os }}
shell: bash
run: |
set -eux
cargo --version
rustc --print cfg
cargo build --lib --verbose --locked
- name: Test using rust ${{ matrix.msrv }} on ${{ matrix.os }}
shell: bash
run: |
set -eux
cargo --version
cargo test --lib --locked
# do all the basic rust stuff
job_fmt_clippy_build_buildrelease_test_doc:
name: fmt clippy build test doc
needs: [job_msrv]
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v3
- name: Check rustfmt
shell: bash
run: |
cargo --version
cargo fmt --version
cargo fmt --verbose --check
- name: Check clippy
shell: bash
run: |
cargo --version
cargo clippy --version
cargo clippy --no-deps --verbose --all-targets --all-features -- \
-D warnings
- name: Build Debug and Release
run: |
set -eux
cargo --version
cargo build --verbose
cargo build --verbose --release
- name: Run All Tests Single-threaded
run: |
set -eux
cargo --version
cargo test -j1 --verbose \
--all-features \
--future-incompat-report \
-- \
--test-threads=1
- name: Run Lib Tests Multi-threaded
run: |
set -eux
cargo --version
cargo test -j2 --lib --verbose -- --test-threads=2
cargo test -j4 --lib --verbose -- --test-threads=4
cargo test -j8 --lib --verbose -- --test-threads=8
cargo test -j8 --lib --verbose -- --test-threads=16
- name: Build Documentation
run: cargo doc --locked --release --frozen --no-deps -v
job_yamllint:
# this job install Python PIP packages
name: yamllint
needs: [job_msrv]
runs-on: ubuntu-latest
steps:
- name: git checkout
uses: actions/checkout@v3
- name: Use Python 3.11
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Install dependencies
run: |
set -eux
python --version
python -m pip \
--disable-pip-version-check \
--no-python-version-warning \
--version
python -m pip install \
--disable-pip-version-check \
--no-python-version-warning \
--no-color \
yamllint
python -m pip list \
--disable-pip-version-check \
--no-python-version-warning \
-v -v
- name: Run yamllint.sh
run: |
# XXX: ignore yamllint.sh errors, see Issue #120
PYTHON=python3 ./tools/yamllint.sh || true
# run code coverage with rust "stable" then upload to codecov.io
# help from
# - https://github.com/marketplace/actions/rust-grcov
# - https://eipi.xyz/blog/rust-code-coverage-with-github-workflows/
# - https://github.com/mozilla/grcov/blob/v0.8.18/README.md#example-how-to-generate-gcda-files-for-a-rust-project
# - https://github.com/mozilla/grcov/blob/v0.8.18/README.md#lcov-output
job_grcov:
name: grcov
runs-on: ubuntu-latest
needs: [job_msrv, job_fmt_clippy_build_buildrelease_test_doc]
steps:
- name: git checkout
uses: actions/checkout@v3
- name: get toolchain stable
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: stable
override: true
- name: cargo install
uses: actions-rs/cargo@v1
with:
command: install
args: --verbose -- rustfilt grcov
- name: cargo build with special profiling
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTC_BOOTSTRAP: 1
RUSTDOCFLAGS: -Cpanic=abort
RUSTFLAGS: -Zprofile
-Ccodegen-units=1
-Copt-level=0
-Clink-dead-code
-Coverflow-checks=off
-Zpanic_abort_tests
-Cpanic=abort
with:
command: build
args: --verbose
- name: cargo test with special profiling
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTC_BOOTSTRAP: 1
RUSTDOCFLAGS: -Cpanic=abort
RUSTFLAGS: -Zprofile
-Ccodegen-units=1
-Copt-level=0
-Clink-dead-code
-Coverflow-checks=off
-Zpanic_abort_tests
-Cpanic=abort
with:
command: test
args: --lib --no-fail-fast
- name: grcov
env:
CARGO_INCREMENTAL: 0
RUSTC_BOOTSTRAP: 1
RUSTDOCFLAGS: -Cpanic=abort
RUSTFLAGS: -Zprofile
-Ccodegen-units=1
-Copt-level=0
-Clink-dead-code
-Coverflow-checks=off
-Zpanic_abort_tests
-Cpanic=abort
run: |
set -eux
grcov --version
grcov \
. \
--source-dir ./src \
--log-level DEBUG \
--llvm \
--binary-path ./target/debug/ \
--branch \
--ignore-not-existing \
--output-type lcov \
--output-path lcov.info
ls -l
head lcov.info
# action from https://github.com/codecov/codecov-action
- name: upload codecov
uses: codecov/codecov-action@v3
with:
files: lcov.info
verbose: true
fail_ci_if_error: true
# public repository does not need secret section `with: token`
# see
# https://about.codecov.io/blog/javascript-code-coverage-using-github-actions-and-codecov/
#
# list of acceptable formats
# https://docs.codecov.com/docs/supported-report-formats