Skip to content

Commit d70acff

Browse files
ci: add sccache, rust-cache, and modernize GitHub Actions
1 parent 6f9eabe commit d70acff

File tree

1 file changed

+65
-50
lines changed

1 file changed

+65
-50
lines changed

.github/workflows/rust.yml

Lines changed: 65 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -6,93 +6,108 @@ jobs:
66
check:
77
name: Check
88
runs-on: ubuntu-latest
9+
env:
10+
CARGO_TERM_COLOR: always
11+
SCCACHE_GHA_ENABLED: "true"
12+
RUSTC_WRAPPER: "sccache"
913
steps:
10-
- uses: actions/checkout@v2
11-
- uses: actions-rs/toolchain@v1
14+
- uses: actions/checkout@v4
15+
- uses: dtolnay/rust-toolchain@stable
16+
- uses: Swatinem/rust-cache@v2
1217
with:
13-
profile: minimal
14-
toolchain: stable
15-
override: true
16-
- uses: actions-rs/cargo@v1
17-
with:
18-
command: check
19-
args: --features webgpu
18+
shared-key: native
19+
cache-targets: false
20+
save-if: ${{ github.ref == 'refs/heads/main' }}
21+
- uses: mozilla-actions/sccache-action@v0.0.9
22+
- run: cargo check --features webgpu
2023

2124
check_wasm:
2225
name: Check wasm32
2326
runs-on: ubuntu-latest
27+
env:
28+
CARGO_TERM_COLOR: always
29+
SCCACHE_GHA_ENABLED: "true"
30+
RUSTC_WRAPPER: "sccache"
2431
steps:
25-
- uses: actions/checkout@v2
26-
- uses: actions-rs/toolchain@v1
32+
- uses: actions/checkout@v4
33+
- uses: dtolnay/rust-toolchain@stable
2734
with:
28-
profile: minimal
29-
toolchain: stable
30-
target: wasm32-unknown-unknown
31-
override: true
32-
- uses: actions-rs/cargo@v1
35+
targets: wasm32-unknown-unknown
36+
- uses: Swatinem/rust-cache@v2
3337
with:
34-
command: check
35-
args: --features webgpu --lib --target wasm32-unknown-unknown
38+
shared-key: wasm
39+
cache-targets: false
40+
save-if: ${{ github.ref == 'refs/heads/main' }}
41+
- uses: mozilla-actions/sccache-action@v0.0.9
42+
- run: cargo check --features webgpu --lib --target wasm32-unknown-unknown
3643

3744
test:
3845
name: Test Suite
3946
runs-on: ubuntu-latest
47+
env:
48+
CARGO_TERM_COLOR: always
49+
SCCACHE_GHA_ENABLED: "true"
50+
RUSTC_WRAPPER: "sccache"
4051
steps:
41-
- uses: actions/checkout@v2
42-
- uses: actions-rs/toolchain@v1
52+
- uses: actions/checkout@v4
53+
- uses: dtolnay/rust-toolchain@stable
54+
- uses: Swatinem/rust-cache@v2
4355
with:
44-
profile: minimal
45-
toolchain: stable
46-
override: true
56+
shared-key: native
57+
cache-targets: false
58+
save-if: ${{ github.ref == 'refs/heads/main' }}
59+
- uses: mozilla-actions/sccache-action@v0.0.9
4760
- run: sudo apt-get install libxcb-render0-dev libxcb-shape0-dev libxcb-xfixes0-dev libxkbcommon-dev libssl-dev
48-
- uses: actions-rs/cargo@v1
49-
with:
50-
command: test
51-
args: --lib
61+
- run: cargo test --lib
5262

5363
fmt:
5464
name: Rustfmt
5565
runs-on: ubuntu-latest
5666
steps:
57-
- uses: actions/checkout@v2
58-
- uses: actions-rs/toolchain@v1
67+
- uses: actions/checkout@v4
68+
- uses: dtolnay/rust-toolchain@stable
5969
with:
60-
profile: minimal
61-
toolchain: stable
62-
override: true
6370
components: rustfmt
64-
- uses: actions-rs/cargo@v1
65-
with:
66-
command: fmt
67-
args: --all -- --check
71+
- run: cargo fmt --all -- --check
6872

6973
clippy:
7074
name: Clippy
7175
runs-on: ubuntu-latest
76+
env:
77+
CARGO_TERM_COLOR: always
78+
SCCACHE_GHA_ENABLED: "true"
79+
RUSTC_WRAPPER: "sccache"
7280
steps:
73-
- uses: actions/checkout@v2
74-
- uses: actions-rs/toolchain@v1
81+
- uses: actions/checkout@v4
82+
- uses: dtolnay/rust-toolchain@stable
7583
with:
76-
profile: minimal
77-
toolchain: stable
78-
override: true
7984
components: clippy
80-
- uses: actions-rs/cargo@v1
85+
- uses: Swatinem/rust-cache@v2
8186
with:
82-
command: clippy
83-
args: -- -D warnings
87+
shared-key: native
88+
cache-targets: false
89+
save-if: ${{ github.ref == 'refs/heads/main' }}
90+
- uses: mozilla-actions/sccache-action@v0.0.9
91+
- run: cargo clippy -- -D warnings
8492

8593
trunk:
8694
name: trunk
8795
runs-on: ubuntu-latest
96+
env:
97+
CARGO_TERM_COLOR: always
98+
SCCACHE_GHA_ENABLED: "true"
99+
RUSTC_WRAPPER: "sccache"
88100
steps:
89-
- uses: actions/checkout@v2
90-
- uses: actions-rs/toolchain@v1
101+
- uses: actions/checkout@v4
102+
- uses: dtolnay/rust-toolchain@stable
103+
with:
104+
targets: wasm32-unknown-unknown
105+
- uses: Swatinem/rust-cache@v2
91106
with:
92-
profile: minimal
93-
toolchain: stable
94-
target: wasm32-unknown-unknown
95-
override: true
107+
shared-key: wasm
108+
cache-targets: false
109+
save-if: ${{ github.ref == 'refs/heads/main' }}
110+
- uses: mozilla-actions/sccache-action@v0.0.9
96111
- name: Download and install Trunk binary
97112
run: wget -qO- https://github.com/trunk-rs/trunk/releases/download/v0.18.8/trunk-x86_64-unknown-linux-gnu.tar.gz | tar -xzf-
98113
- name: Build

0 commit comments

Comments
 (0)