Skip to content

ci: add changeset validation to pull request workflow#325

Merged
geoquant merged 4 commits intocloudflare:mainfrom
geoquant:geoquant/changeset-pipeline
Mar 27, 2026
Merged

ci: add changeset validation to pull request workflow#325
geoquant merged 4 commits intocloudflare:mainfrom
geoquant:geoquant/changeset-pipeline

Conversation

@geoquant
Copy link
Copy Markdown
Collaborator

Summary

Adds a changeset job to the pull request workflow that runs the same validate-kumo-changeset.ts script used by the lefthook pre-push hook. This ensures changeset validation cannot be bypassed with --no-verify or LEFTHOOK=0.

Problem

The changeset validation currently only runs as a local pre-push hook via lefthook. Contributors can bypass it with:

  • git push --no-verify
  • LEFTHOOK=0 git push
  • LEFTHOOK_EXCLUDE=validate-changeset git push

This means PRs can be opened without the required changeset for packages/kumo/ changes.

Solution

Add a CI job that runs the same validation script (ci/scripts/validate-kumo-changeset.ts) in the GitHub Actions pull request workflow. The script already handles both local and CI contexts (GITHUB_BASE_REF, GITHUB_EVENT_NAME, etc.).

The job:

  • Uses fetch-depth: 0 for full git history (needed for base branch diff)
  • Runs independently of the build job (no artifact dependency needed)
  • Has a 2-minute timeout (lightweight check)
  • Keeps the local pre-push hook in place as a fast feedback loop for developers

Adds a 'changeset' job to pullrequest.yml that runs the same
validate-kumo-changeset.ts script used by the lefthook pre-push hook.
This ensures changeset validation cannot be bypassed with --no-verify
or LEFTHOOK=0.

The job:
- Uses fetch-depth: 0 for full git history (needed for base branch diff)
- Runs independently of the build job (no artifact dependency)
- Reuses the existing CI-aware validation script
- 2 minute timeout (lightweight check)
@pkg-pr-new
Copy link
Copy Markdown

pkg-pr-new bot commented Mar 27, 2026

npm i https://pkg.pr.new/@cloudflare/kumo@325

commit: 4b0c183

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 27, 2026

Docs Preview

View docs preview

Commit: 4b0c183

GITHUB_HEAD_REF is a branch name (e.g. 'geoquant/changeset-pipeline'),
not a commit SHA. After actions/checkout it doesn't exist as a local
git ref — especially for fork PRs. This causes the git diff to fail,
which makes the script assume kumo changes exist and then fail because
no changeset is found.

Clearing GITHUB_HEAD_REF lets the script fall through to GITHUB_SHA
(always a valid commit) for the diff comparison.
GITHUB_HEAD_REF is a branch name (e.g. 'geoquant/changeset-pipeline')
that doesn't exist as a local git ref for fork PRs. The previous env
override approach didn't work — GitHub's GITHUB_* vars can't be
overridden at the step level.

Fix: add resolveHeadRef() that validates each candidate ref with
'git rev-parse --verify' before using it. Falls back through:
GITHUB_HEAD_REF → GITHUB_SHA → HEAD

This ensures the git diff command always uses a valid local ref.
@geoquant geoquant merged commit 7ad330e into cloudflare:main Mar 27, 2026
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants