-
Notifications
You must be signed in to change notification settings - Fork 72
137 lines (126 loc) · 5.44 KB
/
ci.yaml
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
name: Rust CI
on:
# Always test pull requests
pull_request:
# Bors related branches
push:
branches:
- master
- staging
- trying
# Test once per week: Saturday at 00:00
schedule:
- cron: "0 0 * * 6"
permissions: read-all
jobs:
clippy_check:
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "windows-latest"]
rust: ["stable", "nightly"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: "Install/Update the Rust version"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
components: clippy
- name: clippy "No Default Features" (${{ matrix.os }} / ${{ matrix.rust }})
run: cargo clippy --workspace --no-default-features --all-targets
- name: clippy "Default" (${{ matrix.os }} / ${{ matrix.rust }})
run: cargo clippy --workspace --all-targets
- name: clippy "All Features" (${{ matrix.os }} / ${{ matrix.rust }})
run: cargo clippy --workspace --all-features --all-targets
rustfmt:
name: Rustfmt
runs-on: ubuntu-latest
strategy:
matrix:
rust:
- stable
steps:
- uses: actions/checkout@v4
- name: "Install/Update the Rust version"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
components: rustfmt
- name: Rustfmt Check (${{ matrix.rust }})
uses: actions-rust-lang/rustfmt@v1
build_and_test:
name: Build and Test
strategy:
matrix:
os: ["ubuntu-latest", "windows-latest"]
# It is good to test more than the MSRV and stable since sometimes
# breakage occurs in intermediate versions.
# IMPORTANT: Synchronize the MSRV with the Cargo.toml values.
rust: ["1.65", "1.70", "1.75", "stable", "beta", "nightly"]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- name: "Install/Update the Rust version"
uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: ${{ matrix.rust }}
# Extra toolchain to test no_std
target: thumbv7em-none-eabihf
# # Test that the project also compiles with the newest dependencies.
# # On nightly there is little cache reuse, so there is not much overhead
# # in constantly updating the versions.
# - name: Bump dependencies on nightly
# if: matrix.rust == 'nightly'
# run: cargo update
# Build the project
- name: "Build (${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo build --all-features --all-targets
# Check no_std works
- name: "Check no_std (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo check --package serde_with --no-default-features --target thumbv7em-none-eabihf
- name: "Check no_std+alloc (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo check --package serde_with --no-default-features --features=alloc --target thumbv7em-none-eabihf
- name: "Check no_std+alloc+optional (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo check --package serde_with --no-default-features --features=alloc,base64,chrono_0_4,hashbrown_0_14,hex,indexmap_1,indexmap_2,json,time_0_3 --target thumbv7em-none-eabihf
# The tests are split into build and run steps, to see the time impact of each
# cargo test --all-targets does NOT run doctests
# since doctests are important this should not be added
# https://github.com/rust-lang/cargo/issues/6669
- name: "Test Build (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-default-features --no-run
- name: "Test Run (No Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-default-features --no-fail-fast
- name: "Test Build (Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-run
- name: "Test Run (Default Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --no-fail-fast
- name: "Test Build (All Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --all-features --no-run
- name: "Test Run (All Features / ${{ matrix.os }} / ${{ matrix.rust }})"
run: cargo test --all-features --no-default-features --no-fail-fast
- name: Run cargo-tarpaulin
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
run: |
cargo install cargo-tarpaulin
cargo tarpaulin --out xml --workspace --all-features -- --test-threads=1
- name: Upload to codecov.io
uses: codecov/codecov-action@v4
if: matrix.rust == 'stable' && matrix.os == 'ubuntu-latest'
# Added to summarize the matrix (otherwise we would need to list every single
# job in bors.toml)
# https://forum.bors.tech/t/bors-with-github-workflows/426
tests-result:
name: Tests result
if: always()
needs:
- rustfmt
- clippy_check
- build_and_test
runs-on: ubuntu-latest
steps:
- name: Mark the job as a success
if: "needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success'"
run: exit 0
- name: Mark the job as a failure
if: "!(needs.rustfmt.result == 'success' && needs.clippy_check.result == 'success' && needs.build_and_test.result == 'success')"
run: exit 1