Skip to content

Commit a8b8267

Browse files
authored
Merge pull request #51 from jjl9807/workflow
Add caching to improve workflow execution time
2 parents dddcaad + a003872 commit a8b8267

File tree

2 files changed

+54
-18
lines changed

2 files changed

+54
-18
lines changed

.github/install-sys-deps/action.yml

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,15 @@ name: 'Install System Tools and Dependencies'
33
runs:
44
using: "composite"
55
steps:
6+
- name: Setup Rust Toolchain
7+
uses: actions-rust-lang/setup-rust-toolchain@v1
8+
with:
9+
components: clippy rustfmt
10+
cache-workspaces: |
11+
./project
12+
cache-directories: |
13+
./project/target
14+
615
- name: Update APT Cache
716
run: sudo apt-get update
817
shell: bash
@@ -15,14 +24,11 @@ runs:
1524
run: sudo apt-get install seccomp libseccomp-dev
1625
shell: bash
1726

18-
- name: Install Buck2
19-
run: |
20-
curl https://github.com/facebook/buck2/releases/download/latest/buck2-x86_64-unknown-linux-gnu.zst --output "${{runner.temp}}/buck2-x86_64-unknown-linux-gnu.zst" --location --silent --show-error --fail --retry 5
21-
zstd -d "${{runner.temp}}/buck2-x86_64-unknown-linux-gnu.zst" -o $HOME/.cargo/bin/buck2
22-
chmod +x $HOME/.cargo/bin/buck2
23-
rm -f "${{runner.temp}}/buck2-x86_64-unknown-linux-gnu.zst"
24-
shell: bash
25-
26-
- name: Install Reindeer
27-
run: cargo install --locked --git https://github.com/facebookincubator/reindeer reindeer
28-
shell: bash
27+
- name: Restore cache
28+
id: cache-restore
29+
uses: actions/cache/restore@v4
30+
with:
31+
path: |
32+
/home/runner/.cargo/bin/buck2
33+
/home/runner/.cargo/bin/reindeer
34+
key: buck2-binary

.github/workflows/base.yml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,15 @@ jobs:
2525
CARGO_TERM_COLOR: always
2626

2727
steps:
28+
- name: Restore cache
29+
id: cache-restore
30+
uses: actions/cache/restore@v4
31+
with:
32+
path: |
33+
/home/runner/.cargo/bin/buck2
34+
/home/runner/.cargo/bin/reindeer
35+
key: buck2-binary
36+
2837
- name: Checkout repository
2938
uses: actions/checkout@v4
3039
with:
@@ -34,6 +43,33 @@ jobs:
3443
uses: actions-rust-lang/setup-rust-toolchain@v1
3544
with:
3645
components: clippy rustfmt
46+
cache-workspaces: |
47+
./project
48+
cache-directories: |
49+
./project/target
50+
51+
- name: Install Buck2
52+
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
53+
run: |
54+
curl https://github.com/facebook/buck2/releases/download/latest/buck2-x86_64-unknown-linux-gnu.zst --output "${{runner.temp}}/buck2-x86_64-unknown-linux-gnu.zst" --location --silent --show-error --fail --retry 5
55+
zstd -d "${{runner.temp}}/buck2-x86_64-unknown-linux-gnu.zst" -o $HOME/.cargo/bin/buck2
56+
chmod +x $HOME/.cargo/bin/buck2
57+
rm -f "${{runner.temp}}/buck2-x86_64-unknown-linux-gnu.zst"
58+
shell: bash
59+
60+
- name: Install Reindeer
61+
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
62+
run: cargo install --locked --git https://github.com/facebookincubator/reindeer reindeer
63+
shell: bash
64+
65+
- name: Save cache
66+
if: ${{ steps.cache-restore.outputs.cache-hit != 'true' }}
67+
uses: actions/cache/save@v4
68+
with:
69+
path: |
70+
/home/runner/.cargo/bin/buck2
71+
/home/runner/.cargo/bin/reindeer
72+
key: buck2-binary
3773

3874
format:
3975
name: Rustfmt Check
@@ -99,17 +135,11 @@ jobs:
99135
reindeer --third-party-dir third-party buckify
100136
buck2 build //project/...
101137
102-
- name: Cache buck-out
103-
uses: actions/cache/save@v4
104-
with:
105-
path: ./buck-out
106-
key: buck2-cache-${{ github.run_id }}-${{ github.run_attempt }}
107-
108138
test:
109139
name: Buck2 Test
110140

111141
runs-on: ubuntu-latest
112-
needs: build
142+
needs: setup
113143

114144
steps:
115145
- name: Checkout repository

0 commit comments

Comments
 (0)