Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
96 changes: 96 additions & 0 deletions .github/workflows/RegenSnapshotGoldens.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json

name: Regenerate Snapshot Goldens

on:
pull_request:
types: [labeled]

permissions:
contents: read
pull-requests: read

defaults:
run:
shell: bash

jobs:
# Build guests once, upload as artifacts for the regen jobs to
# download. Mirrors `build-guests` in `ValidatePullRequest.yml`.
build-guests:
if: github.event.label.name == 'regen-goldens'
strategy:
fail-fast: false
matrix:
config: [debug]
uses: ./.github/workflows/dep_build_guests.yml
secrets: inherit
with:
docs_only: "false"
config: ${{ matrix.config }}

regen:
if: github.event.label.name == 'regen-goldens'
needs: [build-guests]
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
hypervisor: ['hyperv-ws2025', mshv3, kvm]
cpu: [amd, intel]
runs-on: ${{ fromJson(
format('["self-hosted", "{0}", "X64", "1ES.Pool=hld-{1}-{2}", "JobId=regen-goldens-{3}-{4}-{5}-{6}"]',
matrix.hypervisor == 'hyperv-ws2025' && 'Windows' || 'Linux',
matrix.hypervisor == 'hyperv-ws2025' && 'win2025' || matrix.hypervisor == 'mshv3' && 'azlinux3-mshv' || matrix.hypervisor,
matrix.cpu,
matrix.hypervisor,
github.run_id,
github.run_number,
github.run_attempt)) }}
steps:
- uses: actions/checkout@v6

- uses: hyperlight-dev/ci-setup-workflow@v1.9.0
with:
rust-toolchain: "1.89"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Fix cargo home permissions
if: runner.os == 'Linux'
run: |
sudo chown -R $(id -u):$(id -g) /opt/cargo || true

- name: Rust cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "${{ runner.os }}-debug"
cache-on-failure: "true"

- name: Download Rust guests
uses: actions/download-artifact@v8
with:
name: rust-guests-debug
path: src/tests/rust_guests/bin/debug/

- name: Run regen
env:
HYPERLIGHT_REGEN_GOLDENS: "1"
run: |
cargo test -p hyperlight-host --lib \
sandbox::snapshot::golden_tests::golden_regen \
-- --nocapture

- name: Upload regenerated fixtures
uses: actions/upload-artifact@v4
with:
name: goldens-${{ matrix.hypervisor }}-${{ matrix.cpu }}
# Map the runner's hypervisor input to the fixture filename
# suffix that golden_regen produces for that runner: mshv3 -> mshv,
# hyperv-ws2025 -> whp, kvm -> kvm. Restricting the glob this way
# avoids uploading stale fixtures for other HVs that happened to
# be checked in alongside this branch.
path: |
src/hyperlight_host/tests/snapshot_goldens/fixtures/*_${{ matrix.hypervisor == 'mshv3' && 'mshv' || matrix.hypervisor == 'hyperv-ws2025' && 'whp' || matrix.hypervisor }}.hls
if-no-files-found: error
retention-days: 14
21 changes: 21 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

44 changes: 44 additions & 0 deletions Justfile
Original file line number Diff line number Diff line change
Expand Up @@ -572,3 +572,47 @@ install-vcpkg:

install-flatbuffers-with-vcpkg: install-vcpkg
cd ../vcpkg && ./vcpkg install flatbuffers || cd -

##################################
### SNAPSHOT GOLDEN CROSS-LOAD ###
##################################
# Cross-HV/CPU experiment helpers. Pull the `.hls` fixtures
# generated by a specific run of the `Regenerate Snapshot Goldens`
# workflow, drop them into the local fixtures dir under the
# locally-detected hypervisor's name, and run the goldens with
# validation bypassed so the HV-tag mismatch in the file does not
# fail the load.
#
# Requires: `gh` CLI authenticated to the repo. The CI run id is
# the run that produced the artifacts you want (find it under the
# Actions tab of the PR).

# Fetch all `goldens-*` artifacts from a regen workflow run into
# `target/snapshot-goldens-cross-load/`. Run id is the only arg.
#
# Example:
# just fetch-snapshot-goldens 25583983652
fetch-snapshot-goldens run_id:
{{ if os() == "windows" { "if (Test-Path target/snapshot-goldens-cross-load) { Remove-Item -Recurse -Force target/snapshot-goldens-cross-load }" } else { "rm -rf target/snapshot-goldens-cross-load" } }}
{{ if os() == "windows" { "New-Item -ItemType Directory -Force target/snapshot-goldens-cross-load | Out-Null" } else { "mkdir -p target/snapshot-goldens-cross-load" } }}
gh run download {{run_id}} --dir target/snapshot-goldens-cross-load -p 'goldens-*'
ls target/snapshot-goldens-cross-load/

# Cross-load test: copy the chosen artifact's `.hls` files over the
# committed fixtures (renamed to the local HV's suffix) and run
# goldens with validation bypassed. `source` is the artifact dir
# name (e.g. `goldens-kvm-intel`). `source_hv` is the suffix used
# inside that artifact (`kvm`, `mshv`, or `whp`). `local_hv` is the
# locally-detected hypervisor's suffix (`kvm`, `mshv`, or `whp`).
#
# Example (load AMD-on-KVM CI artifact on a local Intel KVM box):
# just cross-load-snapshot-goldens goldens-kvm-amd kvm kvm
#
# Example (load Intel-on-MSHV CI artifact on a local KVM box):
# just cross-load-snapshot-goldens goldens-mshv3-intel mshv kvm
cross-load-snapshot-goldens source source_hv local_hv:
{{ if os() == "windows" { "Copy-Item -Force target/snapshot-goldens-cross-load/" + source + "/init_" + source_hv + ".hls src/hyperlight_host/tests/snapshot_goldens/fixtures/init_" + local_hv + ".hls" } else { "cp target/snapshot-goldens-cross-load/" + source + "/init_" + source_hv + ".hls src/hyperlight_host/tests/snapshot_goldens/fixtures/init_" + local_hv + ".hls" } }}
{{ if os() == "windows" { "Copy-Item -Force target/snapshot-goldens-cross-load/" + source + "/call_" + source_hv + ".hls src/hyperlight_host/tests/snapshot_goldens/fixtures/call_" + local_hv + ".hls" } else { "cp target/snapshot-goldens-cross-load/" + source + "/call_" + source_hv + ".hls src/hyperlight_host/tests/snapshot_goldens/fixtures/call_" + local_hv + ".hls" } }}
{{ if os() == "windows" { "$env:HYPERLIGHT_SNAPSHOT_BYPASS_VALIDATION = '1'; cargo test -p hyperlight-host --lib sandbox::snapshot::golden_tests" } else { "HYPERLIGHT_SNAPSHOT_BYPASS_VALIDATION=1 cargo test -p hyperlight-host --lib sandbox::snapshot::golden_tests" } }}
git checkout src/hyperlight_host/tests/snapshot_goldens/fixtures/

Loading
Loading