Skip to content

Commit 8b74e7a

Browse files
authored
Fix broken rust cache (#1477)
Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent c87eed5 commit 8b74e7a

6 files changed

Lines changed: 118 additions & 3 deletions

File tree

.github/workflows/PrimeCaches.yml

Lines changed: 103 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,103 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
# Builds on main to populate the GitHub Actions cache for all Swatinem/rust-cache
4+
# shared-keys used by PR workflows. Caches saved on `refs/heads/main` are
5+
# restorable from every PR via the base-branch fallback. PR workflows are
6+
# configured with `save-if: github.ref == 'refs/heads/main'`, so they only ever
7+
# read from this cache.
8+
#
9+
# No tests are run here. The goal is just to populate dependency build artifacts
10+
# so that PR jobs start warm.
11+
12+
name: Prime Caches
13+
14+
on:
15+
push:
16+
branches: [main]
17+
workflow_dispatch:
18+
19+
env:
20+
CARGO_TERM_COLOR: always
21+
RUST_BACKTRACE: full
22+
23+
permissions:
24+
contents: read
25+
26+
defaults:
27+
run:
28+
shell: bash
29+
30+
jobs:
31+
# Populate v0-rust-guests-{debug,release}-Linux-x64 caches.
32+
guests:
33+
strategy:
34+
fail-fast: false
35+
matrix:
36+
config: [debug, release]
37+
uses: ./.github/workflows/dep_build_guests.yml
38+
secrets: inherit
39+
with:
40+
config: ${{ matrix.config }}
41+
42+
# Populate v0-rust-code-checks-{linux,windows} caches.
43+
code-checks:
44+
uses: ./.github/workflows/dep_code_checks.yml
45+
secrets: inherit
46+
47+
# Populate v0-rust-{Linux,Windows}-{hypervisor}-{debug,release} caches used
48+
# by dep_build_test.yml. Linux is primed once per hypervisor because the kvm
49+
# pools run Ubuntu and the mshv3 pools run Azure Linux 3, and we want each
50+
# distro to restore a cache produced under its own libc. Only the host
51+
# dependency graph is built here, no tests are run.
52+
host:
53+
strategy:
54+
fail-fast: false
55+
matrix:
56+
include:
57+
- hypervisor: kvm
58+
config: debug
59+
- hypervisor: kvm
60+
config: release
61+
- hypervisor: mshv3
62+
config: debug
63+
- hypervisor: mshv3
64+
config: release
65+
- hypervisor: hyperv-ws2025
66+
config: debug
67+
- hypervisor: hyperv-ws2025
68+
config: release
69+
timeout-minutes: 30
70+
runs-on: ${{ fromJson(
71+
format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-amd", "JobId=prime-cache-{2}-{3}-{4}-{5}-{6}"]',
72+
matrix.hypervisor == 'hyperv-ws2025' && 'Windows' || 'Linux',
73+
matrix.hypervisor == 'hyperv-ws2025' && 'win2025' || matrix.hypervisor == 'mshv3' && 'azlinux3-mshv' || matrix.hypervisor,
74+
matrix.hypervisor,
75+
matrix.config,
76+
github.run_id,
77+
github.run_number,
78+
github.run_attempt)) }}
79+
steps:
80+
- uses: actions/checkout@v6
81+
82+
- uses: hyperlight-dev/ci-setup-workflow@v1.9.0
83+
with:
84+
rust-toolchain: "1.89"
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
88+
- name: Fix cargo home permissions
89+
if: runner.os == 'Linux'
90+
run: |
91+
sudo chown -R $(id -u):$(id -g) /opt/cargo || true
92+
93+
- name: Rust cache
94+
uses: Swatinem/rust-cache@v2
95+
with:
96+
shared-key: "${{ runner.os }}-${{ matrix.hypervisor }}-${{ matrix.config }}"
97+
cache-on-failure: "true"
98+
# Only save on main as caches are not shared across branches.
99+
# https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache
100+
save-if: ${{ github.ref == 'refs/heads/main' }}
101+
102+
- name: Build host
103+
run: just build ${{ matrix.config }}

.github/workflows/dep_benchmarks.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,7 @@ jobs:
9797
- name: Rust cache
9898
uses: Swatinem/rust-cache@v2
9999
with:
100-
shared-key: "${{ runner.os }}-release"
100+
shared-key: "${{ runner.os }}-${{ inputs.hypervisor }}-release"
101101
save-if: "false"
102102

103103
- name: Download Rust guests

.github/workflows/dep_build_guests.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ jobs:
6161
with:
6262
shared-key: "guests-${{ inputs.config }}"
6363
cache-on-failure: "true"
64+
# Only save on main as caches are not shared across branches.
65+
# https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache
66+
save-if: ${{ github.ref == 'refs/heads/main' }}
6467
workspaces: |
6568
. -> target
6669
src/tests/rust_guests/simpleguest -> target

.github/workflows/dep_build_test.yml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,11 @@ jobs:
6464
- name: Rust cache
6565
uses: Swatinem/rust-cache@v2
6666
with:
67-
shared-key: "${{ runner.os }}-${{ inputs.config }}"
67+
shared-key: "${{ runner.os }}-${{ inputs.hypervisor }}-${{ inputs.config }}"
6868
cache-on-failure: "true"
69+
# Only save on main as caches are not shared across branches.
70+
# https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache
71+
save-if: ${{ github.ref == 'refs/heads/main' }}
6972

7073
- name: Download Rust guests
7174
uses: actions/download-artifact@v8

.github/workflows/dep_code_checks.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,9 @@ jobs:
5757
with:
5858
shared-key: "code-checks-linux"
5959
cache-on-failure: "true"
60+
# Only save on main as caches are not shared across branches.
61+
# https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache
62+
save-if: ${{ github.ref == 'refs/heads/main' }}
6063
workspaces: |
6164
. -> target
6265
src/tests/rust_guests/simpleguest -> target
@@ -128,6 +131,9 @@ jobs:
128131
with:
129132
shared-key: "code-checks-windows"
130133
cache-on-failure: "true"
134+
# Only save on main as caches are not shared across branches.
135+
# https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching#restrictions-for-accessing-a-cache
136+
save-if: ${{ github.ref == 'refs/heads/main' }}
131137
workspaces: |
132138
. -> target
133139
src/tests/rust_guests/simpleguest -> target

.github/workflows/dep_run_examples.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ jobs:
6464
- name: Rust cache
6565
uses: Swatinem/rust-cache@v2
6666
with:
67-
shared-key: "${{ runner.os }}-${{ inputs.config }}"
67+
shared-key: "${{ runner.os }}-${{ inputs.hypervisor }}-${{ inputs.config }}"
6868
save-if: "false"
6969

7070
- name: Download Rust guests

0 commit comments

Comments
 (0)