Repository navigation
feat: add reusable CI workflows for Nix+Go repos - #2
Conversation
|
This change is part of the following stack: Change managed by git-spice. |
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (6)
✅ Files skipped from review due to trivial changes (2)
📝 WalkthroughSummary by CodeRabbit
WalkthroughAdds four reusable GitHub Actions workflows (openspec-guard, generate, build, ci), a manual test caller, comprehensive specs and archive docs, updated OpenSpec config, and a consumer README illustrating inputs, secrets, and migration examples. ChangesReusable Workflows Implementation and Specifications
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Poem
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. Comment |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
Add four reusable workflows that consolidate the CI logic previously duplicated across kalbasit/ncps, kalbasit/swm, and kalbasit/signal-api-receiver: - openspec-guard.yml: fails CI when active (non-archived) OpenSpec changes exist; sourced from swm (newest). - generate.yml: language-aware Nix dependency-hash regenerator. Accepts a structured `languages` JSON object so adding Python, Rust, etc. later is additive. Ships with Go (today's vendorHash flow using SWM's two-build verify recipe). - build.yml: per-arch flake-check + coverage + OCI image build/push + multi-arch manifest. Gated on the orchestrator's `oci` boolean input so swm (no images) can opt out. - ci.yml: top-level orchestrator that wires filter, generate, flake-check (when oci=false) or build (when oci=true), openspec-guard, and a final `ci` gate that enumerates each upstream needs.<job>.result individually (SWM's pattern). Conflict-resolution precedence between source workflows: SWM > ncps > signal-api-receiver. Applied: SWM's vendor-hash loop and commit message, SWM's enumerated final gate, ncps's codecov-action@v6 over signal-api-receiver's @v5, workflow_dispatch trigger included. Also: switch Docker -> OCI terminology throughout; update openspec/config.yaml with project context and per-artifact rules; add a README with consumer examples; add a workflow_dispatch _test-openspec-guard.yml sanity-test workflow. Consumer-repo migrations (swm, ncps, signal-api-receiver) are tracked under the openspec change `shared-workflows` and will land as separate PRs once this repo tags v0.1.0.
GitHub's workflow_dispatch requires the workflow file to exist on the default branch. Until this PR merges to main, the only way to exercise _test-openspec-guard.yml is to give it a pull_request trigger. Will be reverted before merge.
The PR-trigger workaround didn't fire as expected and we are switching to validating the workflows via real consumer migrations (ncps, swm, signal-api-receiver) instead. Reverting before the temp trigger ships. This reverts commit 4a565bc.
Update tasks.md to reflect the swm (1963b74), ncps (115fca5), and signal-api-receiver (552c1e4) consumer-repo migrations, all committed on their respective user/wnasreddine/ci-jobs branches. Verification tasks (PR open, CI green, merge) stay open and will be ticked off as the PRs progress.
The reusable generate.yml declared workflow-level
\`permissions: contents: write\` to match the auto-commit step.
GitHub validates the permissions chain when one reusable workflow
calls another: the called workflow's declared permissions cannot
exceed the caller's. swm's caller (and ci.yml itself) declares
\`contents: read\` because nothing in the static call graph appears
to need write — the actual git push is performed by
\`git-auto-commit-action\` using the PAT supplied to actions/checkout,
not via GITHUB_TOKEN. The declaration was therefore both unnecessary
and breaking: it forced consumers' calling workflows to also declare
\`contents: write\` despite never directly pushing anything.
Lower generate.yml to \`contents: read\`. The PAT path is identical
to what kalbasit/{ncps,swm,signal-api-receiver} have always done.
Side benefit: PAT-pushed commits re-trigger downstream workflows
(GITHUB_TOKEN-pushed commits do not).
Fixes the invalid-workflow error swm hit when first calling
gh-actions/ci.yml:
Error calling workflow
'kalbasit/gh-actions/.github/workflows/generate.yml@...'.
The workflow is requesting 'contents: write', but is only allowed
'contents: read'.
The shared-workflows change ships the reusable CI workflows (ci.yml, generate.yml, build.yml, openspec-guard.yml) plus the three consumer-repo migrations (swm, ncps, signal-api-receiver). swm's CI run on PR #149 confirmed the orchestrator works end-to-end. With implementation done, archive the change directory to openspec/changes/archive/2026-05-22-shared-workflows/ and materialize the four delta specs into openspec/specs/ as the canonical capability records for this repo. Twelve tasks remain open (per-consumer PR-merge, tagging v0.1.0, repin to @v0.1.0); these are post-implementation verification steps, not implementation work, and don't gate the archive. Specs synced via openspec-sync-specs in a separate step; the archive itself ran with --skip-specs to avoid double-applying.
f04eff9 to
0627e7e
Compare
There was a problem hiding this comment.
Actionable comments posted: 9
🧹 Nitpick comments (4)
openspec/changes/archive/2026-05-22-shared-workflows/specs/oci-build/spec.md (1)
3-4: ⚡ Quick winUpdate the placeholder Purpose section.
The Purpose section contains a placeholder note. Consider updating it with the actual purpose now that the change has been archived.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openspec/changes/archive/2026-05-22-shared-workflows/specs/oci-build/spec.md` around lines 3 - 4, Replace the placeholder text in the "Purpose" section under the "Requirement: Reusable OCI build workflow" header with a concise summary of the archived change: describe why the reusable OCI build workflow was introduced, its intended scope (e.g., standardized build steps, portability, and reuse across projects), and any key outcomes or decisions from the archive. Update the Purpose paragraph in spec.md to reflect the finalized intent and outcomes rather than the placeholder note.openspec/specs/reusable-ci/spec.md (1)
3-4: ⚡ Quick winUpdate the placeholder Purpose section.
The Purpose section contains a placeholder note. Consider updating it with the actual purpose of this specification.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openspec/specs/reusable-ci/spec.md` around lines 3 - 4, The "## Purpose" section currently contains a placeholder note; replace the placeholder text under the "## Purpose" heading with a concise summary of this specification's intent—describe what the reusable CI spec covers, its scope, intended audience, and expected outcomes (e.g., defining shared CI workflows, configuration conventions, and reuse guidelines for projects); ensure the new Purpose is clear, 2–4 short sentences, and uses the existing "## Purpose" heading so links/TOC remain valid.openspec/changes/archive/2026-05-22-shared-workflows/specs/reusable-ci/spec.md (1)
3-4: ⚡ Quick winUpdate the placeholder Purpose section.
The Purpose section contains a placeholder note. Consider updating it with the actual purpose now that the change has been archived.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openspec/changes/archive/2026-05-22-shared-workflows/specs/reusable-ci/spec.md` around lines 3 - 4, The Purpose section currently contains a placeholder note; replace that placeholder in the "Purpose" section under the "Requirement: Reusable CI orchestrator workflow" header with a concise, final purpose statement describing why the reusable CI orchestrator workflow exists, its intended audience, and the key outcomes (e.g., "provide a configurable, shareable orchestration workflow for CI pipelines to standardize job composition, reduce duplication, and enable cross-repo reuse across teams"); ensure the wording is final (not TODO) and aligns with the archived change context in spec.md.openspec/specs/oci-build/spec.md (1)
3-4: ⚡ Quick winUpdate the placeholder Purpose section.
The Purpose section contains a placeholder note. Consider updating it with the actual purpose of this specification.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@openspec/specs/oci-build/spec.md` around lines 3 - 4, Replace the placeholder text under the "Purpose" heading with a concise, specific description of this specification's intent: state why the OCI build spec exists, its scope (what it governs or standardizes), intended audience/consumers, and any high-level goals or constraints; update the "Purpose" section in openspec/specs/oci-build/spec.md to remove "TBD - created by archiving change shared-workflows. Update Purpose after archive." and include that concrete purpose statement.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In @.github/workflows/build.yml:
- Around line 67-70: The workflow uses floating refs for GitHub Actions which
weakens supply-chain security; replace every `uses:` entry that currently
references a tag (e.g., actions/checkout@v6,
DeterminateSystems/flake-checker-action@main, cachix/install-nix-action@v31,
cachix/cachix-action@v17, codecov/codecov-action@v6, docker/*`@v4`|`@v6`, etc.) with
the corresponding full commit SHA for that release, and in the
`actions/checkout` step add a `with:` block containing `persist-credentials:
false` to harden checkout; locate the `uses:` lines in the workflow and update
each to use the verified commit SHAs and add `persist-credentials: false` under
the `actions/checkout` entry.
- Line 91: The "Build coverage" and "Upload coverage reports to Codecov" steps
currently only run when github.event.pull_request.head.repo.fork == false which
prevents them from running on non-pull_request events; update the steps (named
"Build coverage" and "Upload coverage reports to Codecov") to gate on event type
first so you only exclude forked PRs — replace the current if with a condition
that allows non-pull_request events and only blocks forked PRs, e.g. use: if:
(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork
== false) || github.event_name != 'pull_request' so the steps run for
push/tag/workflow_dispatch but still skip forked PRs.
In @.github/workflows/ci.yml:
- Around line 161-175: When inputs.oci is true the build job may be invoked
without required inputs (images, dockerhub_username, primary_package); add an
explicit validation step before or as part of the build job to check those
inputs and fail with a clear error message. For example, add a short pre-job or
an initial step in the existing build job that inspects inputs.images,
inputs.dockerhub_username and inputs.primary_package (the same symbols used in
the build job) and exits with a descriptive error if any are empty so the
failure is explicit rather than cryptic.
- Around line 151-154: Pin all GitHub Actions usages by replacing the current
tags with commit SHAs for each referenced action (e.g., change uses:
actions/checkout@v6 to uses: actions/checkout@<commit-sha>,
DeterminateSystems/flake-checker-action@main to
DeterminateSystems/flake-checker-action@<commit-sha>,
cachix/install-nix-action@v31 and cachix/cachix-action@v17 to their respective
commit SHAs) and disable credential persistence for the checkout step by adding
the persist-credentials: false input to the actions/checkout invocation; update
the uses entries for DeterminateSystems/flake-checker-action,
cachix/install-nix-action, and cachix/cachix-action to pinned SHAs as well.
- Line 90: Replace the unpinned actions/checkout@v6 usage with a fixed commit
SHA and explicitly disable credential persistence; update the uses reference
from "actions/checkout@v6" to "actions/checkout@<commit-sha-for-v6>" and add a
with block that sets persist-credentials: false (optionally include fetch-depth
or clean if needed), ensuring the checkout action is pinned and credentials are
not saved to .git/config.
- Line 112: Replace the floating tag used for the GitHub Action reference
`dorny/paths-filter@v4` with the exact commit SHA for the v4 release to prevent
tag movement; update the single occurrence of `dorny/paths-filter@v4` in the
workflow to `dorny/paths-filter@<commit-sha>` (use the actual commit hash for
v4) so the workflow pins to a specific immutable revision.
In @.github/workflows/generate.yml:
- Line 57: Replace floating action tags with their corresponding full commit
SHAs for each used action: actions/checkout@v6, dorny/paths-filter@v4,
cachix/install-nix-action@v31, cachix/cachix-action@v17, and
stefanzweifel/git-auto-commit-action@v7 by looking up and substituting the
commit SHA for each repository and updating the workflow references; also
address the checkout credential behavior by either removing or setting
persist-credentials: true on the actions/checkout step (or, if you must keep
persist-credentials: false, add a step that reconfigures an authenticated git
remote or provides credentials before stefanzweifel/git-auto-commit-action runs)
so the auto-commit action can push.
In @.github/workflows/openspec-guard.yml:
- Line 22: Update the checkout step that currently uses "uses:
actions/checkout@v6" to pin the action to its full commit SHA and add
"persist-credentials: false" to the step configuration; locate the workflow step
referencing uses: actions/checkout@v6 and replace the tag with the exact commit
SHA for that release and add the persist-credentials: false key so tokens are
not persisted by the runner.
In `@openspec/changes/archive/2026-05-22-shared-workflows/tasks.md`:
- Around line 128-133: The task 10.3 checkbox is still marked incomplete but the
file already lives in archive/, so update the checklist entry "10.3 Archive this
OpenSpec change." to mark it complete by changing the unchecked box "- [ ] 10.3
Archive this OpenSpec change." to a checked box "- [x] 10.3 Archive this
OpenSpec change." so the checklist reflects the current archived state.
---
Nitpick comments:
In
`@openspec/changes/archive/2026-05-22-shared-workflows/specs/oci-build/spec.md`:
- Around line 3-4: Replace the placeholder text in the "Purpose" section under
the "Requirement: Reusable OCI build workflow" header with a concise summary of
the archived change: describe why the reusable OCI build workflow was
introduced, its intended scope (e.g., standardized build steps, portability, and
reuse across projects), and any key outcomes or decisions from the archive.
Update the Purpose paragraph in spec.md to reflect the finalized intent and
outcomes rather than the placeholder note.
In
`@openspec/changes/archive/2026-05-22-shared-workflows/specs/reusable-ci/spec.md`:
- Around line 3-4: The Purpose section currently contains a placeholder note;
replace that placeholder in the "Purpose" section under the "Requirement:
Reusable CI orchestrator workflow" header with a concise, final purpose
statement describing why the reusable CI orchestrator workflow exists, its
intended audience, and the key outcomes (e.g., "provide a configurable,
shareable orchestration workflow for CI pipelines to standardize job
composition, reduce duplication, and enable cross-repo reuse across teams");
ensure the wording is final (not TODO) and aligns with the archived change
context in spec.md.
In `@openspec/specs/oci-build/spec.md`:
- Around line 3-4: Replace the placeholder text under the "Purpose" heading with
a concise, specific description of this specification's intent: state why the
OCI build spec exists, its scope (what it governs or standardizes), intended
audience/consumers, and any high-level goals or constraints; update the
"Purpose" section in openspec/specs/oci-build/spec.md to remove "TBD - created
by archiving change shared-workflows. Update Purpose after archive." and include
that concrete purpose statement.
In `@openspec/specs/reusable-ci/spec.md`:
- Around line 3-4: The "## Purpose" section currently contains a placeholder
note; replace the placeholder text under the "## Purpose" heading with a concise
summary of this specification's intent—describe what the reusable CI spec
covers, its scope, intended audience, and expected outcomes (e.g., defining
shared CI workflows, configuration conventions, and reuse guidelines for
projects); ensure the new Purpose is clear, 2–4 short sentences, and uses the
existing "## Purpose" heading so links/TOC remain valid.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: f54a4641-da92-45bf-84a9-2490f0942a07
📒 Files selected for processing (19)
.github/workflows/_test-openspec-guard.yml.github/workflows/build.yml.github/workflows/ci.yml.github/workflows/generate.yml.github/workflows/openspec-guard.ymlREADME.mdopenspec/changes/archive/2026-05-22-shared-workflows/.openspec.yamlopenspec/changes/archive/2026-05-22-shared-workflows/design.mdopenspec/changes/archive/2026-05-22-shared-workflows/proposal.mdopenspec/changes/archive/2026-05-22-shared-workflows/specs/dependency-hash-generation/spec.mdopenspec/changes/archive/2026-05-22-shared-workflows/specs/oci-build/spec.mdopenspec/changes/archive/2026-05-22-shared-workflows/specs/openspec-guard/spec.mdopenspec/changes/archive/2026-05-22-shared-workflows/specs/reusable-ci/spec.mdopenspec/changes/archive/2026-05-22-shared-workflows/tasks.mdopenspec/config.yamlopenspec/specs/dependency-hash-generation/spec.mdopenspec/specs/oci-build/spec.mdopenspec/specs/openspec-guard/spec.mdopenspec/specs/reusable-ci/spec.md
Refactor build.yml so each registry is independently opt-in,
matching the user's want to push to "Docker Hub, ghcr.io, or
something else" without rewriting the workflow:
- Rename `images` -> `dockerhub_image` (optional).
- Make `dockerhub_username` optional. Docker Hub is enabled iff
both `dockerhub_image` and `dockerhub_username` are set (one
without the other is rejected at workflow start with a clear
`::error::` from a new pre-flight validation step).
- Add `ghcr_enabled` boolean (default true).
- Add `ghcr_image` optional override (default falls back to
`ghcr.io/<repo>`).
- When `oci: true`, at least one registry must be enabled or the
validation step fails up-front.
- The `docker/metadata-action` `images:` list and each
`docker/login-action` step are gated on the per-registry
enablement check.
Also fold in the CodeRabbit review comments worth addressing:
- **Real bug**: Codecov "Build coverage" and "Upload coverage"
steps were gated only on `pull_request.head.repo.fork == false`.
On push/tag/workflow_dispatch events that expression evaluates
to false (the `fork` field is null), so coverage was silently
skipped outside of PRs. Gate on `github.event_name` first so we
only skip fork PRs.
- **SHA-pinning**: pin every third-party action to a full commit
SHA across build.yml, ci.yml, generate.yml, and
openspec-guard.yml. Each `uses:` line carries a trailing
`# vN.N.N` comment for human readability.
- **persist-credentials: false** on every `actions/checkout`
step EXCEPT `generate.yml`'s, which embeds the PAT in the git
remote URL so `git-auto-commit-action` can push back. Documented
that exception inline with a comment.
Consumer-side rename (`images` -> `dockerhub_image`) ships in
separate commits in the consumer repos. The orchestrator inputs are
documented in README.md with a new "Registries" subsection showing
three common configurations (ghcr-only, Docker-Hub-only, both).
Trivial: mark task 10.3 (Archive this OpenSpec change) complete in
the archived tasks.md — it's accurate now since the change was
archived in commit 2fb344c.
Add four reusable workflows that consolidate the CI logic previously
duplicated across kalbasit/ncps, kalbasit/swm, and
kalbasit/signal-api-receiver:
changes exist; sourced from swm (newest).
Accepts a structured
languagesJSON object so adding Python,Rust, etc. later is additive. Ships with Go (today's vendorHash
flow using SWM's two-build verify recipe).
ocibooleaninput so swm (no images) can opt out.
flake-check (when oci=false) or build (when oci=true),
openspec-guard, and a final
cigate that enumerates eachupstream needs..result individually (SWM's pattern).
Conflict-resolution precedence between source workflows: SWM > ncps
Also: switch Docker -> OCI terminology throughout; update
openspec/config.yaml with project context and per-artifact rules;
add a README with consumer examples; add a workflow_dispatch
_test-openspec-guard.yml sanity-test workflow.
Consumer-repo migrations (swm, ncps, signal-api-receiver) are
tracked under the openspec change
shared-workflowsand will landas separate PRs once this repo tags v0.1.0.