diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bf99f8ea..e91cbb3c 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -12,57 +12,15 @@ concurrency: # Least privilege by default: this workflow executes PR-controlled build code # (the Justfile and build scripts come from the PR head), so the workflow-wide -# token is read-only. contents: write is granted per job only where genuinely -# required (see track-refs and release below). +# token is read-only. No job that runs on `pull_request` holds a write token; +# contents: write is granted only to `release`, which is gated to main. permissions: contents: read jobs: - # Resolves BuildStream junction refs and pushes them back to the PR branch. - # This runs PR-controlled code (`just bst source track`) with a write token, - # so it keeps the pre-existing renovate/* branch gate. The push updates the - # PR branch tip; the build job below runs afterwards and checks out that - # updated tip. - track-refs: - if: github.event_name == 'pull_request' && startsWith(github.head_ref, 'renovate/') - runs-on: ubuntu-24.04 - timeout-minutes: 60 - permissions: - contents: write # pushes resolved refs back to the renovate/* PR branch - steps: - - name: Checkout repository - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 - with: - ref: ${{ github.event.pull_request.head.ref || github.ref }} - repository: ${{ github.event.pull_request.head.repo.full_name || github.repository }} - - - name: Set up just - uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c # v2 - with: - tool: just - - - name: Track and Resolve BuildStream Refs - env: - HEAD_REF: ${{ github.head_ref }} - run: | - set -euo pipefail - git config --global user.name "github-actions[bot]" - git config --global user.email "github-actions[bot]@users.noreply.github.com" - just bst source track freedesktop-sdk.bst || true - just bst source track gnome-build-meta.bst || true - if ! git diff --exit-code; then - git add elements/ - git commit -m "chore: resolve BuildStream junction refs to git-describe format" -m "Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>" - git push origin "HEAD:${HEAD_REF}" - fi - build: # Read-only token (workflow default): on pull_request this job checks out # and executes PR-controlled code, so it must never hold a write token. - needs: track-refs - # track-refs is skipped for non-renovate PRs and pushes; only a failed or - # cancelled track job should stop the build. - if: ${{ !failure() && !cancelled() }} runs-on: ubuntu-24.04 timeout-minutes: 180 outputs: @@ -182,7 +140,7 @@ jobs: # Publishes the signed assets to the GitHub Release. Only runs on # pushes/dispatches to main, where the code is already reviewed, and is the - # only job besides track-refs that holds contents: write. + # only job in this workflow that holds contents: write. release: if: ${{ !failure() && !cancelled() && github.ref == 'refs/heads/main' }} needs: [build, installer-test] diff --git a/.github/workflows/track-junctions.yml b/.github/workflows/track-junctions.yml new file mode 100644 index 00000000..2b7c2c63 --- /dev/null +++ b/.github/workflows/track-junctions.yml @@ -0,0 +1,162 @@ +name: Track junction refs + +# Resolves the BuildStream junction refs on a schedule and delivers the result +# as its own titled pull request. +# +# This deliberately has NO `pull_request` trigger. The job this replaces +# (`track-refs` in build.yml) ran on every `renovate/*` pull request and pushed +# re-resolved junction refs onto that PR's branch, so unrelated dependency PRs +# silently acquired freedesktop-sdk and gnome-build-meta bumps that appeared in +# no title, body or Renovate table. Moving the work onto a schedule with its own +# branch also removes the need for the old `startsWith(github.head_ref, +# 'renovate/')` gate: a branch name is not an identity, and on a scheduled +# trigger there is no PR-controlled head to gate in the first place. +on: + schedule: + # Offset from dakota's trackers (06:00 and 20:00 UTC) to spread runner load. + - cron: '0 8 * * *' + workflow_dispatch: + +permissions: + contents: read + +# Tracking only queries upstream git remotes to resolve refs; it never builds +# and never touches the CAS, so it has no reason to share the build group. +concurrency: + group: track-junctions + cancel-in-progress: false + +jobs: + track-junctions: + runs-on: ubuntu-24.04 + timeout-minutes: 60 + permissions: + contents: write # pushes the auto/track-junctions branch + pull-requests: write # opens/updates the junction bump PR + steps: + # A GitHub App token, not secrets.GITHUB_TOKEN: pushes and PRs made with + # GITHUB_TOKEN do not dispatch workflow runs, which is why the old job's + # github-actions[bot] commits left PRs sitting at `action_required` with + # zero jobs and no checks at all. + - name: Get mergeraptor token + id: app-token + uses: actions/create-github-app-token@bcd2ba49218906704ab6c1aa796996da409d3eb1 # v3 + with: + app-id: ${{ secrets.MERGERAPTOR_APP_ID }} + private-key: ${{ secrets.MERGERAPTOR_PRIVATE_KEY }} + + - name: Checkout repository + uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 + with: + ref: main + fetch-depth: 0 + token: ${{ steps.app-token.outputs.token }} + + - name: Set up just + uses: taiki-e/install-action@7b8d4719ee4aaa279bdf55df38dacb9ebfe12a6c # v2 + with: + tool: just + + - name: Track and resolve BuildStream junction refs + run: | + set -euo pipefail + # No `|| true` here. The job this replaces swallowed both exit codes, + # which made an upstream outage indistinguishable from "nothing to + # track" and let the run report success having resolved nothing. + # + # gnome-build-meta.bst carries `overrides: freedesktop-sdk.bst`, so + # the pair is only valid together and is tracked and committed as one + # atomic change — same rationale as dakota's track-core-junctions. + just bst source track freedesktop-sdk.bst + just bst source track gnome-build-meta.bst + + - name: Sync release-version to the tracked FSDK point release + run: | + set -euo pipefail + # project.conf's release-version names every published OS asset and + # must equal the FSDK point release; check-release-version.py fails + # closed on drift and is the first thing `just validate` runs. Without + # this step an FSDK bump would open a PR that dies in seconds at + # "Validate Element Graph" — exactly the failure the old job produced. + pinned=$(grep -oE 'freedesktop-sdk-[0-9]+\.[0-9]+\.[0-9]+' elements/freedesktop-sdk.bst | head -1 | sed 's/freedesktop-sdk-//') + if [ -z "$pinned" ]; then + echo "ERROR: tracked freedesktop-sdk.bst ref carries no X.Y.Z point release" >&2 + exit 1 + fi + sed -i -E "s|^([[:space:]]*release-version:[[:space:]]*).*|\1\"${pinned}\"|" project.conf + # Assert before opening the PR; a failure here means the sync broke. + python3 .github/scripts/check-release-version.py + + - name: Create or update the junction bump PR + env: + GH_TOKEN: ${{ steps.app-token.outputs.token }} + BRANCH: auto/track-junctions + run: | + set -euo pipefail + + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + + old_fsdk=$(git show "HEAD:elements/freedesktop-sdk.bst" | awk '/^[[:space:]]*ref:/ { print $2; exit }') + old_gbm=$(git show "HEAD:elements/gnome-build-meta.bst" | awk '/^[[:space:]]*ref:/ { print $2; exit }') + new_fsdk=$(awk '/^[[:space:]]*ref:/ { print $2; exit }' elements/freedesktop-sdk.bst) + new_gbm=$(awk '/^[[:space:]]*ref:/ { print $2; exit }' elements/gnome-build-meta.bst) + + git checkout -B "$BRANCH" + git add elements/freedesktop-sdk.bst elements/gnome-build-meta.bst project.conf + if git diff --cached --quiet; then + echo "Junction refs already current — nothing to propose." + exit 0 + fi + + title="chore(deps): update BuildStream junctions" + if [ "$old_fsdk" != "$new_fsdk" ]; then + title="${title} (freedesktop-sdk $(echo "$old_fsdk" | sed 's/^freedesktop-sdk-//;s/-[0-9]*-g[0-9a-f]*$//') -> $(echo "$new_fsdk" | sed 's/^freedesktop-sdk-//;s/-[0-9]*-g[0-9a-f]*$//'))" + elif [ "$old_gbm" != "$new_gbm" ]; then + title="${title} (gnome-build-meta)" + fi + + { + echo "Scheduled resolution of the BuildStream junction refs to their" + echo "\`git-describe\` form. Opened by the tracker so the bump arrives as its own" + echo "reviewable change instead of being pushed into an unrelated pull request." + echo "" + echo "| Junction | From | To |" + echo "| --- | --- | --- |" + echo "| \`elements/freedesktop-sdk.bst\` | \`${old_fsdk}\` | \`${new_fsdk}\` |" + echo "| \`elements/gnome-build-meta.bst\` | \`${old_gbm}\` | \`${new_gbm}\` |" + echo "" + echo "\`project.conf\`'s \`release-version\` is synced to the pinned FSDK point" + echo "release in the same commit, because \`check-release-version.py\` fails closed" + echo "on drift between the two." + echo "" + echo "The two junctions move together: \`gnome-build-meta.bst\` overrides" + echo "\`freedesktop-sdk.bst\`, so a half-applied pair is not a valid graph." + echo "" + echo "---" + echo "*Generated by [Track junction refs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})*" + } > /tmp/pr-body.md + + # Deliberately no attribution trailers. This commit is a deterministic + # `bst source track` result plus a `sed` on project.conf — machine + # output with no AI authorship to attribute. The `Co-authored-by: + # Copilot` trailer inherited from the old track-refs job was a false + # attribution that would accumulate across every junction bump. Please + # do not re-add it; AGENTS.md's trailer requirement is about + # AI-authored commits, which this is not. + git commit -m "$title" + git push --force-with-lease origin "$BRANCH" + + # No `|| true`: `gh pr list` already exits 0 and prints nothing when + # no PR matches, so a fallback buys nothing for the normal case and + # only converts an auth failure or API outage into an empty + # `existing` that falls through to `gh pr create` against a branch + # that may already have an open PR. `// empty` is the legitimate + # mechanism for "no open PR"; a failed query must abort the step. + existing=$(gh pr list --head "$BRANCH" --base main --state open --json number --jq '.[0].number // empty') + if [ -n "$existing" ]; then + gh pr edit "$existing" --title "$title" --body-file /tmp/pr-body.md + echo "Updated PR: $(gh pr view "$existing" --json url --jq '.url')" + else + echo "Created PR: $(gh pr create --base main --head "$BRANCH" --title "$title" --body-file /tmp/pr-body.md)" + fi diff --git a/docs/skills/bump-fsdk-version.md b/docs/skills/bump-fsdk-version.md index 1d0453e3..ccd20f80 100644 --- a/docs/skills/bump-fsdk-version.md +++ b/docs/skills/bump-fsdk-version.md @@ -79,9 +79,9 @@ Before merging a bump: ## Automated Point-Release Bumps -Point releases are fully automated via Renovate and GitHub Actions. -- **Trigger:** Renovate bot scans `elements/freedesktop-sdk.bst` using a custom regex manager. When a new upstream point release is published, Renovate creates a Pull Request. -- **Mechanism:** On the Renovate PR, a GHA job in `build.yml` automatically runs `just bst source track freedesktop-sdk.bst` to track and resolve the raw tag to the full `git-describe` ref, then commits and pushes it back to the PR branch. +Point releases are delivered by the scheduled `track-junctions.yml` workflow. +- **Trigger:** `track-junctions.yml` runs daily and resolves the junction's own `track: freedesktop-sdk-26.08*` glob; it does not wait on a Renovate PR. +- **Mechanism:** `track-junctions.yml` runs `just bst source track freedesktop-sdk.bst` (alongside `gnome-build-meta.bst`, which overrides it), syncs `project.conf`'s `release-version` to the tracked point release, and opens its own PR on `auto/track-junctions`. It never runs on `pull_request`, so a junction bump can never be injected into an unrelated dependency PR. - **Build Loop:** When the PR is merged to `main`, GitHub Actions automatically compiles the standalone DDI OS and installer images, and publishes them directly to GitHub Releases under the new FSDK point-release version. ## See also diff --git a/docs/skills/ci-tooling.md b/docs/skills/ci-tooling.md index e236f99f..0effa27b 100644 --- a/docs/skills/ci-tooling.md +++ b/docs/skills/ci-tooling.md @@ -59,13 +59,19 @@ permissions: The workflow checks out and executes PR-controlled code (the `Justfile` and build scripts come from the PR head), so no job that runs on `pull_request` -may hold a write token. `contents: write` is granted per job only to: +may hold a write token. In `build.yml`, `contents: write` is granted to exactly +one job: -- `track-refs` — pushes resolved BuildStream refs back to the PR branch; gated - to `renovate/*` PRs. - `release` — creates the GitHub Release and uploads assets; gated to `refs/heads/main`. +Junction ref tracking must never run on `pull_request`. It used to, as a +`track-refs` job gated on `startsWith(github.head_ref, 'renovate/')`, and a +branch name is not an identity. It also pushed its result onto whatever PR +branch happened to be open, so unrelated dependency PRs silently carried +freedesktop-sdk and gnome-build-meta bumps. It now lives in +`track-junctions.yml` on a schedule, opening its own PR on its own branch. + The `build` job (validation, compile, signing) runs with the read-only default on every event. If a new job needs additional permissions, keep them as narrow as possible and document why. @@ -83,18 +89,23 @@ The `sudo_cmd` Just variable auto-detects at recipe startup: sudo_cmd := if `podman info >/dev/null 2>&1 && echo 1 || echo 0` == "1" { "" } else { "sudo" } ``` -### No PAT/App credentials in CI +### No PATs; GitHub App tokens for automation that must trigger CI - Personal Access Tokens (PATs) are banned. - `repository_dispatch` is not used for build handoff. -- Build/release triggers are driven cleanly by Renovate PR merges or manual - dispatches. The workflow uses `secrets.GITHUB_TOKEN` for release uploads. +- `secrets.GITHUB_TOKEN` is used for release uploads inside `build.yml`. +- Automation that pushes a branch and opens a PR uses the org-wide + `mergeraptor` GitHub App (`secrets.MERGERAPTOR_APP_ID` / + `secrets.MERGERAPTOR_PRIVATE_KEY`) via `actions/create-github-app-token`, as + `projectbluefin/dakota` does. This is not cosmetic: pushes made with + `secrets.GITHUB_TOKEN` do not dispatch workflow runs, so a PR built that way + sits at `action_required` with zero jobs and never gets checks. ## Workflow Structure | Job | Workflow | Trigger | Purpose | |-----|----------|---------|---------| -| `track-refs` | `build.yml` | `pull_request` (`renovate/*` only) | Resolves BuildStream junction refs and pushes them back to the PR branch. Sole `contents: write` grant on `pull_request`. | +| `track-junctions` | `track-junctions.yml` | `schedule` (08:00 UTC), `workflow_dispatch` | Resolves the `freedesktop-sdk.bst` + `gnome-build-meta.bst` junction refs, syncs `project.conf`'s `release-version`, and opens/updates its own PR on `auto/track-junctions`. `contents: write` + `pull-requests: write`, never on `pull_request`. | | `build` | `build.yml` | `pull_request`, `push/main`, `workflow_dispatch` | Resolves the element graph, runs the full BuildStream compile (including Flatcar LTS Kernel & ZFS), and signs the release manifest on pushes to `main`. Read-only token. | | `installer-test` | `build.yml` | `pull_request`, `push/main`, `workflow_dispatch` | Downloads the build job's exported installer/PXE artifact and calls the shared `projectbluefin/actions` QEMU workflow. No Lima or second BuildStream build. | | `release` | `build.yml` | `push/main`, `workflow_dispatch` | Downloads the signed assets handed off by `build` and publishes them to the GitHub Release (`if: ${{ !failure() && !cancelled() && github.ref == 'refs/heads/main' }}`). `contents: write`. | @@ -111,9 +122,10 @@ uploaded to a GitHub Release tagged `installer-v`. 1. **Renovate tracking:** `renovate.json` is configured with a custom regex manager to scan BuildStream junction files (`freedesktop-sdk.bst` and `gnome-build-meta.bst`) using the `git-refs` datasource. -2. **Auto-resolution:** On Renovate PRs, GitHub Actions executes - `just bst source track` to resolve raw tags to full `git-describe` refs and - commits them back to the PR branch. +2. **Auto-resolution:** The scheduled `track-junctions` workflow executes + `just bst source track` to resolve raw tags to full `git-describe` refs, + syncs `release-version` to the tracked FSDK point release, and proposes the + result as its own pull request against `main`. 3. **Full Compilation:** Builds the standalone DDI OS image, live installer, and k0s systemd-sysext on every pull request and push to `main`. 4. **Installer boot test:** Uploads the already-built installer and PXE artifacts and calls `projectbluefin/actions/.github/workflows/server-installer-test.yml`. The shared workflow prepares QEMU/KVM and runs this repository's `just test-installer-artifact`; Lima remains local-only. diff --git a/workflows/server-release-watch-and-fix.md b/workflows/server-release-watch-and-fix.md index f0e4251b..fa352027 100644 --- a/workflows/server-release-watch-and-fix.md +++ b/workflows/server-release-watch-and-fix.md @@ -20,7 +20,7 @@ Specifies the automated loop that monitors GitHub Actions release runs on `proje ```bash gh run list --workflow=build.yml --limit 3 --json databaseId,status,conclusion,headSha,event ``` -2. Track job-level progression (`build`, `track-refs`, `release`). +2. Track job-level progression (`build`, `installer-test`, `release`). 3. If run fails or is cancelled, fetch failed job logs immediately: ```bash gh run view --job= --log-failed