Skip to content

Commit 9d37a86

Browse files
authored
Merge pull request #18 from hyperlight-dev/ci-caching
ci: add Cargo and kraft-hyperlight caching
2 parents 713389b + 5fce4c3 commit 9d37a86

4 files changed

Lines changed: 94 additions & 34 deletions

File tree

.github/workflows/benchmarks.yml

Lines changed: 23 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,23 @@ jobs:
4040
steps:
4141
- uses: actions/checkout@v4
4242

43-
- name: Install Go (for kraft-hyperlight)
44-
run: |
45-
curl -sL https://go.dev/dl/go1.25.1.linux-amd64.tar.gz | sudo tar -C /usr/local -xz
46-
echo "/usr/local/go/bin" >> $GITHUB_PATH
43+
- uses: actions/setup-go@v5
44+
with:
45+
go-version: '1.25.1'
46+
cache: false
4747

4848
- name: Install just
4949
uses: extractions/setup-just@v2
5050

51+
- name: Cache kraft-hyperlight
52+
id: kraft-cache
53+
uses: actions/cache@v4
54+
with:
55+
path: /usr/local/bin/kraft-hyperlight
56+
key: kraft-hyperlight-linux-${{ hashFiles('.github/workflows/benchmarks.yml') }}
57+
5158
- name: Build kraft-hyperlight
59+
if: steps.kraft-cache.outputs.cache-hit != 'true'
5260
run: |
5361
git clone --branch hyperlight-platform --depth 1 \
5462
https://github.com/danbugs/kraftkit.git /tmp/kraftkit
@@ -116,6 +124,10 @@ jobs:
116124
steps:
117125
- uses: actions/checkout@v4
118126

127+
- uses: Swatinem/rust-cache@v2
128+
with:
129+
workspaces: host -> target
130+
119131
- name: Enable KVM permissions
120132
run: |
121133
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
@@ -313,14 +325,16 @@ jobs:
313325
steps:
314326
- uses: actions/checkout@v4
315327

