-
Notifications
You must be signed in to change notification settings - Fork 0
113 lines (94 loc) · 3.2 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
name: CI
on:
push:
branches:
- main
pull_request:
branches:
- main
workflow_dispatch:
jobs:
check:
runs-on: ubuntu-latest
env:
# Make sure CI fails on all warnings, including Clippy lints
RUSTFLAGS: "-Dwarnings"
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
components: clippy, rustfmt
- name: Show rust toolchain info
shell: bash
run: |
rustup -V
rustup default
cargo -V
rustc -V
- name: Check formatting
run: |
cargo fmt --all -- --check
- name: Lint
run: |
cargo clippy --all-targets --all-features -- -v
build-test:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
fail-fast: false
env:
# Make sure CI fails on all warnings, including Clippy lints
RUSTFLAGS: "-Dwarnings"
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: stable
- name: Build
run: cargo build --workspace --all-targets --all-features --verbose
- name: Test
run: cargo test --all-targets --all-features
coverage:
needs: check
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
fail-fast: false
env:
RUST_BACKTRACE: 1
steps:
- uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@stable
with:
toolchain: nightly
- name: "`grcov` ~ install"
run: cargo install grcov
# https://github.com/mozilla/grcov#example-how-to-generate-source-based-coverage-for-a-rust-project
- name: "add source based coverage support"
run: rustup component add llvm-tools-preview
- name: Execute tests
run: cargo test --no-fail-fast --locked --all-targets
env:
CARGO_INCREMENTAL: "0"
RUSTFLAGS: "-Cinstrument-coverage -Ccodegen-units=1 -Copt-level=0 -Clink-dead-code -Coverflow-checks=off"
- name: Generate coverage data (via `grcov`)
id: coverage
shell: bash
run: |
## Generate coverage data
COVERAGE_REPORT_DIR="target/debug"
COVERAGE_REPORT_FILE="${COVERAGE_REPORT_DIR}/lcov.info"
echo "report=${COVERAGE_REPORT_FILE}" >> $GITHUB_OUTPUT
mkdir -p "${COVERAGE_REPORT_DIR}"
# display coverage files
# grcov . --output-type files --ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*" --ignore "**/tests/" --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()" | sort --unique
# generate coverage report
grcov . -s . --binary-path ./target/debug/ --output-type lcov --output-path "${COVERAGE_REPORT_FILE}" --branch --ignore build.rs --ignore "/*" --ignore "[a-zA-Z]:/*" --ignore "**/tests/" --excl-start '#(\[cfg\(test\)\]|\[test\])' --excl-br-line "^\s*((debug_)?assert(_eq|_ne)?!|#\[derive\()"
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v3
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}