🐛 Replace unfinished Alpha builds on push
Cancel older builds only for new automatic updates. Resolve stale dispatches before taking the build lock and check published versions inside it so queued runs skip work that already finished.
This commit is contained in:
1 parent
3cb5384b33
commit
add539cd0f
2 files changed
+54
-19
No files matched your search
@@ -109,4 +109,4 @@ jobs:
|
||||
RUNTIME_COMMIT: ${{ needs.sync.outputs.runtime_commit }}
|
||||
run: |
|
||||
gh workflow run runtime-preview.yml --repo "$GITHUB_REPOSITORY" --ref master \
|
||||
-f upstream_commit="$RUNTIME_COMMIT" -f publish=true
|
||||
-f upstream_commit="$RUNTIME_COMMIT" -f publish=true -f supersede=true
|
||||
@@ -17,6 +17,10 @@ on:
|
||||
description: "Publish the verified preview as a GitHub prerelease"
|
||||
type: boolean
|
||||
default: true
|
||||
supersede:
|
||||
description: "Replace older builds for an automatic maintenance-branch push"
|
||||
type: boolean
|
||||
default: false
|
||||
rebuild:
|
||||
description: "Build a new patch revision (runtime-<commit>-pN) even if this upstream commit is already released"
|
||||
type: boolean
|
||||
@@ -25,10 +29,6 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
|
||||
concurrency:
|
||||
group: build-runtime
|
||||
queue: max
|
||||
|
||||
env:
|
||||
UPSTREAM_URL: ${{ github.server_url }}/${{ github.repository }}.git
|
||||
UPSTREAM_BRANCH: codex/intel-vm-suspend
|
||||
@@ -39,22 +39,49 @@ jobs:
|
||||
outputs:
|
||||
commit: ${{ steps.r.outputs.commit }}
|
||||
skip: ${{ steps.r.outputs.skip }}
|
||||
suffix: ${{ steps.r.outputs.suffix }}
|
||||
steps:
|
||||
- id: r
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
WANT: ${{ inputs.upstream_commit }}
|
||||
REBUILD: ${{ github.event_name == 'push' || inputs.rebuild }}
|
||||
CURRENT_ONLY: ${{ inputs.supersede }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
git clone -q --filter=blob:none --no-checkout --single-branch --branch "$UPSTREAM_BRANCH" "$UPSTREAM_URL" up
|
||||
commit="$(git -C up rev-parse --verify "${WANT:-HEAD}^{commit}")"
|
||||
git -C up cat-file -e "$commit:reims-go-runtime.json"
|
||||
echo "commit=$commit" >> "$GITHUB_OUTPUT"
|
||||
if [[ "$CURRENT_ONLY" == true && "$commit" != "$(git -C up rev-parse HEAD)" ]]; then
|
||||
echo "Skipping superseded runtime commit $commit"
|
||||
echo "skip=true" >> "$GITHUB_OUTPUT"
|
||||
fi
|
||||
|
||||
build:
|
||||
needs: resolve
|
||||
if: needs.resolve.outputs.skip != 'true'
|
||||
concurrency:
|
||||
group: build-runtime
|
||||
cancel-in-progress: ${{ github.event_name == 'push' || inputs.supersede }}
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 150
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
# Check released commits inside the build lock, including queued runs.
|
||||
- name: Plan Alpha release
|
||||
id: plan
|
||||
shell: bash
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
RUNTIME_COMMIT: ${{ needs.resolve.outputs.commit }}
|
||||
REBUILD: ${{ github.event_name == 'push' || inputs.rebuild }}
|
||||
run: |
|
||||
set -euo pipefail
|
||||
commit="$RUNTIME_COMMIT"
|
||||
# Already published (alpha or stable) under any short-hash length or -pN revision?
|
||||
max_rev=0
|
||||
for tag in $(gh release list -R "$GITHUB_REPOSITORY" --limit 1000 --json tagName -q '.[].tagName' | grep '^runtime-' || true); do
|
||||
tags=$(gh release list -R "$GITHUB_REPOSITORY" --limit 1000 --json tagName,isDraft -q '.[] | select(.isDraft | not) | .tagName')
|
||||
for tag in $tags; do
|
||||
[[ "$tag" == runtime-* ]] || continue
|
||||
rest="${tag#runtime-}"
|
||||
base="${rest%%-p*}"
|
||||
case "$commit" in
|
||||
@@ -85,19 +112,13 @@ jobs:
|
||||
echo "skip=$skip" >> "$GITHUB_OUTPUT"
|
||||
echo "suffix=$suffix" >> "$GITHUB_OUTPUT"
|
||||
|
||||
build:
|
||||
needs: resolve
|
||||
if: needs.resolve.outputs.skip != 'true'
|
||||
runs-on: windows-latest
|
||||
timeout-minutes: 150
|
||||
permissions:
|
||||
contents: write
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
with:
|
||||
persist-credentials: false
|
||||
|
||||
- name: Setup MSYS2 CLANG64
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
id: msys2
|
||||
uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
@@ -114,6 +135,7 @@ jobs:
|
||||
mingw-w64-clang-x86_64-python mingw-w64-clang-x86_64-python-pip
|
||||
|
||||
- name: Check out the runtime forks and apply dependency patches
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
id: patches
|
||||
shell: pwsh
|
||||
run: |
|
||||
@@ -156,7 +178,7 @@ jobs:
|
||||
git -C $m2vRepo checkout -q --detach FETCH_HEAD
|
||||
if ($LASTEXITCODE) { throw 'metal2vulkan checkout failed' }
|
||||
$short = (git -C $work rev-parse --short=7 HEAD).Trim()
|
||||
$releaseId = "$short${{ needs.resolve.outputs.suffix }}"
|
||||
$releaseId = "$short${{ steps.plan.outputs.suffix }}"
|
||||
|
||||
# Applies what applies, skips what upstream already has, stops on a
|
||||
# conflict without touching the patch (AGENTS.md rule 4).
|
||||
@@ -190,6 +212,7 @@ jobs:
|
||||
"XDG_CACHE_HOME=$(Join-Path $env:RUNNER_TEMP 'xdg-cache')" >> $env:GITHUB_ENV
|
||||
|
||||
- name: Build upstream runtime in MSYS2 CLANG64
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
shell: msys2 {0}
|
||||
env:
|
||||
REIMS_INSTALL_SKIP_HOST_CHECKS: "1"
|
||||
@@ -207,6 +230,7 @@ jobs:
|
||||
fi
|
||||
|
||||
- name: Package alpha runtime and source archives
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -229,6 +253,7 @@ jobs:
|
||||
-Patches $applied
|
||||
|
||||
- name: Alpha entry gate
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
@@ -239,6 +264,7 @@ jobs:
|
||||
-AppliedPatches @($env:APPLIED_PATCHES -split ',' | Where-Object { $_ })
|
||||
|
||||
- name: Upload alpha artifacts
|
||||
if: steps.plan.outputs.skip != 'true'
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: reims-runtime-win-x64-${{ env.RELEASE_ID }}-alpha
|
||||
@@ -248,13 +274,22 @@ jobs:
|
||||
retention-days: 14
|
||||
|
||||
- name: Publish alpha prerelease (never stable)
|
||||
if: github.event_name == 'push' || github.event_name == 'schedule' || inputs.publish
|
||||
if: steps.plan.outputs.skip != 'true' && (github.event_name == 'push' || github.event_name == 'schedule' || inputs.publish)
|
||||
env:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
CURRENT_ONLY: ${{ github.event_name == 'push' || inputs.supersede }}
|
||||
MERGED: ${{ steps.patches.outputs.merged }}
|
||||
shell: pwsh
|
||||
run: |
|
||||
$ErrorActionPreference = 'Stop'
|
||||
if ($env:CURRENT_ONLY -eq 'true') {
|
||||
$remote = git ls-remote $env:UPSTREAM_URL "refs/heads/$env:UPSTREAM_BRANCH"
|
||||
if ($LASTEXITCODE -or !$remote) { throw 'Could not resolve the runtime maintenance tip' }
|
||||
if (($remote -split '\s+')[0] -ne '${{ needs.resolve.outputs.commit }}') {
|
||||
Write-Host 'Skipping Alpha publication for a superseded runtime commit.'
|
||||
return
|
||||
}
|
||||
}
|
||||
$c = $env:RELEASE_ID
|
||||
$short = $env:SHORT_COMMIT
|
||||
$sourceRepo = $env:UPSTREAM_URL -replace '\.git$', ''
|
||||
|
||||
Reference in new issue
Block a user