328+
- uses: Swatinem/rust-cache@v2
329+
with:
330+
workspaces: host -> target
331+
316332
- name: Install pyhl
317333
shell: pwsh
318334
run: |
319-
cargo install --git https://github.com/${{ github.repository }} `
320-
--branch ${{ github.head_ref || github.ref_name }} `
321-
hyperlight-unikraft-host `
322-
--bin pyhl `
323-
--locked --force
335+
cd host
336+
cargo build --release --bin pyhl
337+
Copy-Item target\release\pyhl.exe $env:USERPROFILE\.cargo\bin\ -Force
324338
325339
- name: Download prebuilt image
326340
uses: actions/download-artifact@v4

.github/workflows/host-checks.yml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ jobs:
3737
steps:
3838
- uses: actions/checkout@v4
3939

40+
- uses: Swatinem/rust-cache@v2
41+
with:
42+
workspaces: host -> target
43+
4044
- name: Install Rust components for pinned toolchain
4145
# The repo pins 1.89.0 via rust-toolchain.toml at the repo root.
4246
# cargo fmt / clippy use the pinned channel, so install their

.github/workflows/publish-examples.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,29 @@ jobs:
8888
steps:
8989
- uses: actions/checkout@v4
9090

91+
- uses: actions/setup-go@v5
92+
with:
93+
go-version: '1.25.1'
94+
cache: false
95+
96+
- uses: Swatinem/rust-cache@v2
97+
with:
98+
workspaces: host -> target
99+
100+
- name: Cache kraft-hyperlight
101+
id: kraft-cache
102+
uses: actions/cache@v4
103+
with:
104+
path: /usr/local/bin/kraft-hyperlight
105+
key: kraft-hyperlight-linux-${{ hashFiles('.github/workflows/publish-examples.yml') }}
106+
91107
- name: Install tools
92108
run: |
93-
# Install kraft-hyperlight
94-
git clone --branch hyperlight-platform --depth 1 https://github.com/danbugs/kraftkit.git /tmp/kraftkit
95-
cd /tmp/kraftkit && go build -o /usr/local/bin/kraft-hyperlight ./cmd/kraft
109+
# Install kraft-hyperlight (if not cached)
110+
if [ ! -f /usr/local/bin/kraft-hyperlight ]; then
111+
git clone --branch hyperlight-platform --depth 1 https://github.com/danbugs/kraftkit.git /tmp/kraftkit
112+
cd /tmp/kraftkit && go build -o /usr/local/bin/kraft-hyperlight ./cmd/kraft
113+
fi
96114
# Install hyperlight-unikraft
97115
cd ${{ github.workspace }}/host && cargo build --release
98116
sudo cp target/release/hyperlight-unikraft /usr/local/bin/

.github/workflows/test-examples.yml

Lines changed: 46 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -68,15 +68,23 @@ jobs:
6868
steps:
6969
- uses: actions/checkout@v4
7070

71-
- name: Install Go (for kraft-hyperlight)
72-
run: |
73-
curl -sL https://go.dev/dl/go1.25.1.linux-amd64.tar.gz | sudo tar -C /usr/local -xz
74-
echo "/usr/local/go/bin" >> $GITHUB_PATH
71+
- uses: actions/setup-go@v5
72+
with:
73+
go-version: '1.25.1'
74+
cache: false
7575

7676
- name: Install just
7777
uses: extractions/setup-just@v2
7878

79+
- name: Cache kraft-hyperlight
80+
id: kraft-cache
81+
uses: actions/cache@v4
82+
with:
83+
path: /usr/local/bin/kraft-hyperlight
84+
key: kraft-hyperlight-linux-${{ hashFiles('.github/workflows/test-examples.yml') }}
85+
7986
- name: Build kraft-hyperlight
87+
if: steps.kraft-cache.outputs.cache-hit != 'true'
8088
run: |
8189
git clone --branch hyperlight-platform --depth 1 \
8290
https://github.com/danbugs/kraftkit.git /tmp/kraftkit
@@ -224,6 +232,10 @@ jobs:
224232
steps:
225233
- uses: actions/checkout@v4
226234

235+
- uses: Swatinem/rust-cache@v2
236+
with:
237+
workspaces: host -> target
238+
227239
- name: Enable KVM permissions (no-op if device absent)
228240
run: |
229241
echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' \
@@ -387,15 +399,23 @@ jobs:
387399
steps:
388400
- uses: actions/checkout@v4
389401

390-
- name: Install Go (for kraft-hyperlight)
391-
run: |
392-
curl -sL https://go.dev/dl/go1.25.1.linux-amd64.tar.gz | sudo tar -C /usr/local -xz
393-
echo "/usr/local/go/bin" >> $GITHUB_PATH
402+
- uses: actions/setup-go@v5
403+
with:
404+
go-version: '1.25.1'
405+
cache: false
394406

395407
- name: Install just
396408
uses: extractions/setup-just@v2
397409

410+
- name: Cache kraft-hyperlight
411+
id: kraft-cache
412+
uses: actions/cache@v4
413+
with:
414+
path: /usr/local/bin/kraft-hyperlight
415+
key: kraft-hyperlight-linux-${{ hashFiles('.github/workflows/test-examples.yml') }}
416+
398417
- name: Build kraft-hyperlight
418+
if: steps.kraft-cache.outputs.cache-hit != 'true'
399419
run: |
400420
git clone --branch hyperlight-platform --depth 1 \
401421
https://github.com/danbugs/kraftkit.git /tmp/kraftkit
@@ -532,17 +552,19 @@ jobs:
532552
steps:
533553
- uses: actions/checkout@v4
534554

535-
- name: Install hyperlight-unikraft host binaries
555+
- uses: Swatinem/rust-cache@v2
556+
with:
557+
workspaces: host -> target
558+
559+
- name: Build host binaries
536560
shell: pwsh
537561
run: |
538-
cargo install --git https://github.com/${{ github.repository }} `
539-
--branch ${{ github.head_ref || github.ref_name }} `
540-
hyperlight-unikraft-host `
541-
--bin hyperlight-unikraft `
542-
--bin multifn-test `
543-
--bin pydriver-run `
544-
--bin pyhl `
545-
--locked --force
562+
cd host
563+
cargo build --release --bin hyperlight-unikraft --bin multifn-test --bin pydriver-run --bin pyhl
564+
Copy-Item target\release\hyperlight-unikraft.exe $env:USERPROFILE\.cargo\bin\ -Force
565+
Copy-Item target\release\multifn-test.exe $env:USERPROFILE\.cargo\bin\ -Force
566+
Copy-Item target\release\pydriver-run.exe $env:USERPROFILE\.cargo\bin\ -Force
567+
Copy-Item target\release\pyhl.exe $env:USERPROFILE\.cargo\bin\ -Force
546568
547569
- name: Download prebuilt image
548570
uses: actions/download-artifact@v4
@@ -636,6 +658,10 @@ jobs:
636658
steps:
637659
- uses: actions/checkout@v4
638660

661+
- uses: Swatinem/rust-cache@v2
662+
with:
663+
workspaces: host -> target
664+
639665
# Linux needs /dev/kvm access to run the guest.
640666
- name: Enable KVM permissions (Linux only)
641667
if: runner.os == 'Linux'
@@ -660,11 +686,9 @@ jobs:
660686
- name: Install pyhl
661687
shell: pwsh
662688
run: |
663-
cargo install --git https://github.com/${{ github.repository }} `
664-
--branch ${{ github.head_ref || github.ref_name }} `
665-
hyperlight-unikraft-host `
666-
--bin pyhl `
667-
--locked --force
689+
cd host
690+
cargo build --release --bin pyhl
691+
Copy-Item target/release/pyhl* $env:USERPROFILE/.cargo/bin/ -Force
668692
669693
- name: Download prebuilt python-agent-driver image
670694
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)