Check #81
Workflow file for this run
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
| name: Check | |
| on: | |
| pull_request: | |
| # The `main` ruleset merges through a merge queue, which validates on a temporary merge-group ref; | |
| # without this trigger no checks run there and the queue waits out its check-response timeout. | |
| merge_group: | |
| push: | |
| branches: [main, release] | |
| jobs: | |
| check: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| # moon resolves a merge base against the PR's base ref to compute touched files, which a | |
| # shallow clone cannot do — the base branch is not in the object store. | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup | |
| # Formatting first: it is the cheapest check and a single unformatted file fails the job. | |
| - run: pnpm run format-check | |
| - run: moon run :lint | |
| # A publishable plugin that npm has never seen fails `changeset publish` on its first-ever | |
| # publish, taking every other plugin in that release with it. | |
| - name: Check publishable plugins exist on npm | |
| run: pnpm run check-packages-published | |
| # `:build` is the npm library (dist/lib + dist/types); `:bundle` is the registry bundle | |
| # (out/, incl. manifest.json and the resolved `dependencies` SDK-compat snapshot). | |
| - run: moon run :build | |
| - run: moon run :bundle | |
| # Separate from `check` so a growing suite does not extend the static checks, and so a red test is | |
| # distinguishable from a red build at a glance. The `test` moon task declares no build dependency — | |
| # specs import from src — so this runs in parallel with `check`. | |
| test: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - uses: ./.github/actions/setup | |
| - run: moon run :test | |
| # Advisory (NOT a gate): when a PR changes plugin source but has no `.changeset/*.md`, post/update | |
| # a single sticky comment; remove it once a changeset is added. A change that needs no release just | |
| # omits the changeset — no empty changeset is required. | |
| changeset-reminder: | |
| if: >- | |
| github.event_name == 'pull_request' && | |
| github.event.pull_request.head.repo.full_name == github.repository | |
| runs-on: ubuntu-latest | |
| permissions: | |
| contents: read | |
| pull-requests: write | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| persist-credentials: false | |
| - name: Detect missing changeset | |
| id: detect | |
| env: | |
| CHANGESET_BASE_REF: ${{ github.event.pull_request.base.sha }} | |
| run: node scripts/check-changeset.mjs | |
| - name: Post or remove reminder comment | |
| uses: actions/github-script@v7 | |
| env: | |
| MISSING: ${{ steps.detect.outputs.missing }} | |
| PACKAGES: ${{ steps.detect.outputs.packages }} | |
| with: | |
| script: | | |
| const marker = '<!-- changeset-reminder -->'; | |
| const missing = process.env.MISSING === 'true'; | |
| const packages = process.env.PACKAGES || ''; | |
| const { owner, repo } = context.repo; | |
| const issue_number = context.payload.pull_request.number; | |
| const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number }); | |
| const existing = comments.find((comment) => comment.body && comment.body.includes(marker)); | |
| if (missing) { | |
| const body = [ | |
| marker, | |
| '### 🦋 No changeset found', | |
| '', | |
| 'This PR changes plugin source but has no `.changeset/*.md`.', | |
| packages ? `Affected: ${packages}` : '', | |
| '', | |
| '- If the change is consumer-relevant (worth a changelog entry), add a `.changeset/<slug>.md`.', | |
| "- If it isn't changelog-relevant (chore / refactor / internal), you can ignore this — the code still ships with the next release.", | |
| ].filter(Boolean).join('\n'); | |
| if (existing) { | |
| await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body }); | |
| } else { | |
| await github.rest.issues.createComment({ owner, repo, issue_number, body }); | |
| } | |
| } else if (existing) { | |
| await github.rest.issues.deleteComment({ owner, repo, comment_id: existing.id }); | |
| } |