-
Notifications
You must be signed in to change notification settings - Fork 8
275 lines (232 loc) · 7.99 KB
/
rust-build-test.yaml
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
name: 'Rust: Build and Test'
on:
push:
tags:
- rust-*
workflow_dispatch:
pull_request:
paths:
- 'lace/**'
- 'book/**'
- '.github/workflows/rust-build-test.yaml'
- '.github/scripts/run_code_in_mdfile.py'
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
env:
CARGO_TERM_COLOR: always
jobs:
features:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: . -> lace/target
- name: Install dependencies
run: cargo install cargo-hack
- name: Run cargo check on all features
working-directory: lace
run: cargo hack check --each-feature --all-targets
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: lace
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt, clippy
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: . -> lace/target
- name: Run rustfmt (Lace)
working-directory: lace
run: cargo fmt --all -- --check
- name: Run rustfmt (CLI)
working-directory: cli
run: cargo fmt --all -- --check
- name: Run clippy (Lace)
working-directory: lace
env:
RUSTFLAGS: -C debuginfo=0
run: |
cargo clippy --all-features
- name: Run clippy (CLI)
working-directory: cli
env:
RUSTFLAGS: -C debuginfo=0
run: |
cargo clippy --all-features
- name: Install audit
run: cargo install cargo-audit
- name: Run audit (Lace)
working-directory: lace
# Note: Both `polars` and `arrow2` trigger this security violation
# due to their reliance on `chrono`, which is the ultimate source of the violation
# as of 2/21/23, no version of `chrono` has been published that fixes the issue
# and thus neither `polars` or `arrow2` can pass `audit` checks
run: cargo audit -f Cargo.lock --ignore RUSTSEC-2020-0071
- name: Run audit (CLI)
working-directory: cli
# Note: Both `polars` and `arrow2` trigger this security violation
# due to their reliance on `chrono`, which is the ultimate source of the violation
# as of 2/21/23, no version of `chrono` has been published that fixes the issue
# and thus neither `polars` or `arrow2` can pass `audit` checks
run: cargo audit -f Cargo.lock --ignore RUSTSEC-2020-0071
test:
runs-on: ${{ matrix.os }}
needs: ["lint", "features"]
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
defaults:
run:
working-directory: lace
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: . -> lace/target
- name: Regen Examples
working-directory: cli
env:
RUSTFLAGS: -C debuginfo=0
run: cargo run -- regen-examples
- name: Run Lace tests
env:
RUSTFLAGS: -C debuginfo=0
run: cargo test --all-features
- name: Run CLI tests
working-directory: cli
env:
RUSTFLAGS: -C debuginfo=0
run: cargo test --all-features
# semver-checks:
# runs-on: ubuntu-latest
# needs: ["features", "lint", "test"]
# steps:
# - name: Checkout branch
# uses: actions/checkout@v4
# with:
# path: branch
# - name: Checkout master
# uses: actions/checkout@v4
# with:
# ref: master
# path: master
# - name: Set up Rust
# uses: dtolnay/rust-toolchain@stable
# - name: Cache Rust
# uses: Swatinem/rust-cache@v2
# with:
# workspaces: . -> lace/target
# - name: Install extra cargo tools
# run: cargo install cargo-semver-checks --locked
# - name: Check for semver-incompatibilities
# run: cargo semver-checks check-release --manifest-path branch/lace/Cargo.toml --baseline-root master/lace --verbose
compile-benchmarks:
runs-on: ubuntu-latest
needs: ["features", "lint", "test"]
steps:
- uses: actions/checkout@v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Compile benchmark tests (but do not run)
uses: actions-rs/cargo@v1
with:
command: bench
args: --manifest-path lace/Cargo.toml --no-run
test-mdbook-rust:
name: Test MDBook Rust Snippets
runs-on: ubuntu-latest
needs: ["features", "lint", "test"]
steps:
- uses: actions/checkout@v4
- name: Install codedown
run: npm install -g codedown
- name: Set up Rust
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust
uses: Swatinem/rust-cache@v2
with:
workspaces: . -> lace/target
- name: Install rust-script
run: cargo install rust-script
- name: Test MDBook Code Samples (Rust)
env:
FORCE_COLOR: 1
run: |
pip install termcolor yq
NEW_VERSION=$(tomlq -r .package.version < lace/Cargo.toml)
python3 .github/scripts/run_code_in_mdfile.py directory rust book $NEW_VERSION --exclusion-file .github/resources/mdbook_exclusions.txt
release:
name: release
runs-on: ubuntu-latest
if: startsWith(github.ref, 'refs/tags/rust-')
needs: ["compile-benchmarks", "features", "lint", "test", "test-mdbook-rust"]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check Branch
env:
NEW_VERSION: ${{github.ref_name}}
run: |
git fetch origin master
git tag --merged origin/master | grep $NEW_VERSION
- uses: dtolnay/rust-toolchain@stable
- name: Check Semver
working-directory: lace
env:
NEW_VERSION: ${{github.ref_name}}
run: |
pip install yq
DEPLOYING_VERSION=$(echo "$NEW_VERSION" | perl -lpe 's/^rust-//')
MAIN_VERSION=$(tomlq -r .package.version Cargo.toml)
test "$DEPLOYING_VERSION" = "$MAIN_VERSION"
- name: Install dependencies
run: cargo install cargo-crate
- name: Publish Updated Library Crates to Crates.io
working-directory: lace
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
PACKAGE_ORDER: "lace_utils lace_consts lace_data lace_stats lace_codebook lace_geweke lace_cc lace_metadata lace"
run: |
for PACKAGE_NAME in $PACKAGE_ORDER
do
echo "Processing package $PACKAGE_NAME"
if [ "$PACKAGE_NAME" == 'lace' ]
then
CARGO_FILE="Cargo.toml"
else
CARGO_FILE="$PACKAGE_NAME/Cargo.toml"
fi
PACKAGE_VERSION=$(tomlq .package.version $CARGO_FILE)
ALREADY_PUBLISHED=$(cargo crate info $PACKAGE_NAME --json --max-versions 100 | jq '[.krate.versions[].num] | any(. == '$PACKAGE_VERSION')')
if [ "$ALREADY_PUBLISHED" == 'false' ]
then
cargo publish --token "${CRATES_TOKEN}" -p $PACKAGE_NAME
fi
done
- name: Publish Updated CLI Crate to Crates.io
working-directory: cli
env:
CRATES_TOKEN: ${{ secrets.CRATES_TOKEN }}
run: |
PACKAGE_VERSION=$(tomlq .package.version Cargo.toml)
ALREADY_PUBLISHED=$(cargo crate info lace-cli --json --max-versions 100 | jq '[.krate.versions[].num] | any(. == '$PACKAGE_VERSION')')
if [ "$ALREADY_PUBLISHED" == 'false' ]
then
cargo publish --token "${CRATES_TOKEN}" -p lace-cli
fi