-
Notifications
You must be signed in to change notification settings - Fork 1
69 lines (58 loc) · 1.95 KB
/
Copy pathci.yml
File metadata and controls
69 lines (58 loc) · 1.95 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
name: CI
on:
push:
branches: ["**"]
pull_request:
branches: ["**"]
env:
CARGO_TERM_COLOR: always
jobs:
build:
name: Build, Clippy, and Test
runs-on: macos-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
# The channel is read from rust-toolchain.toml so the pinned version lives
# in exactly one place. Floating `stable` here is what let a clippy
# release break unrelated PRs.
- name: Read pinned Rust toolchain
id: rust
run: |
set -euo pipefail
channel=$(sed -n 's/^[[:space:]]*channel[[:space:]]*=[[:space:]]*"\(.*\)"/\1/p' rust-toolchain.toml)
if [ -z "$channel" ]; then
echo "::error::rust-toolchain.toml does not declare a toolchain channel"
exit 1
fi
echo "Pinned Rust channel: ${channel}"
echo "channel=${channel}" >> "$GITHUB_OUTPUT"
- name: Install Rust (pinned)
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ steps.rust.outputs.channel }}
components: clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-registry-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-registry-
- name: Cache build target
uses: actions/cache@v4
with:
# Keyed on the pinned toolchain as well as the lockfile: artifacts built
# by a different rustc must not be reused.
path: target
key: ${{ runner.os }}-cargo-target-${{ hashFiles('**/Cargo.lock', 'rust-toolchain.toml') }}
restore-keys: |
${{ runner.os }}-cargo-target-
- name: Build
run: cargo build --verbose
- name: Clippy
run: cargo clippy -- -D warnings
- name: Test
run: cargo test --verbose