-
Notifications
You must be signed in to change notification settings - Fork 13
237 lines (220 loc) · 8.74 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
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
name: CI
on:
push:
paths-ignore:
- '**.md'
- 'LICENSE'
pull_request:
paths-ignore:
- '**.md'
- 'LICENSE'
workflow_dispatch:
env:
CARGO_TERM_COLOR: always
# When updating this, also update:
# - src/lib.rs
# - Cargo.toml
# - README.md
rust_minver: 1.60.0
defaults:
run:
shell: bash
jobs:
format:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- name: Install Rust nightly
run: |
rustup toolchain install nightly
rustup component add rustfmt --toolchain nightly
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Check formatting
run: cargo +nightly fmt --all --verbose -- --check
test:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
fn_features: ['', 'log native libsystemd multi-thread runtime-pattern serde_json']
cfg_feature: ['', 'flexible-string', 'source-location']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set a non-UTC timezone # for detecting issues related to the local timezone
uses: szenius/[email protected]
with:
timezoneLinux: "Asia/Shanghai"
timezoneMacos: "Asia/Shanghai"
timezoneWindows: "China Standard Time"
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo bash ./.github/workflows/install-deps.sh
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run tests
run: cargo test --features "${{ matrix.fn_features }} ${{ matrix.cfg_feature }}" --verbose
clippy:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust nightly (latest and stable date version)
id: install-rust
run: |
STABLE_DATE=$(cargo clippy --version | perl -ne 'print $& if /\b\d{4}-\d{2}-\d{2}\b/')
echo "stable_date=$STABLE_DATE" >> $GITHUB_OUTPUT
rustup toolchain install nightly
rustup component add clippy --toolchain nightly
rustup toolchain install nightly-$STABLE_DATE
rustup component add clippy --toolchain nightly-$STABLE_DATE
echo "Stable version: $(cargo clippy --version)"
echo "Nightly version: $(cargo +nightly clippy --version)"
echo "Near stable nightly version: $(cargo +nightly-$STABLE_DATE clippy --version)"
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run clippy
run: cargo clippy --all-features --tests --examples -- -D warnings
- name: Run clippy nightly-${{ steps.install-rust.outputs.stable_date }} for benches
run: cargo +nightly-${{ steps.install-rust.outputs.stable_date }} clippy --all-features --benches -- -D warnings -A clippy::incompatible_msrv
- name: Run clippy nightly-latest without denying warnings
run: |
cargo +nightly clippy --all-features --tests --examples
echo "## clippy nightly output" >> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
# Run it again so there is no noise like "Compiling xxx" and "Checking xxx" in the output.
CARGO_TERM_COLOR=never cargo +nightly clippy --all-features --tests --examples 2>> $GITHUB_STEP_SUMMARY
echo "\`\`\`" >> $GITHUB_STEP_SUMMARY
check:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
target: ['', 'x86_64-apple-ios']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- name: Install dependencies
if: matrix.os == 'ubuntu-latest'
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust target
if: matrix.target != ''
run: rustup target add ${{ matrix.target }}
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run check
run: |
if [[ -z "${{ matrix.target }}" ]]; then
cargo check --all-features
else
cargo check --all-features --target ${{ matrix.target }}
fi
check-doc:
strategy:
fail-fast: false
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- name: Install dependencies
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust nightly (stable date version)
id: install-rust
run: |
STABLE_DATE=$(rustdoc --version | perl -ne 'print $& if /\b\d{4}-\d{2}-\d{2}\b/')
echo "stable_date=$STABLE_DATE" >> $GITHUB_OUTPUT
rustup toolchain install nightly-$STABLE_DATE
echo "Stable version: $(rustdoc --version)"
echo "Near stable nightly version: $(rustdoc +nightly-$STABLE_DATE --version)"
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run rustdoc nightly-${{ steps.install-rust.outputs.stable_date }}
run: |
cd spdlog
cargo +nightly-${{ steps.install-rust.outputs.stable_date }} rustdoc --verbose -- -D warnings -A rustdoc::broken-intra-doc-links
cargo +nightly-${{ steps.install-rust.outputs.stable_date }} rustdoc --all-features --verbose -- -D warnings
cd ../spdlog-macros
cargo +nightly-${{ steps.install-rust.outputs.stable_date }} rustdoc --verbose -- -D warnings -A rustdoc::broken-intra-doc-links
cargo +nightly-${{ steps.install-rust.outputs.stable_date }} rustdoc --all-features --verbose -- -D warnings
check-msrv:
strategy:
fail-fast: false
matrix:
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
runs-on: ${{ matrix.os }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- name: Install dependencies (Linux)
if: matrix.os == 'ubuntu-latest'
run: sudo bash ./.github/workflows/install-deps.sh
- name: Install Rust nightly
run: rustup toolchain install nightly
- name: Install Rust ${{ env.rust_minver }}
run: rustup toolchain install ${{ env.rust_minver }}
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Avoid dev-dependencies
run: |
# Some dev-dependencies require a newer version of Rust, but it doesn't matter for MSRV check
# This is a workaround for the cargo nightly option `-Z avoid-dev-deps`
perl -pi -e 's/\[dev-dependencies]/[workaround-avoid-dev-deps]/g' ./spdlog/Cargo.toml
- name: Downgrade dependencies to minimal versions
run: cargo +nightly update -Z minimal-versions
- name: Check MSRV for core with Rust ${{ env.rust_minver }}
run: cargo +${{ env.rust_minver }} check --locked --all-features --verbose
bench:
needs: [test, check]
strategy:
fail-fast: false
runs-on: 'ubuntu-latest'
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Disable bench dependencies
run: ./.github/workflows/disable-bench-deps.sh
- name: Install Rust nightly
run: rustup toolchain install nightly
- name: Restore cargo caches
uses: Swatinem/rust-cache@v2
- name: Run benchmark
run: cargo +nightly bench --features "multi-thread,runtime-pattern,serde_json" --bench spdlog_rs --bench spdlog_rs_pattern | tee bench-results.txt
- name: Discard irrelevant changes
run: git checkout -- spdlog/Cargo.toml
- name: Process results
uses: benchmark-action/github-action-benchmark@v1
with:
name: spdlog-rs on Linux
tool: cargo
output-file-path: bench-results.txt
benchmark-data-dir-path: docs/dev/benchmarks
github-token: ${{ secrets.GITHUB_TOKEN }}
summary-always: true
comment-on-alert: true
alert-comment-cc-users: '@SpriteOvO'
- name: Push results to GitHub Pages branch
if: github.event_name != 'pull_request' && (github.ref_name == 'main' || github.ref_name == 'main-dev')
run: git push 'https://${{ github.repository_owner }}:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}.git' gh-pages:gh-pages