Skip to content

Commit fcda1a7

Browse files
authored
Merge branch 'main' into squad/1061-fix-flaky-gdb-test
2 parents 0ca66a2 + 2af763e commit fcda1a7

23 files changed

Lines changed: 287 additions & 61 deletions

File tree

.github/workflows/ValidatePullRequest.yml

Lines changed: 39 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ concurrency:
1515

1616
permissions:
1717
contents: write
18+
pull-requests: read
1819

1920
jobs:
2021
docs-pr:
@@ -40,9 +41,24 @@ jobs:
4041
return all_file_count === docs_file_count;
4142
result-encoding: string
4243

44+
# Update guest Cargo.lock files for Dependabot PRs.
45+
# Dependabot only updates the root Cargo.lock, leaving the guest crate
46+
# Cargo.lock files stale. This job updates them before code-checks runs
47+
# `cargo fetch --locked` so that the first CI run succeeds.
48+
update-guest-locks:
49+
if: >-
50+
github.event.pull_request.user.login == 'dependabot[bot]' &&
51+
github.actor == 'dependabot[bot]'
52+
uses: ./.github/workflows/dep_update_guest_locks.yml
53+
secrets: inherit
54+
4355
# Build guests once, upload as artifacts for other jobs to download
4456
build-guests:
45-
needs: docs-pr
57+
needs: [docs-pr, update-guest-locks]
58+
# Required because update-guest-locks is skipped on non-dependabot PRs,
59+
# and a skipped dependency transitively skips all downstream jobs.
60+
# See: https://github.com/actions/runner/issues/2205
61+
if: ${{ !cancelled() && !failure() }}
4662
strategy:
4763
fail-fast: true
4864
matrix:
@@ -55,7 +71,11 @@ jobs:
5571

5672
# Code checks (fmt, clippy, MSRV) - runs in parallel with build-guests
5773
code-checks:
58-
needs: docs-pr
74+
needs: [docs-pr, update-guest-locks]
75+
# Required because update-guest-locks is skipped on non-dependabot PRs,
76+
# and a skipped dependency transitively skips all downstream jobs.
77+
# See: https://github.com/actions/runner/issues/2205
78+
if: ${{ !cancelled() && !failure() }}
5979
uses: ./.github/workflows/dep_code_checks.yml
6080
secrets: inherit
6181
with:
@@ -66,6 +86,10 @@ jobs:
6686
needs:
6787
- docs-pr
6888
- build-guests
89+
# Required because update-guest-locks is skipped on non-dependabot PRs,
90+
# and a skipped dependency transitively skips all downstream jobs.
91+
# See: https://github.com/actions/runner/issues/2205
92+
if: ${{ !cancelled() && !failure() }}
6993
strategy:
7094
fail-fast: true
7195
matrix:
@@ -85,6 +109,10 @@ jobs:
85109
needs:
86110
- docs-pr
87111
- build-guests
112+
# Required because update-guest-locks is skipped on non-dependabot PRs,
113+
# and a skipped dependency transitively skips all downstream jobs.
114+
# See: https://github.com/actions/runner/issues/2205
115+
if: ${{ !cancelled() && !failure() }}
88116
strategy:
89117
fail-fast: true
90118
matrix:
@@ -104,6 +132,10 @@ jobs:
104132
needs:
105133
- docs-pr
106134
- build-guests
135+
# Required because update-guest-locks is skipped on non-dependabot PRs,
136+
# and a skipped dependency transitively skips all downstream jobs.
137+
# See: https://github.com/actions/runner/issues/2205
138+
if: ${{ !cancelled() && !failure() }}
107139
strategy:
108140
fail-fast: true
109141
matrix:
@@ -120,6 +152,10 @@ jobs:
120152
needs:
121153
- docs-pr
122154
- build-guests
155+
# Required because update-guest-locks is skipped on non-dependabot PRs,
156+
# and a skipped dependency transitively skips all downstream jobs.
157+
# See: https://github.com/actions/runner/issues/2205
158+
if: ${{ !cancelled() && !failure() }}
123159
uses: ./.github/workflows/dep_fuzzing.yml
124160
with:
125161
targets: '["fuzz_host_print", "fuzz_guest_call", "fuzz_host_call", "fuzz_guest_estimate_trace_event", "fuzz_guest_trace"]' # Pass as a JSON array
@@ -148,6 +184,7 @@ jobs:
148184
report-ci-status:
149185
needs:
150186
- docs-pr
187+
- update-guest-locks
151188
- build-guests
152189
- code-checks
153190
- build-test

