-
Notifications
You must be signed in to change notification settings - Fork 3
ci: guard release consistency at merge time #747
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
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 |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| {} |
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
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 |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| name: Registry drift | ||
|
|
||
| # Manifests can advance even when publishing fails. Tags and GitHub Releases | ||
| # already wait for npm confirmation; this check covers the default branch. | ||
|
|
||
| on: | ||
| schedule: | ||
| - cron: "17 7 * * *" | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: registry-drift | ||
| cancel-in-progress: false | ||
|
|
||
| jobs: | ||
| drift: | ||
| name: Manifests versus registry | ||
| runs-on: ubuntu-latest | ||
| permissions: | ||
| contents: read | ||
| issues: write | ||
| steps: | ||
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | ||
| with: | ||
| ref: ${{ github.event.repository.default_branch }} | ||
| persist-credentials: false | ||
|
|
||
| - uses: actions/setup-node@820762786026740c76f36085b0efc47a31fe5020 # v7.0.0 | ||
| with: | ||
| node-version: "22" | ||
|
|
||
| - name: Compare every published manifest against npm | ||
| id: compare | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| exceptions="$(cat .github/registry-drift-exceptions.json)" | ||
| jq -e 'type == "object" and all(.[]; type == "string" and test("\\S"))' <<<"$exceptions" >/dev/null | ||
|
|
||
| missing=() | ||
| for manifest in js/packages/*/package.json; do | ||
| if [ "$(jq -r '.private // false' "${manifest}")" = "true" ]; then | ||
| continue | ||
| fi | ||
| name="$(jq -er '.name | select(type == "string" and length > 0)' "$manifest")" | ||
| version="$(jq -er '.version | select(type == "string" and length > 0)' "$manifest")" | ||
| reason="$(jq -r --arg target "${name}@${version}" '.[$target] // empty' <<<"$exceptions")" | ||
| if [ -n "$reason" ]; then | ||
| echo "${name}@${version} is intentionally unpublished: ${reason}" | ||
| continue | ||
| fi | ||
|
|
||
| if result="$(npm view "${name}@${version}" version --json --fetch-retries=2 --fetch-timeout=10000 2>"${RUNNER_TEMP}/npm-view-error.log")"; then | ||
| echo "${name}@${version} is on npm." | ||
| elif [ "$(jq -r '.error.code // empty' <<<"$result" 2>/dev/null)" = E404 ]; then | ||
| echo "${name}@${version} is NOT on npm." | ||
| missing+=("${name}@${version}") | ||
| else | ||
| cat "${RUNNER_TEMP}/npm-view-error.log" >&2 | ||
| echo "$result" >&2 | ||
| echo "::error::Could not query npm for ${name}@${version}; no drift issue will be changed." | ||
| exit 1 | ||
| fi | ||
| done | ||
|
|
||
| if [ "${#missing[@]}" -eq 0 ]; then | ||
| echo "drift=false" >> "$GITHUB_OUTPUT" | ||
| exit 0 | ||
| fi | ||
|
|
||
| { | ||
| echo "drift=true" | ||
| echo "report<<EOF" | ||
| printf '%s\n' "${missing[@]}" | ||
| echo "EOF" | ||
| } >> "$GITHUB_OUTPUT" | ||
|
|
||
| - name: Report the drift | ||
| if: steps.compare.outputs.drift == 'true' | ||
| env: | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| GH_REPO: ${{ github.repository }} | ||
| REPORT: ${{ steps.compare.outputs.report }} | ||
| WORKFLOW_URL: ${{ github.server_url }}/${{ github.repository }}/actions/workflows/registry-drift.yml | ||
| TITLE: "Release drift: published versions do not match the default branch" | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| # Paginate the issue listing without interpreting the title as search | ||
| # syntax. Keep one report and avoid daily duplicate comments. | ||
| issues="$(gh api --paginate "repos/${GH_REPO}/issues?state=open&per_page=100")" | ||
| existing="$(jq -sr --arg title "$TITLE" 'add | map(select(.pull_request == null and .title == $title)) | .[0].number // empty' <<<"$issues")" | ||
|
|
||
| body_file="${RUNNER_TEMP}/registry-drift.md" | ||
| printf 'The default branch declares package versions the registry does not serve.\n\n```\n%s\n```\n\nCheck the most recent `Release` run for a failed publish or an omitted target. Document deliberately unpublished versions in `.github/registry-drift-exceptions.json` with a reason.\n\n[Registry drift runs](%s)\n' "$REPORT" "$WORKFLOW_URL" > "$body_file" | ||
|
|
||
| if [ -n "${existing}" ]; then | ||
| current_body="$(jq -sr --argjson number "$existing" 'add | .[] | select(.number == $number) | .body' <<<"$issues")" | ||
| if [ "$current_body" != "$(cat "$body_file")" ]; then | ||
| gh issue edit "$existing" --body-file "$body_file" | ||
| fi | ||
| else | ||
| gh issue create --title "${TITLE}" --body-file "$body_file" | ||
| fi | ||
|
|
||
| echo "::error::Published versions do not match the default branch." | ||
| exit 1 |
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
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
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
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.