-
Notifications
You must be signed in to change notification settings - Fork 0
107 lines (87 loc) · 2.78 KB
/
Copy pathci.yml
File metadata and controls
107 lines (87 loc) · 2.78 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
permissions:
contents: read
# A new push to a pull request makes the previous run pointless.
concurrency:
group: ci-${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
CARGO_TERM_COLOR: always
jobs:
# The crate has a build script that reads `presets/`, but it only needs the
# checked-out tree, so a stock toolchain is enough on every platform.
test:
name: test (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- uses: Swatinem/rust-cache@v2
- name: Build
run: cargo build --locked
- name: Test
run: cargo test --locked
- name: Clippy
run: cargo clippy --locked --lib --bins --tests -- -D warnings
fmt:
name: rustfmt
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: cargo fmt --check
# `cargo deny` reads the lockfile and the advisory database; it never builds
# the crate, so this finishes long before the test matrix does.
deny:
name: cargo-deny
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: EmbarkStudios/cargo-deny-action@v2
with:
command: check
# `rust-version` in Cargo.toml is a promise. This is the only thing that keeps
# it true, since a stable toolchain will happily accept newer syntax.
msrv:
name: msrv
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- id: msrv
shell: bash
run: |
set -euo pipefail
version=$(awk -F' *= *' '
/^\[/ { section = $0 }
section == "[package]" && $1 == "rust-version" { gsub(/"/, "", $2); print $2; exit }
' Cargo.toml)
if [ -z "$version" ]; then
echo "::error::Cargo.toml has no [package] rust-version"
exit 1
fi
echo "version=$version" >> "$GITHUB_OUTPUT"
echo "MSRV is $version"
- uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.msrv.outputs.version }}
- uses: Swatinem/rust-cache@v2
with:
key: msrv-${{ steps.msrv.outputs.version }}
# `check`, not `build`: this asks whether the declared MSRV can still
# compile the tree, and does not need to produce a binary to answer.
- name: Check against the declared MSRV
run: cargo check --locked --all-targets