Skip to content

Commit 2af763e

Browse files
authored
fix: use app-slug output instead of /app API in dependabot guest lock workflow (#1246)
The /app endpoint requires JWT auth but GH_TOKEN is an installation token, causing HTTP 401. Use the app-slug output from create-github-app-token instead. Signed-off-by: Ludvig Liljenberg <4257730+ludfjig@users.noreply.github.com>
1 parent c5b47dd commit 2af763e

File tree

5 files changed

+74
-25
lines changed

5 files changed

+74
-25
lines changed

.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/dependabot-update-guest-locks.yml renamed to .github/workflows/dep_update_guest_locks.yml

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
# This workflow automatically updates the Cargo.lock files in guest crates when
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
24
# Dependabot updates dependencies. Without this, Dependabot PRs only update the
35
# root Cargo.lock, leaving the guest crate Cargo.lock files stale.
46
#
@@ -7,24 +9,21 @@
79
name: Update Guest Cargo.lock for Dependabot PRs
810

911
on:
10-
pull_request:
11-
branches: [main]
12-
paths:
13-
- 'Cargo.toml'
14-
- 'Cargo.lock'
15-
- 'src/hyperlight_*/Cargo.toml'
16-
17-
permissions:
18-
contents: read # Required for actions/checkout to clone the repo
19-
pull-requests: read # Required for dependabot/fetch-metadata to read PR info
12+
workflow_call:
2013

2114
env:
2215
CARGO_TERM_COLOR: always
2316

17+
permissions:
18+
contents: read
19+
pull-requests: read
20+
21+
defaults:
22+
run:
23+
shell: bash
24+
2425
jobs:
2526
update-guest-locks:
26-
# Only run for Dependabot PRs - check the PR author, not the actor
27-
if: github.event.pull_request.user.login == 'dependabot[bot]'
2827
runs-on: [self-hosted, Linux, X64, "1ES.Pool=hld-kvm-amd"]
2928
timeout-minutes: 15
3029
steps:
@@ -109,6 +108,7 @@ jobs:
109108
if: steps.check-ecosystem.outputs.is_cargo == 'true'
110109
env:
111110
GH_TOKEN: ${{ steps.get-app-token.outputs.token }}
111+
APP_SLUG: ${{ steps.get-app-token.outputs.app-slug }}
112112
DEPENDENCY_NAMES: ${{ steps.metadata.outputs.dependency-names }}
113113
BRANCH: ${{ github.head_ref }}
114114
REPO: ${{ github.repository }}
@@ -124,7 +124,9 @@ jobs:
124124
echo "Guest Cargo.lock files have changed, committing via API..."
125125
126126
# Get app identity for DCO sign-off trailer
127-
app_slug=$(gh api /app --jq .slug)
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}"
128130
app_user_id=$(gh api "/users/${app_slug}[bot]" --jq .id)
129131
130132
# Get current branch HEAD and its tree

src/tests/rust_guests/dummyguest/Cargo.lock

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

src/tests/rust_guests/simpleguest/Cargo.lock

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

src/tests/rust_guests/witguest/Cargo.lock

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

0 commit comments

Comments
 (0)