.github/workflows/dep_code_checks.yml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,11 @@ jobs:
6464
src/tests/rust_guests/witguest -> target
6565
6666
- name: Ensure up-to-date Cargo.lock
67-
run: cargo fetch --locked
67+
run: |
68+
cargo fetch --locked
69+
cargo fetch --manifest-path src/tests/rust_guests/simpleguest/Cargo.toml --locked
70+
cargo fetch --manifest-path src/tests/rust_guests/dummyguest/Cargo.toml --locked
71+
cargo fetch --manifest-path src/tests/rust_guests/witguest/Cargo.toml --locked
6872
6973
- name: fmt
7074
run: just fmt-check
@@ -128,7 +132,11 @@ jobs:
128132
src/tests/rust_guests/witguest -> target
129133
130134
- name: Ensure up-to-date Cargo.lock
131-
run: cargo fetch --locked
135+
run: |
136+
cargo fetch --locked
137+
cargo fetch --manifest-path src/tests/rust_guests/simpleguest/Cargo.toml --locked
138+
cargo fetch --manifest-path src/tests/rust_guests/dummyguest/Cargo.toml --locked
139+
cargo fetch --manifest-path src/tests/rust_guests/witguest/Cargo.toml --locked
132140
133141
- name: fmt
134142
run: just fmt-check
Lines changed: 177 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,177 @@
1+
# yaml-language-server: $schema=https://json.schemastore.org/github-workflow.json
2+
3+
# This reusable workflow updates the Cargo.lock files in guest crates when
4+
# Dependabot updates dependencies. Without this, Dependabot PRs only update the
5+
# root Cargo.lock, leaving the guest crate Cargo.lock files stale.
6+
#
7+
# See: https://docs.github.com/en/code-security/tutorials/secure-your-dependencies/automating-dependabot-with-github-actions
8+
9+
name: Update Guest Cargo.lock for Dependabot PRs
10+
11+
on:
12+
workflow_call:
13+
14+
env:
15+
CARGO_TERM_COLOR: always
16+
17+
permissions:
18+
contents: read
19+
pull-requests: read
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
25+
jobs:
26+
update-guest-locks:
27+
runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"]
28+
timeout-minutes: 15
29+
steps:
30+
# Fetch metadata about the Dependabot PR
31+
- name: Dependabot metadata
32+
id: metadata
33+
uses: dependabot/fetch-metadata@v2
34+
with:
35+
github-token: "${{ secrets.GITHUB_TOKEN }}"
36+
37+
# Only proceed for cargo ecosystem updates
38+
- name: Check if cargo update
39+
id: check-ecosystem
40+
run: |
41+
if [ "${{ steps.metadata.outputs.package-ecosystem }}" = "cargo" ]; then
42+
echo "is_cargo=true" >> "$GITHUB_OUTPUT"
43+
else
44+
echo "is_cargo=false" >> "$GITHUB_OUTPUT"
45+
echo "Skipping non-cargo dependency update"
46+
fi
47+
48+
# Get GitHub App token for pushing commits back to the PR
49+
# Uses the same app as auto-merge-dependabot.yml
50+
- name: Get GitHub App token
51+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
52+
uses: actions/create-github-app-token@v2
53+
id: get-app-token
54+
with:
55+
app-id: ${{ secrets.DEPENDABOT_APP_ID }}
56+
private-key: ${{ secrets.DEPENDABOT_APP_KEY }}
57+
permission-contents: write
58+
59+
- name: Checkout PR branch
60+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
61+
uses: actions/checkout@v6
62+
with:
63+
token: ${{ steps.get-app-token.outputs.token }}
64+
ref: ${{ github.head_ref }}
65+
fetch-depth: 0
66+
persist-credentials: false
67+
68+
- name: Setup Rust toolchain
69+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
70+
uses: hyperlight-dev/ci-setup-workflow@v1.8.0
71+
with:
72+
rust-toolchain: "1.89"
73+
env:
74+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
75+
76+
- name: Fix cargo home permissions
77+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
78+
run: |
79+
sudo chown -R $(id -u):$(id -g) /opt/cargo || true
80+
81+
- name: Update simpleguest Cargo.lock
82+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
83+
working-directory: src/tests/rust_guests/simpleguest
84+
run: cargo fetch
85+
86+
- name: Update dummyguest Cargo.lock
87+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
88+
working-directory: src/tests/rust_guests/dummyguest
89+
run: cargo fetch
90+
91+
- name: Update witguest Cargo.lock
92+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
93+
working-directory: src/tests/rust_guests/witguest
94+
run: cargo fetch
95+
96+
# Commits created via the Git Data API are automatically signed/verified
97+
# by GitHub when authenticated as a GitHub App and no custom author or
98+
# committer info is provided.
99+
#
100+
# References:
101+
# - Signature verification for bots:
102+
# https://docs.github.com/en/authentication/managing-commit-signature-verification/about-commit-signature-verification#signature-verification-for-bots
103+
# - How to Use Commit Signing with GitHub Apps:
104+
# https://github.com/orgs/community/discussions/50055
105+
# - Git Data API (Create a commit):
106+
# https://docs.github.com/en/rest/git/commits#create-a-commit
107+
- name: Commit and push changes via API
108+
if: steps.check-ecosystem.outputs.is_cargo == 'true'
109+
env:
110+
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
111+
APP_SLUG: ${{ steps.get-app-token.outputs.app-slug }}
112+
DEPENDENCY_NAMES: ${{ steps.metadata.outputs.dependency-names }}
113+
BRANCH: ${{ github.head_ref }}
114+
REPO: ${{ github.repository }}
115+
run: |
116+
set -euo pipefail
117+
118+
# Check if there are any changes to the guest Cargo.lock files
119+
if git diff --quiet -- src/tests/rust_guests/*/Cargo.lock; then
120+
echo "No changes to guest Cargo.lock files"
121+
exit 0
122+
fi
123+
124+
echo "Guest Cargo.lock files have changed, committing via API..."
125+
126+
# Get app identity for DCO sign-off trailer
127+
# Use the app-slug output from create-github-app-token (the /app API
128+
# endpoint requires JWT auth, not an installation token).
129+
app_slug="${APP_SLUG}"
130+
app_user_id=$(gh api "/users/${app_slug}[bot]" --jq .id)
131+
132+
# Get current branch HEAD and its tree
133+
HEAD_SHA=$(gh api "/repos/${REPO}/git/ref/heads/${BRANCH}" --jq .object.sha)
134+
BASE_TREE=$(gh api "/repos/${REPO}/git/commits/${HEAD_SHA}" --jq .tree.sha)
135+
136+
# Build tree entries with file content for each changed Cargo.lock.
137+
# The tree API accepts "content" directly and creates blobs for us,
138+
# avoiding the need for separate blob creation API calls.
139+
TREE_JSON="[]"
140+
for file in $(git diff --name-only -- src/tests/rust_guests/*/Cargo.lock); do
141+
TREE_JSON=$(jq \
142+
--arg path "$file" \
143+
--arg content "$(cat "$file")" \
144+
'. + [{"path": $path, "mode": "100644", "type": "blob", "content": $content}]' \
145+
<<< "$TREE_JSON")
146+
done
147+
148+
# Create a new tree with the updated files
149+
NEW_TREE=$(jq -n \
150+
--arg base "$BASE_TREE" \
151+
--argjson tree "$TREE_JSON" \
152+
'{"base_tree": $base, "tree": $tree}' | \
153+
gh api "/repos/${REPO}/git/trees" --input - --jq .sha)
154+
155+
# Build commit message with DCO sign-off
156+
SIGNOFF="${app_slug}[bot] <${app_user_id}+${app_slug}[bot]@users.noreply.github.com>"
157+
COMMIT_MSG=$(printf '%s\n\n%s\n%s\n\n%s' \
158+
"chore: update guest Cargo.lock files" \
159+
"Automatically updated by dependabot-update-guest-locks workflow." \
160+
"Triggered by: ${DEPENDENCY_NAMES}" \
161+
"Signed-off-by: ${SIGNOFF}")
162+
163+
# Create commit via API — GitHub signs it automatically since we
164+
# authenticate as the App and omit custom author/committer info.
165+
NEW_COMMIT=$(jq -n \
166+
--arg msg "$COMMIT_MSG" \
167+
--arg tree "$NEW_TREE" \
168+
--arg parent "$HEAD_SHA" \
169+
'{"message": $msg, "tree": $tree, "parents": [$parent]}' | \
170+
gh api "/repos/${REPO}/git/commits" --input - --jq .sha)
171+
172+
# Update branch ref to point to the new commit
173+
gh api "/repos/${REPO}/git/refs/heads/${BRANCH}" \
174+
-X PATCH \
175+
-f sha="${NEW_COMMIT}"
176+
177+
echo "Successfully committed and pushed changes"

