-
Notifications
You must be signed in to change notification settings - Fork 6
179 lines (175 loc) · 5.51 KB
/
ci.yml
File metadata and controls
179 lines (175 loc) · 5.51 KB
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
name: "CI"
on:
push:
branches:
- "main"
- "forks/*"
pull_request:
branches:
- "main"
- "v*.*.*-rc"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.event_name }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
RUST_TOOLCHAIN_NIGHTLY: nightly
CARGO_TERM_COLOR: always
CACHE_KEY_SUFFIX: 20250110
jobs:
misc-check:
name: misc check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run typos check
uses: crate-ci/typos@master
rust-machete:
name: rust machete check
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run cargo machete
uses: bnjbvr/cargo-machete@main
rust-ffmt-check:
name: rust ffmt check
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
components: rustfmt
- name: Cache Cargo home
uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ env.CACHE_KEY_SUFFIX }}-rust-ffmt-check
- name: Fastidious Format Check
run: |
cargo fmt --all --check -- --config-path rustfmt.nightly.toml
- name: Hint
if: ${{ failure() }}
run: |-
echo "The ffmt (Fastidious Format Check) test is not a necessary."
echo "It uses unstable features to achieve a better format."
echo "If you want to pass the test, please install the nightly toolchain with \`rustup install nightly\`."
echo "Then run \`make ffmt\`."
rust-test:
name: rust test with codecov
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
rust_toolchain: [stable]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust_toolchain }}
components: rustfmt, clippy, llvm-tools-preview
- name: Cache Cargo home
uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ env.CACHE_KEY_SUFFIX }}-rust-test
- name: Install cargo tools
if: steps.cache.outputs.cache-hit != 'true'
run: |
cargo install cargo-sort --locked
- name: Run rust cargo-sort check
# https://github.com/DevinR528/cargo-sort/issues/56
if: matrix.os != 'windows-latest'
run: |
cargo sort -w -c
- name: Run rust format check
run: |
cargo fmt --all -- --check
- name: Run rust clippy check (stable)
if: matrix.rust_toolchain == 'stable'
run: |
cargo clippy --all-targets --all-features -- -D warnings
- if: steps.cache.outputs.cache-hit != 'true'
uses: taiki-e/install-action@cargo-llvm-cov
- if: steps.cache.outputs.cache-hit != 'true'
uses: taiki-e/install-action@nextest
- name: Run rust test with coverage
env:
RUST_BACKTRACE: 1
CI: true
run: |
cargo llvm-cov --no-report nextest --all-features
- name: Run rust examples with coverage
env:
RUST_BACKTRACE: 1
CI: true
run: |
cargo llvm-cov --no-report run --example basic --features prometheus_0_14
- name: Generate codecov report
run: |
cargo llvm-cov report --lcov --output-path lcov.info
- uses: codecov/codecov-action@v4
if: runner.os == 'Linux' && matrix.rust_toolchain == 'stable'
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
verbose: true
rustdoc-test:
name: rust doc test
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: nightly
- name: Cache Cargo home
uses: actions/cache@v4
id: cache
with:
path: |
~/.cargo/bin/
~/.cargo/registry/index/
~/.cargo/registry/cache/
~/.cargo/git/db/
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.toml') }}-${{ env.CACHE_KEY_SUFFIX }}-rustdoc-test
- name: Run rustdoc test
run: |
cargo test --all-features --doc
- name: Test docs build with docs.rs
env:
RUSTDOCFLAGS: --cfg docsrs -D warnings
run: |
cargo doc --all-features --no-deps
- name: Upload docs.rs docs as artifacts
uses: actions/upload-artifact@v4
with:
name: mixtrics-docs-${{ github.sha }}-${{ runner.os }}
path: target/doc
if-no-files-found: error
retention-days: 7