Skip to content

Commit 0bcbc3c

Browse files
fix: caching
1 parent 66c58fb commit 0bcbc3c

4 files changed

Lines changed: 61 additions & 22 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Restore Environment Cache
2+
description: Restore the cache for the Rust environment built
3+
inputs:
4+
cache-key:
5+
description: The key to restore the cache from
6+
required: true
7+
8+
runs:
9+
using: "composite"
10+
steps:
11+
- name: Restore Build Files Cache
12+
uses: actions/cache@v3
13+
with:
14+
path: |
15+
~/.cargo/bin/
16+
~/.cargo/registry/index/
17+
~/.cargo/registry/cache/
18+
~/.cargo/git/db/
19+
target/
20+
restore-keys: ${{ inputs.cache-key }}

.github/actions/setup-rust-environment.yml

Whitespace-only changes.

.github/actions/setup-rust-environment/action.yml

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,10 @@
33
name: Setup Rust Environment
44
description: Install deps, ARM toolchain, and Rust toolchain
55
inputs:
6-
cargo-dependencies:
7-
description: List of cargo dependencies to install (space separated)
6+
cache-key:
7+
description: The key to use for caching the Rust environment
8+
required: true
9+
810
runs:
911
using: composite
1012
steps:
@@ -25,13 +27,13 @@ runs:
2527
with:
2628
toolchain: stable
2729
target: thumbv7em-none-eabihf
30+
components: rustfmt
2831

2932
- name: Install Cargo Dependencies
30-
if: ${{ inputs.cargo-dependencies != '' }}
3133
uses: actions-rs/cargo@v1
3234
with:
3335
command: install
34-
args: --force ${{ inputs.cargo-dependencies }}
36+
args: --force cargo-make
3537

3638
- name: Cache Build Files
3739
uses: actions/cache@v3
@@ -42,4 +44,4 @@ runs:
4244
~/.cargo/registry/cache/
4345
~/.cargo/git/db/
4446
target/
45-
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
47+
key: ${{ inputs.cache-key }}

.github/workflows/build.yml

Lines changed: 34 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -7,31 +7,44 @@ on:
77
name: Build Verification
88

99
jobs:
10-
formatting:
11-
name: Check for Formatting Issues
10+
build_environment:
11+
name: Build Environment Setup
1212
runs-on: ubuntu-latest
1313
steps:
1414
- uses: actions/checkout@v2
1515
- name: Setup Rust Environment
1616
uses: ./.github/actions/setup-rust-environment/
1717
with:
1818
embedded: true
19-
cargo-dependencies: "cargo-make cargo-fmt"
19+
cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
20+
formatting:
21+
name: Check for Formatting Issues
22+
needs: build_environment
23+
runs-on: ubuntu-latest
24+
steps:
25+
- name: Checkout
26+
uses: actions/checkout@v2
27+
28+
- name: Restore Rust Environment Cache
29+
uses: ./.github/actions/restore-environment-cache/
30+
with:
31+
cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
32+
2033
- name: Check Formatting
2134
run: cargo fmt -- --check
2235

2336
build_pressure:
2437
name: Build with Pressure Feature
38+
needs: build_environment
2539
runs-on: ubuntu-latest
2640
steps:
2741
- name: Checkout
2842
uses: actions/checkout@v2
2943

30-
- name: Setup Rust Environment
31-
uses: ./.github/actions/setup-rust-environment/
44+
- name: Restore Rust Environment Cache
45+
uses: ./.github/actions/restore-environment-cache/
3246
with:
33-
embedded: true
34-
cargo-dependencies: "cargo-make"
47+
cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
3548

3649
- name: "Build with Pressure Feature"
3750
uses: actions-rs/cargo@v1
@@ -41,16 +54,16 @@ jobs:
4154

4255
build_temperature:
4356
name: Build with Temperature Feature
57+
needs: build_environment
4458
runs-on: ubuntu-latest
4559
steps:
4660
- name: Checkout
4761
uses: actions/checkout@v2
4862

49-
- name: Setup Rust Environment
50-
uses: ./.github/actions/setup-rust-environment/
63+
- name: Restore Rust Environment Cache
64+
uses: ./.github/actions/restore-environment-cache/
5165
with:
52-
embedded: true
53-
cargo-dependencies: "cargo-make"
66+
cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
5467

5568
- name: "Build with Temperature Feature"
5669
uses: actions-rs/cargo@v1
@@ -60,16 +73,16 @@ jobs:
6073

6174
build_strain:
6275
name: Build with Strain Feature
76+
needs: build_environment
6377
runs-on: ubuntu-latest
6478
steps:
6579
- name: Checkout
6680
uses: actions/checkout@v2
6781

68-
- name: Setup Rust Environment
69-
uses: ./.github/actions/setup-rust-environment/
82+
- name: Restore Rust Environment Cache
83+
uses: ./.github/actions/restore-environment-cache/
7084
with:
71-
embedded: true
72-
cargo-dependencies: "cargo-make"
85+
cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
7386

7487
- name: "Build with Strain Feature"
7588
uses: actions-rs/cargo@v1
@@ -78,15 +91,19 @@ jobs:
7891
args: --release --features strain
7992

8093
test:
94+
name: Run Host Tests
95+
needs: build_environment
8196
runs-on: ubuntu-latest
8297
env:
8398
RUST_MIN_STACK: 8388608
8499
steps:
85100
- name: Checkout
86101
uses: actions/checkout@v2
87102

88-
- name: Setup Rust Environment
89-
uses: ./.github/actions/setup-rust-environment/
103+
- name: Restore Rust Environment Cache
104+
uses: ./.github/actions/restore-environment-cache/
105+
with:
106+
cache-key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
90107

91108
- uses: actions-rs/cargo@v1
92109
name: "Run Host Tests"

0 commit comments

Comments
 (0)