Skip to content

feat(ci): add central run-bids-validation + run-pr-merge workflows - #12

Merged
neuromechanist merged 2 commits into
mainfrom
11-add-central-run-bids-validation-+-run-pr-merge-workflows
May 23, 2026
Merged

neuromechanist merged 2 commits into
mainfrom
11-add-central-run-bids-validation-+-run-pr-merge-workflows

Conversation

@neuromechanist

Copy link
Copy Markdown
Member

Closes #11. Phase 4 of nemarOrg/nemar-cli#601.

What

Two new central workflows that pair with thin per-repo shims (nemarOrg/nemar-cli#611). PR-event-triggered workflows can't be relocated directly because GitHub PR events fire only in the repo where the PR lives, so the dataset repo's shim fires repository_dispatch here.

run-bids-validation.yml

  • Triggers on repository_dispatch[run-bids-validation] + workflow_dispatch.
  • Inputs: dataset_id, ref, head_sha, pr_number (optional).
  • Mints per-repo App token, creates a check-run on the dataset repo with status=in_progress so the PR reviewer sees a pending check immediately.
  • Checks out the dataset repo at head_sha, runs deno BIDS validator with the same jq pipeline + annex-pointer filtering as the legacy per-repo template.
  • Updates the check-run with conclusion=success/failure and a human-readable summary linking back to the central run logs.

run-pr-merge.yml

  • Triggers on repository_dispatch[run-pr-merge] (the shim fires this when a PR closes with merged==true).
  • Mints per-repo App token, checks out the dataset repo at main, reads Version from dataset_description.json, creates the vX.Y.Z tag + GitHub release. The tag push then fires the Phase 2 tag-push handler which dispatches version-doi.
  • The legacy template's cleanup-staging job stays inline on the dataset-repo shim because it's AWS-only with no GitHub coupling.

permissions: {} on both jobs; all GitHub writes go through the per-repo App token.

Test plan

After merge:

# bids-validation: needs a recent commit SHA on nm099999
HEAD_SHA=$(gh api repos/nemarDatasets/nm099999/commits/main --jq .sha)
gh workflow run run-bids-validation.yml --repo nemarDatasets/.github \
  -f dataset_id=nm099999 -f ref=main -f head_sha="$HEAD_SHA"
gh run watch
gh api repos/nemarDatasets/nm099999/check-runs --jq '.check_runs[0]'

# pr-merge: idempotent on existing tags, smoke-test with a real version
gh workflow run run-pr-merge.yml --repo nemarDatasets/.github \
  -f dataset_id=nm099999
gh run watch

Expect green; the bids-validation run creates a check-run on nemarDatasets/nm099999@<sha> visible in the gh api .../check-runs listing.

Closes #11. Phase 4 of nemarOrg/nemar-cli#601. Two central workflows that pair with thin per-repo shims (nemar-cli#611) — PR-event-triggered workflows can't be relocated directly because GitHub PR events fire only in the repo where the PR lives, so the shim fires repository_dispatch here. The bids-validation workflow uses the GitHub Checks API to post results back to the dataset repo's PR; the pr-merge workflow cuts the tag + release directly on the dataset repo.
…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 d0ffbef into main May 23, 2026
@neuromechanist
neuromechanist deleted the 11-add-central-run-bids-validation-+-run-pr-merge-workflows branch May 23, 2026 16:30
neuromechanist added a commit to nemarOrg/nemar-cli that referenced this pull request May 23, 2026
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.
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.

Add central run-bids-validation + run-pr-merge workflows

1 participant