Repository navigation
ci: test.yml with a completion check, and PR-based releases with npm trusted publishing - #401
Merged
Merged
Conversation
Replace "Build and test" with test.yml. Its jobs: - Biome runs `biome ci .`, which checks format and lint. - Build runs tsc, then check:pack. - Test runs the unit tests and the Cypress example on Node 22, 24 and 26. It skips draft PRs. - Test completion check fails when any other job failed or was cancelled. Branch protection requires this one job, so the job list can change without editing the ruleset. The old workflow triggered on pushes to '*', which never matches a branch name containing a slash. test.yml runs on pushes to main and on pull requests. Concurrent runs for the same PR cancel each other. check:pack (scripts/check-pack.mts) runs `npm pack --dry-run`. It fails when the tarball lacks `main`, `types`, or any .js or .d.ts file that tsc emitted. Users require `dist/plugin` by path, so every emitted module counts. This check catches both packaging faults fixed in #400: the unpublished types.d.ts and the dist/src/ layout. scripts/ci/build-and-test.sh only ran the steps test.yml now names individually, so it goes. The README badge points at test.yml. Assisted-by: Claude Code:claude-opus-5-5
The old process ran `commit-and-tag-version` from a manual dispatch. It pushed the bump straight to main with a PAT. A `workflow_run` hook then published with a long-lived NPM_TOKEN and created no GitHub release. release.yml replaces both workflows with four jobs: - prepare (push to main) runs `scripts/release.mts prepare`. git-cliff proposes the next version from conventional commits. The script writes it to package.json, prepends a CHANGELOG.md section, and force-pushes release/pact-cypress-adapter behind a draft PR. - dry-run (release PR marked ready) runs `release.mts check`. It fails when the version is already tagged or CHANGELOG.md has no section for it. It then builds and runs check:pack. - tag (release PR merged) tags the merge commit with the version from its package.json. - publish (v* tag) builds, publishes to npm through OIDC trusted publishing in the `npm` environment, and creates the GitHub release from the version's CHANGELOG.md section. The files on the release branch are the release. Once the branch has a commit from anyone but the bot, prepare stops regenerating it and leaves a one-time comment. Hand edits to the version or changelog therefore survive later pushes to main. Closing the PR gets a fresh one. prepare does nothing while package.json's version is untagged. Merging the release PR pushes to main while the tag job is still running. In that window git-cliff measures from the previous tag. With a hand-edited version, it would open a second release PR for a version nobody chose. prepare and tag push with the PACTFLOW_CI_BOT App token. Pushes made with GITHUB_TOKEN start no workflows, so the release PR would get no CI and the tag would never publish. publish skips a version npm already has, so the job can be re-run after a failed GitHub release step. The script and git-cliff config follow pactflow/pact-msw-adapter. The pause on manual edits follows pact-foundation/pact-reference#566. CHANGELOG.md takes git-cliff's header. With the old standard-version header, `git cliff --prepend` wrote a second header above the file. `release.mts notes` also stops at standard-version's `### [x.y.z]` patch headings, so old sections extract cleanly. .versionrc and the commit-and-tag-version dependency are gone. RELEASING.md describes the process and the one-time setup. Assisted-by: Claude Code:claude-opus-5-5
standard-version wrote patch releases as `### [x.y.z]`, one level below minor and major releases. Every release now has a `## ` heading, so a release's section runs to the next `## ` heading. Only the heading levels change. Assisted-by: Claude Code:claude-opus-5-5
With every CHANGELOG.md release under a `## ` heading, changelogSection ends a section at the next `## ` heading alone. The release script has no unit tests. It is small and runs on every push to main. Running `notes`, `check`, `tag --dry-run` and `prepare --dry-run` against this repository's history verified it. The test file was deleted in the previous commit, which staged it by mistake. Assisted-by: Claude Code:claude-opus-5-5
Build now skips draft PRs, like the Node test matrix. A draft PR runs only the Biome check. The ready_for_review trigger runs Build and the tests once the PR is marked ready. Pushes to main run every job. Skipped jobs count as passing for Test completion check. A draft cannot merge, so the sentinel's green result on a draft gates nothing. Assisted-by: Claude Code:claude-opus-5-5
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Goal
Split CI into one
test.ymlbehind a single required status, and release through a draft PR:main.Sequence
ci: split CI into test.yml jobs behind a completion checkbiome ci .), Build (tscpluscheck:pack), and Test (unit tests and the Cypress example on Node 22, 24 and 26).ready_for_review) and on pushes tomain.Test completion checkfails when any job failed or was cancelled. The branch rule requires this one status.push: branches: '*'trigger never matched a branch name with a slash.test.ymlruns on pushes tomainand on pull requests.check:packfails when the npm tarball lacksmain,types, or any.jsor.d.tsfile underdist/. It catches both packaging faults fixed in chore(deps): Cypress 16 and TypeScript 7, plus build and release fixes #400.ci: release through a draft release PR, with npm trusted publishingprepareruns on each push tomain. git-cliff proposes the version.scripts/release.mtswritespackage.jsonandCHANGELOG.mdand force-pushesrelease/pact-cypress-adapterbehind a draft PR.preparestops regenerating it and comments once.preparedoes nothing while the current version is untagged. That covers the gap between the merge and the tag.Verify releaseruns on the ready release PR. It fails when the version is already tagged orCHANGELOG.mdhas no section for it.tagtags the merge commit with the App token. Pushes made withGITHUB_TOKENstart no workflows.publishbuilds, runsnpm publishthrough OIDC in thenpmenvironment, and creates the GitHub release from the version'sCHANGELOG.mdsection. It skips a version npm already has, so a failed run can be re-run.release.yaml,publish.yaml,.versionrcandcommit-and-tag-version. AddsRELEASING.md.Alternatives weighed
chore/move-to-release-pleasebranch. Rejected. It regenerates the release PR on every push, which discards hand edits to the changelog or version.release.tsunchanged. Its script andcliff.tomlare the base here, with three additions:main's headcheckandnotescommandsscripts/ci/build-and-test.sh. Rejected.test.ymlnames each step, and the script had no other caller.Verification
biome ci ., the 13 unit tests, a cleantscbuild,check:pack, and actionlint all pass.release.mts prepare --dry-runon currentmainproposes v1.4.0, because afeat(config)commit has landed sincev1.3.0. It writes one newCHANGELOG.mdsection under a single header.v1.3.0,release.mts checkfails as expected andtag --dry-runreports that the tag exists.release.mts notesprints only the requested section forv1.3.0and1.2.6. The second-to-last commit raises standard-version's### [x.y.z]patch headings to##, so every release ends at the next##heading.The App-token and OIDC paths can only run on GitHub. They first run on the first release PR.
Setup before the first release
PACTFLOW_CI_BOTApp on this repository, and makevars.PACTFLOW_CI_BOT_APP_IDandsecrets.PACTFLOW_CI_BOT_PRIVATE_KEYavailable to it.release/pact-cypress-adapterandv*tags. RequireTest completion checkonmain.@pactflow/pact-cypress-adapter: repositorypactflow/pact-cypress-adapter, workflowrelease.yml, environmentnpm.npmenvironment.NPM_TOKENandGH_TOKENsecrets.The first release PR's changelog lists every commit since 2022. Trim it on the PR before merging.