-
Notifications
You must be signed in to change notification settings - Fork 5
68 lines (62 loc) · 1.92 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
name: ci
on:
pull_request:
push:
branches:
- master
jobs:
build-and-test:
name: build-and-test
runs-on: ${{ matrix.image }}
env:
# Emit backtraces on panics.
RUST_BACKTRACE: 1
strategy:
matrix:
build: [linux-x64, macos-x64, win-x64-msvc]
include:
- build: linux-x64
os: ubuntu
image: ubuntu-20.04
target: x86_64-unknown-linux-gnu
- build: macos-x64
os: macos
image: macos-12
target: x86_64-apple-darwin
- build: win-x64-msvc
os: windows
image: windows-2022
target: x86_64-pc-windows-msvc
steps:
- name: Checkout repository
uses: actions/checkout@v4
# See: https://github.com/actions/cache/blob/main/examples.md#rust---cargo
# And also https://github.com/rust-lang/rustup/blob/25dc87dc605adc0843c9369063333997ae806008/.github/workflows/linux-builds-on-stable.yaml#L81
- name: Cache cargo registry and git trees
id: do-cache-cargo
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- name: Get rustc commit hash
id: cargo-target-cache
run: |
echo "rust_hash=$(rustc -Vv | grep commit-hash | awk '{print $2}')" >> $GITHUB_OUTPUT
shell: bash
- name: Cache cargo build
id: do-cache-target
uses: actions/cache@v4
with:
path: target
key: ${{ matrix.target }}-cargo-target-dir-${{ steps.cargo-target-cache.outputs.rust_hash }}-${{ hashFiles('**/Cargo.lock') }}
- name: cargo build
run: cargo build
- name: cargo test
run: cargo build
- name: Clear the cargo caches
if: ${{ ! steps.do-cache-cargo.outputs.cache-hit }}
run: |
cargo install cargo-cache --no-default-features --features ci-autoclean
cargo-cache