Skip to content

ci: reusable changeset-hygiene workflow#39

Merged
turnipdabeets merged 3 commits into
mainfrom
feat/changeset-hygiene
May 4, 2026
Merged

ci: reusable changeset-hygiene workflow#39
turnipdabeets merged 3 commits into
mainfrom
feat/changeset-hygiene

Conversation

@turnipdabeets
Copy link
Copy Markdown
Contributor

Summary

Adds a reusable workflow that any pnpm/changesets repo in the PostHog org can call to surface changeset coverage issues as a sticky PR comment. Always exits 0 — the comment is informational, never gates merging.

Why

A real bug in posthog-android (#491 → #507): a PR modified code in posthog-android-gradle-plugin/ but the changeset declared posthog-android (the SDK package). The mistake silently slipped through because the directory name and the SDK package name look almost identical. The wrong package got bumped, the actual change never released, and a corrective changeset PR was needed.

This workflow catches that class of mistake at PR-time. It also catches three other patterns:

Failure mode Caught?
Changeset declares a package the PR didn't modify
PR modifies a package no changeset declares (the #491 case)
Changeset declares a name not in the workspace (typo)
PR modifies workspace package code but adds no changeset at all

How it works

  • Triggered via workflow_call so each consumer repo has a tiny ~6-line caller that delegates here.
  • Uses pnpm m ls --json --depth=-1 to discover workspace packages — handles globs, exclusions, and the catalog (e.g., posthog-js's packages/* + tooling/* + !**/playground/**).
  • Diffs against the merge base, prefix-matches each changed file to its package directory, and parses the YAML frontmatter of any .changeset/*.md added or modified in the PR.
  • Posts a single sticky comment under the marker <!-- changeset-hygiene -->, with a collapsible <details open> body. Auto-deletes when a follow-up push resolves the issue.
  • Comment-management uses actions/github-script (no third-party deps) — same pattern as posthog-js's existing check-posthog-major-version.yml.

Caller setup (~6 lines)

name: 'Changeset hygiene'
on:
  pull_request:
    branches: [main]
    types: [opened, synchronize, reopened]
jobs:
  check:
    uses: PostHog/.github/.github/workflows/changeset-hygiene.yml@main

Test plan

Out of scope

Major-version-bump policies (e.g., posthog-js's autoload constraint blocking posthog-js: major) stay in each repo's existing workflow. This shared workflow handles coverage only.

After merge

Caller PRs in posthog-android and posthog-js will update their uses: from @feat/changeset-hygiene to @main and drop the script-ref input.

Reusable workflow + script that any pnpm/changesets monorepo can call to
surface changeset issues as a sticky PR comment. Never blocks the PR —
output is informational. Detects:

- packages modified but not declared in any changeset
- changesets declaring packages that don't exist in the workspace (typo)
- changesets declaring packages with no source changes
- source modified but no changeset added at all
- (opt-in via forbidden-major-packages input) major bumps for
  autoload-style packages where breaking changes break consumers
@turnipdabeets turnipdabeets requested a review from a team as a code owner May 4, 2026 16:53
@turnipdabeets turnipdabeets requested a review from a team May 4, 2026 16:54
turnipdabeets added a commit to PostHog/posthog-android that referenced this pull request May 4, 2026
…kflow

Removes the local 169-line script and 85-line workflow in favor of a tiny
22-line caller delegating to PostHog/.github's reusable changeset-hygiene
workflow (PostHog/.github#39). Same behavior, single source of truth across
SDKs.

Pinned to feat/changeset-hygiene while PostHog/.github#39 is open; will
update to @main once that merges.
@turnipdabeets turnipdabeets enabled auto-merge May 4, 2026 17:01
@Piccirello Piccirello disabled auto-merge May 4, 2026 17:03
- name: Setup Node
uses: actions/setup-node@v6
with:
node-version: '22'
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: use node 24 since it's the current LTS?

@turnipdabeets turnipdabeets merged commit d2e7c95 into main May 4, 2026
12 of 13 checks passed
@turnipdabeets turnipdabeets deleted the feat/changeset-hygiene branch May 4, 2026 17:07
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.

3 participants