Cargo.lock

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Justfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ test-like-ci config=default-target hypervisor="kvm":
102102
code-checks-like-ci config=default-target hypervisor="kvm":
103103
@# Ensure up-to-date Cargo.lock
104104
cargo fetch --locked
105+
cargo fetch --manifest-path src/tests/rust_guests/simpleguest/Cargo.toml --locked
106+
cargo fetch --manifest-path src/tests/rust_guests/dummyguest/Cargo.toml --locked
107+
cargo fetch --manifest-path src/tests/rust_guests/witguest/Cargo.toml --locked
105108

106109
@# fmt
107110
just fmt-check

src/hyperlight_common/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ workspace = true
1616

1717
[dependencies]
1818
flatbuffers = { version = "25.12.19", default-features = false }
19-
anyhow = { version = "1.0.101", default-features = false }
19+
anyhow = { version = "1.0.102", default-features = false }
2020
log = "0.4.29"
2121
tracing = { version = "0.1.44", optional = true }
2222
arbitrary = {version = "1.4.2", optional = true, features = ["derive"]}

src/hyperlight_component_macro/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ proc-macro = true
1919
wasmparser = { version = "0.244.0" }
2020
quote = { version = "1.0.44" }
2121
proc-macro2 = { version = "1.0.106" }
22-
syn = { version = "2.0.114" }
22+
syn = { version = "2.0.117" }
2323
itertools = { version = "0.14.0" }
2424
prettyplease = { version = "0.2.37" }
2525
hyperlight-component-util = { workspace = true }

src/hyperlight_component_util/Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ name = "hyperlight_component_util"
1818
wasmparser = { version = "0.244.0" }
1919
quote = { version = "1.0.44" }
2020
proc-macro2 = { version = "1.0.106" }
21-
syn = { version = "2.0.114" }
21+
syn = { version = "2.0.117" }
2222
itertools = { version = "0.14.0" }
2323
prettyplease = { version = "0.2.37" }
24-
log = { version = "0.4" }
24+
tracing = { version = "0.1.44", features = ["log"]}

0 commit comments

Comments
 (0)