-
Notifications
You must be signed in to change notification settings - Fork 355
Upgrade test workflow: release-created trigger, prerelease coverage, and failure conclusion/issue flow #27372
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+98
−20
Merged
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -2,13 +2,14 @@ name: Extension Upgrade Test | |||||
|
|
||||||
| on: | ||||||
| workflow_dispatch: {} | ||||||
| release: | ||||||
| types: [created] | ||||||
| pull_request: | ||||||
| paths: | ||||||
| - 'pkg/cli/update_extension_check.go' | ||||||
| - '.github/workflows/upgrade-test.yml' | ||||||
|
|
||||||
| permissions: | ||||||
| contents: read | ||||||
| permissions: {} | ||||||
|
|
||||||
| jobs: | ||||||
| upgrade-path-test: | ||||||
|
|
@@ -23,35 +24,41 @@ jobs: | |||||
| os: [ubuntu-latest, macos-latest, windows-latest] | ||||||
| env: | ||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
| VERSION_REGEX: 'v[0-9]+\.[0-9]+\.[0-9]+(-[0-9A-Za-z.-]+)?' | ||||||
| steps: | ||||||
| - name: Checkout code | ||||||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | ||||||
|
|
||||||
| - name: Find two most recent stable releases | ||||||
| - name: Find target and previous releases | ||||||
| id: releases | ||||||
| shell: bash | ||||||
| run: | | ||||||
| # Use /releases/latest to get n (mirrors getLatestRelease() logic: non-prerelease only). | ||||||
| LATEST=$(gh api repos/github/gh-aw/releases/latest --jq '.tag_name') | ||||||
|
|
||||||
| # Get the second most recent non-draft, non-prerelease release (n-1). | ||||||
| # per_page=50 is ample headroom given this project's release cadence. | ||||||
| PREVIOUS=$(gh api "repos/github/gh-aw/releases?per_page=50" \ | ||||||
| --jq '[.[] | select(.prerelease == false and .draft == false)][1].tag_name') | ||||||
| # Include prereleases too; /releases/latest only returns non-prerelease releases. | ||||||
| # For release-created events, use that exact tag as the upgrade target. | ||||||
| if [ "${{ github.event_name }}" = "release" ]; then | ||||||
| TARGET="${{ github.event.release.tag_name }}" | ||||||
| PREVIOUS=$(gh api "repos/github/gh-aw/releases?per_page=50" \ | ||||||
| --jq --arg target "$TARGET" '[.[] | select(.draft == false and .tag_name != $target)][0].tag_name') | ||||||
| else | ||||||
| TARGET=$(gh api "repos/github/gh-aw/releases?per_page=50" \ | ||||||
| --jq '[.[] | select(.draft == false)][0].tag_name') | ||||||
| PREVIOUS=$(gh api "repos/github/gh-aw/releases?per_page=50" \ | ||||||
| --jq '[.[] | select(.draft == false)][1].tag_name') | ||||||
| fi | ||||||
|
|
||||||
| if [ -z "$LATEST" ] || [ -z "$PREVIOUS" ] || [ "$LATEST" = "null" ] || [ "$PREVIOUS" = "null" ]; then | ||||||
| echo "❌ Could not find two stable releases (latest=$LATEST, previous=$PREVIOUS)" | ||||||
| if [ -z "$TARGET" ] || [ -z "$PREVIOUS" ] || [ "$TARGET" = "null" ] || [ "$PREVIOUS" = "null" ]; then | ||||||
| echo "❌ Could not find two releases (target=$TARGET, previous=$PREVIOUS)" | ||||||
| exit 1 | ||||||
| fi | ||||||
| if [ "$LATEST" = "$PREVIOUS" ]; then | ||||||
| echo "❌ Only one stable release found; cannot test upgrade path" | ||||||
| if [ "$TARGET" = "$PREVIOUS" ]; then | ||||||
| echo "❌ Only one release found; cannot test upgrade path" | ||||||
| exit 1 | ||||||
| fi | ||||||
|
|
||||||
| echo "latest=$LATEST" >> "$GITHUB_OUTPUT" | ||||||
| echo "latest=$TARGET" >> "$GITHUB_OUTPUT" | ||||||
| echo "previous=$PREVIOUS" >> "$GITHUB_OUTPUT" | ||||||
| echo "Latest stable: $LATEST" | ||||||
| echo "Previous stable: $PREVIOUS" | ||||||
| echo "Target release: $TARGET" | ||||||
| echo "Previous release: $PREVIOUS" | ||||||
|
|
||||||
| - name: Install previous version (n-1) | ||||||
| shell: bash | ||||||
|
|
@@ -61,8 +68,8 @@ jobs: | |||||
| echo "Installing gh-aw $PREVIOUS ..." | ||||||
| gh extension install github/gh-aw --pin "$PREVIOUS" --force | ||||||
|
|
||||||
| # Extract version string (stable releases always have the simple vX.Y.Z form). | ||||||
| INSTALLED=$(gh aw version 2>&1 | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1) | ||||||
| # Extract version string (supports stable and prerelease tags). | ||||||
| INSTALLED=$(gh aw version 2>&1 | grep -oE "$VERSION_REGEX" | head -1) | ||||||
| echo "Installed: $INSTALLED" | ||||||
| [ "$INSTALLED" = "$PREVIOUS" ] || { echo "❌ Expected $PREVIOUS, got $INSTALLED"; exit 1; } | ||||||
| echo "✅ n-1 installed: $INSTALLED" | ||||||
|
|
@@ -85,8 +92,79 @@ jobs: | |||||
| env: | ||||||
| LATEST: ${{ steps.releases.outputs.latest }} | ||||||
| run: | | ||||||
| INSTALLED=$(gh aw version 2>&1 | grep -oE 'v[0-9]+\.[0-9]+\.[0-9]+' | head -1) | ||||||
| INSTALLED=$(gh aw version 2>&1 | grep -oE "$VERSION_REGEX" | head -1) | ||||||
| echo "Installed: $INSTALLED" | ||||||
| echo "Expected: $LATEST" | ||||||
| [ "$INSTALLED" = "$LATEST" ] || { echo "❌ Version mismatch: got $INSTALLED, expected $LATEST"; exit 1; } | ||||||
| echo "✅ Upgrade succeeded: $INSTALLED" | ||||||
|
|
||||||
| conclusion: | ||||||
| name: Conclusion | ||||||
| if: always() | ||||||
| needs: | ||||||
| - upgrade-path-test | ||||||
| runs-on: ubuntu-latest | ||||||
| permissions: | ||||||
| actions: read | ||||||
| contents: read | ||||||
| issues: write | ||||||
| env: | ||||||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||||||
| UPGRADE_JOB_NAME_PREFIX: "Extension upgrade on " | ||||||
| steps: | ||||||
| - name: Collect upgrade test outcomes | ||||||
| id: outcomes | ||||||
| shell: bash | ||||||
| run: | | ||||||
| set -euo pipefail | ||||||
|
|
||||||
| FAILURES=$( | ||||||
| gh api "repos/${{ github.repository }}/actions/runs/${{ github.run_id }}/jobs?per_page=100" \ | ||||||
| --jq --arg job_prefix "$UPGRADE_JOB_NAME_PREFIX" '.jobs | ||||||
| | map(select(.name | startswith($job_prefix))) | ||||||
| | map(select(.conclusion != "success")) | ||||||
| | map("\(.name): \(.conclusion // "unknown")") | ||||||
| | join("\n")' | ||||||
| ) | ||||||
|
|
||||||
| if [ -n "$FAILURES" ]; then | ||||||
| echo "has_failures=true" >> "$GITHUB_OUTPUT" | ||||||
| { | ||||||
| echo "failures<<EOF" | ||||||
| echo "$FAILURES" | ||||||
| echo "EOF" | ||||||
| } >> "$GITHUB_OUTPUT" | ||||||
| { | ||||||
| echo "## ❌ Extension upgrade failures" | ||||||
| echo | ||||||
| echo '```text' | ||||||
| echo "$FAILURES" | ||||||
| echo '```' | ||||||
| } >> "$GITHUB_STEP_SUMMARY" | ||||||
| else | ||||||
| echo "has_failures=false" >> "$GITHUB_OUTPUT" | ||||||
| echo "## ✅ Extension upgrade tests passed" >> "$GITHUB_STEP_SUMMARY" | ||||||
| fi | ||||||
|
|
||||||
| - name: Create issue for release failures | ||||||
| if: ${{ steps.outcomes.outputs.has_failures == 'true' && github.event_name == 'release' }} | ||||||
| shell: bash | ||||||
| env: | ||||||
| RELEASE_TAG: ${{ github.event.release.tag_name }} | ||||||
| FAILURES: ${{ steps.outcomes.outputs.failures }} | ||||||
| run: | | ||||||
| RUN_URL="${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}" | ||||||
| TITLE="Extension Upgrade Test failure for release ${RELEASE_TAG}" | ||||||
| BODY=$(cat <<EOF | ||||||
| The extension upgrade workflow failed for release \`${RELEASE_TAG}\`. | ||||||
|
|
||||||
| Run: ${RUN_URL} | ||||||
|
|
||||||
| Failed jobs: | ||||||
| \`\`\`text | ||||||
| ${FAILURES} | ||||||
| \`\`\` | ||||||
| EOF | ||||||
| ) | ||||||
|
|
||||||
| gh issue create --title "$TITLE" --body "$BODY" --label "bug" | ||||||
|
||||||
| gh issue create --title "$TITLE" --body "$BODY" --label "bug" | |
| gh issue create --repo "${{ github.repository }}" --title "$TITLE" --body "$BODY" --label "bug" |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
on: release: types: [created]will also run for draft releases. Since the workflow later assumes the target tag is installable, draft releases are likely to fail/spam issues. Consider switching the trigger totypes: [published](still includes prereleases) or add a job-level guard likeif: github.event.release.draft == falsefor the release path.