Skip to content

Phase 4: hybrid shim for bids-validation + pr-merge (version-check stays per-repo) - #611

Merged
neuromechanist merged 2 commits into
feature/issue-601-epic-centralize-workflowsfrom
feature/issue-610-phase4-shims
May 23, 2026
Merged

neuromechanist merged 2 commits into
feature/issue-601-epic-centralize-workflowsfrom
feature/issue-610-phase4-shims

Conversation

@neuromechanist

Copy link
Copy Markdown
Contributor

Closes #610. Phase 4 of epic #601.

Summary

PR-triggered workflows can't be relocated directly because GitHub's pull_request events fire only in the repo where the PR lives. Phase 4 takes a hybrid approach:

  • bids-validation.yml: ~30-line shim that dispatches repository_dispatch[run-bids-validation] at nemarDatasets/.github. The central workflow (nemarDatasets/.github#12) runs the deno validator and posts results back as a GitHub check-run on the dataset repo so the PR reviewer still sees the check.
  • pr-merge.yml (create-release job): ~25-line shim that dispatches repository_dispatch[run-pr-merge] at .github. The central workflow cuts the tag + release. The cleanup-staging job stays inline because it's AWS-only.
  • version-check.yml: stays per-repo. Pure JSON math, low churn, shimming saves nothing. Documented as the per-repo endstate.

Pairs with nemarDatasets/.github#12.

Changes

  • backend/src/services/github.ts — bidsValidation and prMerge template strings replaced with shim variants. ~150 lines removed, ~85 added (net reduction). versionCheck unchanged.
  • test/workflow-yaml.test.ts:
    • "migrated templates mint App tokens" renamed/rescoped to "shim templates mint App tokens" — pins the new contract (App token scoped to .github, no secrets.GITHUB_TOKEN left behind).
    • New "shim templates dispatch to nemarDatasets/.github" test pins the outbound dispatch shape (event_type=run-bids-validation / run-pr-merge, client_payload[dataset_id]=...).
    • Validator-pin test rescoped: the shim no longer carries the validator string; the CLI runtime pin file (validator-version.json) stays the source of truth, asserted directly.
    • Read-only-templates list shrinks to just version-check.yml.

No new Worker logic. The shims do their own dispatch via App token; no Worker round-trip needed.

Cutover

  1. nemarDatasets/.github#12 lands — central workflows available.
  2. This PR merges to epic → epic → dev → main. New dataset imports ship the shims via addCi.
  3. Run nemar admin ci sync --all (or the equivalent per-repo loop) to deploy the new shims to all 123 existing dataset repos. NOTE: this OVERWRITES the existing bids-validation.yml + pr-merge.yml. No strip script needed — the files stay at the same paths, just become shims.
  4. Verify: open a PR on nm099999; expect the shim's quick dispatch + a check-run from the central workflow with the validation result.

Test plan

  • bun run lint clean
  • bun run typecheck clean
  • 94/94 unit tests pass on touched files (workflow-yaml + all trigger + webhook tests)
  • After deploy + nemar commands #12 merge: gh workflow run run-bids-validation.yml --repo nemarDatasets/.github -f dataset_id=nm099999 -f head_sha=<sha> produces a check-run on nm099999
  • After CI sync to nm099999: open a test PR, expect the shim fires, central workflow posts a check, the check matches the validator outcome

Closes #610. Phase 4 of epic #601.

The PR-triggered workflows can't be relocated directly because GitHub's pull_request / pull_request_target events fire only in the repo where the PR lives. Phase 4 takes a hybrid approach:

- bids-validation.yml is now a ~30-line shim: triggers on push to main + pull_request to main, mints an App token scoped to .github, dispatches repository_dispatch[run-bids-validation] at nemarDatasets/.github with dataset_id/ref/head_sha/pr_number in the payload. The central run-bids-validation.yml (nemarDatasets/.github#12) does the deno validator work and posts the result back as a GitHub check-run on the dataset repo so the PR reviewer still sees a check.

- pr-merge.yml's create-release job is now a ~25-line shim: dispatches repository_dispatch[run-pr-merge] at .github. The central run-pr-merge.yml creates the tag + GitHub release on the dataset repo. The cleanup-staging job stays inline because it's AWS-only with no GitHub coupling and centralizing it would just add a network hop.

- version-check.yml stays per-repo unchanged. ~50 lines of pure JSON math, low churn, shimming saves nothing. Documented as the per-repo endstate.

test/workflow-yaml.test.ts updated: 'migrated templates' assertions pin the new shim contract (App token scoped to .github, dispatch to repos/nemarDatasets/.github/dispatches with the right event_type). A new test pins the dispatch contract directly. The validator-pin assertion drops the per-template substring check (the shim no longer carries the validator string); the CLI runtime pin file stays the source of truth. Read-only templates list shrinks to just version-check.
@github-actions

github-actions Bot commented May 23, 2026 •

Copy link
Copy Markdown

📦 Package Preview

Your package is ready to test!

bun install -g nemar-cli@PR611

Version: 0.8.33-PR611.25eda13
Commit: 25eda13


🤖 Updated on each push.

…ks:write

Code-review findings: 1) The central run-bids-validation.yml hardcoded validator 2.0.0 but the CLI pin is 2.4.1 — silent drift on every version bump. Fix: bidsValidation shim now interpolates VALIDATOR_VERSION (from src/lib/bids-validator.ts which sources validator-version.json) into the dispatch payload as client_payload[validator_version], and the central workflow reads it from there. The workflow_dispatch input default (in #12) tracks the same value; bumping the pin re-renders the shim on the next ci/sync. 2) docs/guides/github-app-setup.md was missing Checks:Read & write — the central run-bids-validation.yml uses the Checks API to post check-runs to dataset repos, which 403s without that permission. Added to step-1 perm list + Acceptance checklist + a note that operators re-accept the grant on both org installations after the App definition changes. New workflow-yaml.test.ts assertion pins the validator_version field in the shim.
neuromechanist added a commit to nemarDatasets/.github that referenced this pull request May 23, 2026
…otency

Code-review findings: 1) Validator version was hardcoded 2.0.0 in run-bids-validation.yml with no runtime sync to the CLI's validator-version.json pin (currently 2.4.1). Add validator_version as a workflow_dispatch input + client_payload field. The shim in nemarOrg/nemar-cli#611 interpolates the CLI's VALIDATOR_VERSION at template-deploy time so the value tracks the pin across ci/sync runs. The workflow_dispatch default (2.4.1) tracks the current pin; manual dispatches without an input get the default. 2) The tag-and-release step was a single atomic write — a network blip after git push but before gh release create would leave a tag without a release, and the Phase 2 tag-push handler would mint a DOI against a release-less tag. Split into 'Create tag if missing' + 'Create release if missing' (gh release view || gh release create) so a rerun after a partial failure creates the missing release.
@neuromechanist
neuromechanist merged commit 0a14309 into feature/issue-601-epic-centralize-workflows May 23, 2026
1 check passed
@neuromechanist
neuromechanist deleted the feature/issue-610-phase4-shims branch May 23, 2026 16:31

This branch was previously deployed

1 inactive deployment
npm — 25eda13e Deployed May 23, 2026 by neuromechanist via publish #1137
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.

1 participant