336 lines (331 loc) · 11.8 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
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
# rust.yml
#
# github workflows action file for super-speedy-syslog-searcher
---
name: Rust
on:
push:
paths:
- .github/**
- Cargo.toml
- src/**.rs
pull_request:
paths:
- benches/**
- .github/**
- Cargo.toml
- "**.rs"
env:
CARGO_TERM_COLOR: always
RUST_BACKTRACE: 1
# run options for debug
S4_ARGSD: -z 0x2 -s
# run options for release
S4_ARGSR: -z 0x40 -s
# run files
S4_TEST_FILES: ./logs/other/tests/dtf2-2.log
./logs/other/tests/dtf3-2a.log
./logs/other/tests/dtf5-6a.log.gz
./logs/other/tests/dtf7-20-LEVELS.log.xz
./logs/other/tests/gen-2-1.tar
./logs/other/tests/gen-20-1-faces.log
./logs/other/tests/gen-20-1-⚀⚁⚂⚃⚄⚅.log
./logs/other/tests/gen-20-2-2-faces.log
jobs:
job_rust_msrv_os:
name: build MSRV ${{ matrix.msrv }} on ${{ matrix.os }}
strategy:
fail-fast: true
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
# first `msrv` should match Cargo.toml:[package]:rust-version
# add a few more for sanity checks (you might be surprised)
msrv: [1.61.0, 1.64.0, 1.66.1]
runs-on: ${{ matrix.os }}
steps:
# Issue #62: `git config` to workaround `git checkout` error on Windows
- run: |
git config --global core.protectNTFS false
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.msrv }}
- name: Build using rust ${{ matrix.msrv }} on ${{ matrix.os }}
shell: bash
run: |
set -eux
cargo --version
cargo build --verbose
job_rust_release_channel:
name: build release channel ${{ matrix.rust_version }}
runs-on: ubuntu-latest
strategy:
fail-fast: true
matrix:
rust_version: ["beta", "nightly"]
steps:
- uses: actions/checkout@v2
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_version }}
- uses: Swatinem/rust-cache@v2
- name: Build using rust ${{ matrix.rust_version }}
run: |
set -eux
cargo --version
cargo build --verbose
job_build_debug_release_test:
# all of these steps need to download and build dependency crates
name: check, clippy, build debug, build release, test
needs: [job_rust_release_channel, job_rust_msrv_os]
runs-on: ubuntu-latest
steps:
# build & upload debug
- name: git checkout
uses: actions/checkout@v2
- name: Check (cargo check)
shell: bash
# `cargo check` builds dependences and other things but skips
# final code generation
run: |
set -eux
cargo --version
cargo check --verbose --all-targets
cargo check --verbose --all-targets --release
- name: Check clippy
shell: bash
run: |
set -eux
cargo --version
cargo clippy --version
cargo clippy --no-deps --verbose --all-targets --all-features
- name: Build Debug
shell: bash
run: |
set -eux
cargo --version
cargo build --verbose
cp -av ./target/debug/s4 ./s4_debug
- name: Upload debug binary
uses: actions/upload-artifact@v3
with:
name: s4_debug
path: ./s4_debug
# build & upload release
- name: Build Release
shell: bash
run: |
set -eux
cargo --version
cargo build --release --verbose
cp -av ./target/release/s4 ./s4_release
- name: Upload release binary
uses: actions/upload-artifact@v3
with:
name: s4_release
path: ./s4_release
# - name: Bench
# run: cargo bench --no-run
# tests
- name: Run Tests
run: cargo test --verbose
- name: Build Documentation
run: cargo doc --locked --release --frozen --no-deps -v
- name: Check Publish
run: cargo publish --verbose --dry-run --allow-dirty
# - name: Run valgrind
# run: |
# set -eux
# sudo apt install -y valgrind g++
# SCRIPT=./tools/valgrind-dhat.sh
# chmod -v +x -- "${PROGRAM}" "${SCRIPT}"
# "${SCRIPT}"
job_runs:
# all of these steps need the s4 binary and the git-committed logs
name: run s4
needs: job_build_debug_release_test
runs-on: ubuntu-latest
steps:
# checkout for the log files
- name: git checkout
uses: actions/checkout@v2
# download & run debug
- name: Download debug binary
uses: actions/download-artifact@v3
with:
name: s4_debug
- name: Run Program Debug
shell: bash
run: |
set -eux
S4=./s4_debug
chmod -v +x -- ${S4}
${S4} --version
${S4} --help
${S4} --color=never ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=never ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=never -l -n -w ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=never -l -p -w ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=never -u -n -w ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=never -u -p -w ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=always -l -n -w ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=always -l -p -w ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=always -u -n -w ${S4_TEST_FILES} 2>/dev/null
${S4} ${S4_ARGSD} --color=always -u -p -w ${S4_TEST_FILES} 2>/dev/null
${S4} -s --color=never -l -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=never -l -p -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=never -u -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=never -u -p -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -l -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -l -p -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -u -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -u -p -w ${S4_TEST_FILES} &>/dev/null
# download & run release
- name: Download release binary
uses: actions/download-artifact@v3
with:
name: s4_release
- name: Run Program Release
shell: bash
run: |
set -eux
S4=./s4_release
chmod -v +x -- ${S4}
${S4} --version
${S4} --help
${S4} --color=never ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=never ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=never -l -n -w ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=never -l -p -w ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=never -u -n -w ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=never -u -p -w ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=always -l -n -w ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=always -l -p -w ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=always -u -n -w ${S4_TEST_FILES}
${S4} ${S4_ARGSR} --color=always -u -p -w ${S4_TEST_FILES}
${S4} -s --color=never ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=never -l -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=never -l -p -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=never -u -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=never -u -p -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -l -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -l -p -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -u -n -w ${S4_TEST_FILES} &>/dev/null
${S4} -s --color=always -u -p -w ${S4_TEST_FILES} &>/dev/null
- name: Compare Runs of Debug and Release
shell: bash
run: |
set -eu
S4R=./s4_release
S4D=./s4_debug
OUTR=output-release.txt
OUTD=output-debug.txt
chmod -v +x -- "${S4R}" "${S4D}"
set -x
time ${S4R} --version
time ${S4D} --version
${S4R} -s -z 0x800 --color=never ${S4_TEST_FILES} | tee "${OUTR}"
${S4D} -s -z 0x800 --color=never ${S4_TEST_FILES} 2>/dev/null | \
tee "${OUTD}"
diff --version
diff -y --suppress-common-lines --minimal "${OUTR}" "${OUTD}"
- name: Run Script compare-grep-sort
shell: bash
run: |
set -eux
export PROGRAM=./s4_release
SCRIPT=./tools/compare-grep-sort.sh
chmod -v +x -- "${PROGRAM}" "${SCRIPT}"
"${SCRIPT}"
- name: Run Script compare-current-and-expected
shell: bash
run: |
set -eux
chmod -v +x ./tools/log-files-time-update.sh
./tools/log-files-time-update.sh
export PROGRAM=./s4_release
SCRIPT=./tools/compare-current-and-expected.sh
chmod -v +x -- "${PROGRAM}" "${SCRIPT}"
"${SCRIPT}"
# Run code coverage with rust "nightly" (necessary for some `-Z` features)
# then upload code coverage result 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#lcov-output
job_grcov:
name: grcov
runs-on: ubuntu-latest
needs: job_runs
steps:
- name: git checkout
uses: actions/checkout@v1
- name: get toolchain nightly
uses: actions-rs/toolchain@v1
with:
profile: minimal
toolchain: nightly
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
RUSTFLAGS: -Zprofile
-Ccodegen-units=1 -Cinline-threshold=0
-Clink-dead-code -Coverflow-checks=off
-Cpanic=abort -Zpanic_abort_tests
with:
command: build
args: --verbose
- name: cargo test with special profiling
uses: actions-rs/cargo@v1
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Zprofile
-Ccodegen-units=1 -Cinline-threshold=0
-Clink-dead-code -Coverflow-checks=off
-Cpanic=abort -Zpanic_abort_tests
with:
command: test
args: --lib --no-fail-fast
- name: grcov
shell: bash
env:
CARGO_INCREMENTAL: 0
RUSTFLAGS: -Zprofile
-Ccodegen-units=1 -Cinline-threshold=0
-Clink-dead-code -Coverflow-checks=off
-Cpanic=abort -Zpanic_abort_tests
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