Skip to content

feat(ci): extract Knip and Jest into reusable workflows - #87

Closed
Chaly-87 wants to merge 1 commit into
ubiquity-os:developmentfrom
Chaly-87:feat/reusable-knip-jest-workflows
Closed

Chaly-87 wants to merge 1 commit into
ubiquity-os:developmentfrom
Chaly-87:feat/reusable-knip-jest-workflows

Conversation

@Chaly-87

@Chaly-87 Chaly-87 commented Dec 1, 2026

Copy link
Copy Markdown

Closes #13.

Why

The Knip and Jest workflows are copy-pasted into every repository that inherits from this template, and they have already drifted:

plugin-template ts-template
checkout v5 v4, and master in jest
setup-bun v2 v1 and v2
knip JSON knip --reporter json knip-ci

Every copy is a place a fix has to be applied again. Fixing the workflow in the template does not reach the repositories that already inherited from it.

What

Two new reusable workflows, workflow_call only:

  • .github/workflows/knip-reusable.yml
  • .github/workflows/jest-reusable.yml

Inputs cover exactly the drift listed above: package-manager (bun/yarn), node-version, working-directory, knip-command, knip-json-command, test-command, dashboard-file, frozen-lockfile, checkout-ref, fetch-depth, artifact names, plus pr-number for dispatch runs.

This repository now consumes them through its own callers, which shrink to the job declaration and its inputs. The caller workflow names are unchanged (Knip, Run Jest testing suite) so knip-reporter.yml, which listens on workflow_run: workflows: ["Knip"], keeps receiving the knip-results artifact from the same run.

Bug fixed on the way

The Knip job wrote github.event.number into pr-number.txt. That value is empty on workflow_dispatch, so the reporter received an empty PR number. The number is now resolved once, exposed as a job output, and can be passed explicitly through the pr-number input.

Behaviour that is deliberately preserved

  • plugin-template installs without a frozen lockfile (as before); the Jest job keeps --frozen-lockfile.
  • Jest still gets NODE_ENV=test and fetch-depth: 0.
  • The Knip JSON report is still only produced and uploaded when Knip fails.
  • Permissions are narrowed to contents: read + actions: write, replacing write-all.

Verification (local, on this branch)

  • bun x prettier@3.6.2 --check on all four files: clean (the six other workflow files already fail this on development and are untouched here).
  • YAML parsed with js-yaml.
  • bun install then bun run test: 5/5 tests pass, coverage 78.78% statements, dashboard generated.
  • bun run knip: exit 0.
  • The workflows themselves run on this PR (Knip and Jest jobs), which is the real end-to-end check.

Migration for consumers

Any repository can replace its copy with:

jobs:
  knip:
    uses: ubiquity-os/plugin-template/.github/workflows/knip-reusable.yml@development
    with:
      package-manager: bun

ubiquity/ts-template is the immediate next consumer; I can open that PR separately once this lands, to keep each change reviewable on its own.

No runtime code is touched; only .github/workflows/.

The Knip and Jest workflows were copy-pasted into every repository that
inherits from this template, and they drifted: checkout v4 vs v5, setup-bun
v1 vs v2, and two different ways of producing knip-results.json.

Both are now workflow_call workflows with explicit inputs for the package
manager, Node version, working directory, script names and lockfile policy.
This repository consumes them through its own callers, so knip-reporter keeps
receiving its artifact under the same workflow name.

Also fixes the PR number written by the Knip job: github.event.number is empty
on workflow_dispatch, so the value is now resolved once and exposed as an
output, with an explicit input for callers that know the number.

Refs: ubiquity-os#13
@coderabbitai

coderabbitai Bot commented Dec 1, 2026

Copy link
Copy Markdown

Important

  • Trigger review

This repository does not receive automatic reviews because it has fewer than 10 stars.

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: c5c291cd-9abf-4893-b612-435abd7c1173
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

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.

Make Knip and Jest workflows reusable

1 participant