-
Notifications
You must be signed in to change notification settings - Fork 39
121 lines (116 loc) · 3.7 KB
/
main.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
name: Rust Build and Test
on:
pull_request:
push:
branches:
- master
- '[0-9]+.[0-9]+'
env:
CARGO_TERM_COLOR: always
jobs:
lint:
name: Lint ${{ matrix.features.name }}
runs-on: ubuntu-latest
strategy:
matrix:
features:
- name: all features
value: --all-features --manifest-path binrw/Cargo.toml
check_formatting: True
- name: no_std
value: --no-default-features --manifest-path binrw/Cargo.toml
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
components: clippy, rustfmt
- name: Check formatting
# There is no reason to check formatting more than once since it is
# a syntax check that does not change depending upon compiler features
if: matrix.features.check_formatting
run: cargo fmt -- --check
- name: Run clippy
run: cargo clippy --all-targets ${{ matrix.features.value }} -- -D warnings
- name: Build documentation
run: cargo rustdoc ${{ matrix.features.value }} -- -D warnings
test:
name: Test ${{ matrix.features.name }} on Rust ${{ matrix.rust }}
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
- nightly
- 1.66 # rust-version, msrv
features:
- name: all features
value: --all-features
- name: no_std
value: --no-default-features --manifest-path binrw/Cargo.toml
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Build workspace
run: cargo build ${{ matrix.features.value }}
# Testing is separated just to more clearly differentiate in the CI
# whether the build failed or a test failed
- name: Run tests
run: cargo test ${{ matrix.features.value }}
coverage:
name: Code coverage
runs-on: ubuntu-latest
env:
RUST_BACKTRACE: 1
steps:
- name: Check out code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: llvm-tools-preview
- name: Install llvm-cov
uses: taiki-e/install-action@v1
with:
tool: cargo-llvm-cov
- name: Generate default features
run: >
cargo llvm-cov --doctests
--no-report
- name: Generate all features
run: >
cargo llvm-cov --doctests --all-features
--no-report
- name: Generate no features
run: >
cargo llvm-cov --doctests --no-default-features
--no-report
- name: Show coverage results
run: >
cargo llvm-cov --doctests
--ignore-filename-regex 'binrw/(tests|src/docs)'
--no-run
# https://github.com/actions/runner/issues/520
- name: Determine whether codecov.io secret is available
id: has_codecov
run: echo 'result=${{ secrets.CODECOV_TOKEN }}' >> $GITHUB_OUTPUT
- name: Generate coverage file
run: >
cargo llvm-cov --doctests
--ignore-filename-regex 'binrw/(tests|src/docs)'
--no-run
--lcov --output-path lcov.info
if: steps.has_codecov.outputs.result != 0
- name: Upload to codecov.io
uses: codecov/codecov-action@v1
with:
files: lcov.info
token: ${{ secrets.CODECOV_TOKEN }}
if: steps.has_codecov.outputs.result != 0