Skip to content

Epic: centralize per-repo dataset workflows on nemarDatasets/.github #601

Closed
5 of 5 issues completed
Closed

Description

@neuromechanist

Status: ✅ Implementation complete — pending dev → main + cutover

All 5 phases landed on feature/issue-601-epic-centralize-workflows. Closing comments below; cutover runbook at the end.

What landed

Centralized workflows (new, on nemarDatasets/.github)

Workflow Trigger Phase PR
run-enrichment.yml repository_dispatch[run-enrichment] from Worker /webhooks/github on README/dataset_description push 1 (#602) nemarDatasets/.github#5 + nemar-cli#605
run-version-doi.yml repository_dispatch[run-version-doi] from Worker /webhooks/github on v* tag push 2 (#606) nemarDatasets/.github#8 + nemar-cli#607
run-generate-archive.yml repository_dispatch[generate-archive] from Worker triggerArchiveGeneration() or run-version-doi's trigger-archive job 3 (#608) nemarDatasets/.github#10 + nemar-cli#609
run-bids-validation.yml repository_dispatch[run-bids-validation] from per-repo shim (PR/push events) 4 (#610) nemarDatasets/.github#12 + nemar-cli#611
run-pr-merge.yml repository_dispatch[run-pr-merge] from per-repo shim (PR merge) 4 (#610) nemarDatasets/.github#12 + nemar-cli#611

Per-repo workflows still shipped by deployWorkflows()

Workflow Reason Notes
bids-validation.yml shim — GitHub PR events fire only where the PR lives ~30 lines, dispatches to .github
pr-merge.yml shim (create-release) + inline (cleanup-staging) AWS staging cleanup stays inline; release-cutting dispatches to .github
version-check.yml kept per-repo by design ~50 lines of pure JSON-math, low churn, shimming saves nothing

Worker changes

  • POST /webhooks/github — new endpoint at backend/src/routes/webhooks.ts. HMAC-SHA256 verification via verifyGitHubWebhookSignature (new backend/src/services/webhook-signature.ts). Push-event filtering via two pure decision functions: shouldDispatchEnrichment (README/dataset_description on main/release branches) and shouldDispatchVersionDoi (v* tag pushes). Both exported and unit-tested in isolation.
  • triggerEnrichmentRun, triggerVersionDoiRun, triggerArchiveGeneration (retargeted) — all dispatch to nemarDatasets/.github via CENTRAL_WORKFLOW_REPO.
  • Zenodo DOI idempotency guard in handleZenodoVersionDoi — short-circuits a duplicate dispatch by checking dataset_versions for an existing DOI before calling zenodo.createNewVersion.
  • 401 self-heal in githubFetchWithRetry (lands separately as v0.8.32) — orthogonal to centralization but carries forward.

Cleanup tooling

Operator cutover runbook

Run in this exact order. Steps are idempotent; rerunning is safe.

1. Confirm the dev → main PR has landed

v0.8.X tag exists on main, Worker has deployed. (Verified by curling https://api.nemar.org/webhooks/github — expect 401 {"error":"Invalid signature"} since the request lacks a signed body; that means the endpoint is live.)

2. Grant Checks: Read & write on the GitHub App (docs/guides/github-app-setup.md)

The Phase 4 central run-bids-validation.yml posts check-runs via the GitHub Checks API. The App's existing permission set does not include Checks:write. Re-accept the App permission update on both nemarOrg and nemarDatasets installations. Without this, bids-validation check-runs 403 silently.

3. Configure the GitHub App webhook URL (if not already done from Phase 1)

Point nemar-publish-bot at https://api.nemar.org/webhooks/github, subscribe to push events at minimum. Confirm the App webhook secret matches the Worker's GITHUB_WEBHOOK_SECRET.

4. Sweep the legacy per-repo workflows

cd /path/to/nemar-cli
bun run scripts/strip-per-repo-workflow.ts --workflow llm-enrichment.yml
bun run scripts/strip-per-repo-workflow.ts --workflow version-doi.yml
bun run scripts/strip-per-repo-workflow.ts --workflow generate-archive.yml

Each invocation loops the ~123 dataset repos at concurrency 5 and DELETEs the file. Idempotent — repos that don't have the file are reported [skp] and skipped.

5. Deploy the new shims to existing repos

nemar admin ci sync --all

Drift-detects and overwrites bids-validation.yml + pr-merge.yml on each dataset repo with the new shim templates. The version-check.yml template is unchanged so no-op on that file.

6. Verify end-to-end

  • Enrichment: push to nm099999's README.md. Expect exactly one run of run-enrichment.yml on nemarDatasets/.github (none on the dataset repo).
  • Version DOI: push a v0.0.X-rc1 tag on nm099999. Expect one run of run-version-doi.yml, which dispatches run-generate-archive.yml.
  • BIDS validation: open a test PR on nm099999. Expect the shim's quick green check + a Run BIDS Validation check-run posted by the central workflow with the validator outcome.
  • PR merge: merge that test PR. Expect the shim's dispatch-release job fires, central run-pr-merge.yml creates the tag + release, and the resulting tag push triggers the Phase 2 chain.

Out of scope (potential follow-ups)

  • BIDS validator output shape verification: the central run-bids-validation.yml inherits the legacy jq filter for annex-pointer error filtering. Reviewer flagged that BIDS validator v2+'s location field may be a nested object rather than a string. Confirm against a real validator output and update the filter if needed.
  • Per-validator-version pinning sync: the shim interpolates VALIDATOR_VERSION from the CLI's validator-version.json at template-deploy time. Bumping the pin requires nemar admin ci sync --all to push the new value out. Worth a CI step that auto-syncs on pin bump.
  • Tighten Worker → run-enrichment race window: the source_hash guard makes duplicate enrichment a Stage-2 no-op, but two concurrent calls during the cutover window can race on the D1 enrichment_json UPDATE. Separate row-level WHERE clause is a small follow-up.

Phases

# Title Sub-issue PRs
1 Centralize llm-enrichment #602 nemar-cli#605, nemarDatasets/.github#5 + #6
2 Centralize version-doi #606 nemar-cli#607, nemarDatasets/.github#8
3 Centralize generate-archive #608 nemar-cli#609, nemarDatasets/.github#10
4 Hybrid shim for bids-validation + pr-merge #610 nemar-cli#611, nemarDatasets/.github#12
5 Final tidy + cutover runbook (this issue) (in epic→dev PR)

Sub-issues

Sub-issues

5 of 5 Issues completed
Loading 5 sub-issues

Activity

  1. added
    feature
    on May 23, 2026
  2. added
    P2
    infrastructure
    backend
    on Jun 18, 2026
  3. added a commit that references this issue on Aug 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2backendfeatureinfrastructure

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions