Skip to content

ci: fire CI once per change and add a staged-file pre-commit gate#86

Merged
brettdavies merged 2 commits into
devfrom
ci/cost-controls-and-hooks
Jul 10, 2026
Merged

ci: fire CI once per change and add a staged-file pre-commit gate#86
brettdavies merged 2 commits into
devfrom
ci/cost-controls-and-hooks

Conversation

@brettdavies

Copy link
Copy Markdown
Owner

Summary

Fleet CI-cost audit applied to this repo. This is the personal Actions pool's dominant consumer (~7,000 units this period), and its CI caller fans out to the six-job rust-ci reusable including a ×2-billed Windows job, so duplicate triggers here were the single most expensive dup in the fleet.

Net diff against dev:

  • ci.yml and skill-fixture-drift.yml fire on pull_request only. Merges to main/dev are squash merges, so the former push runs re-verified trees identical to the CI-verified PR heads. Both gain a concurrency group with cancel-in-progress; skill-fixture-drift's own job gains timeout-minutes: 10 (the rust-ci jobs are capped inside the reusable).
  • scripts/hooks/pre-commit adds the missing fast local gate: staged-file-scoped cargo fmt --check, markdownlint, and shellcheck, complementing the existing whole-repo pre-push. README documents the per-clone activation.

Left CI-only by design: cargo package --list / cargo publish --dry-run (~33 s, too heavy for a hook).

Type of Change

  • ci: CI/CD configuration changes

Related Issues/Stories

Testing

  • Unit tests added/updated
  • Integration tests added/updated
  • Manual testing completed
  • All tests passing

Test Summary:

  • actionlint: clean on all seven workflow files
  • shellcheck (--severity=warning): clean on both hooks; pre-commit exercised against real staged diffs (fmt, markdownlint, shellcheck all fired and passed)
  • Pre-existing on clean origin/dev, unrelated to this diff: 4 failing cargo test cases locally on macOS (symlink + exit-code tests); ubuntu CI is unaffected

Files Modified

Modified:

  • .github/workflows/ci.yml
  • .github/workflows/skill-fixture-drift.yml
  • README.md

Created:

  • scripts/hooks/pre-commit

Renamed:

  • None.

Deleted:

  • None.

Benefits

  • One rust-ci fan-out (including the ×2 Windows job) per change instead of two.
  • Superseded PR heads stop billing immediately.
  • Format and lint errors surface at commit time instead of in CI.

Breaking Changes

  • No breaking changes

Deployment Notes

  • No special deployment steps required

Checklist

  • Code follows project conventions and style guidelines
  • Commit messages follow Conventional Commits
  • Self-review of code completed
  • Tests added/updated and passing
  • No new warnings or errors introduced
  • Changes are backward compatible (or breaking changes documented)

ci.yml and skill-fixture-drift.yml fired on both push (main/dev) and
pull_request, so every squash merge re-ran the same tree that the PR
already verified. ci.yml drives rust-ci.yml's 6-job fan-out including
a windows-latest leg billed at the 2x multiplier, so the duplicate
roughly doubled cost on every merge. Both now trigger on pull_request
only and carry a concurrency group keyed on workflow+ref so superseded
pushes to an open PR cancel the in-flight run instead of queuing
another one. skill-fixture-drift.yml's drift-check job also gets
timeout-minutes now that it's confirmed not to be a reusable-workflow
call.
pre-push already mirrors CI's fmt/clippy/test/deny/shellcheck gates,
but nothing ran at commit time, so a bad format or lint pass only
surfaced at push. The new pre-commit hook scopes to staged files only
so it stays fast: cargo fmt --check when .rs is staged, markdownlint
when .md is staged, shellcheck when .sh is staged (including the hooks
themselves). Each tool no-ops with a notice when not installed, same
as pre-push. Also documents the two-hook activation line in the README
Contributing section.
@brettdavies brettdavies merged commit 480b616 into dev Jul 10, 2026
1 check passed
@brettdavies brettdavies deleted the ci/cost-controls-and-hooks branch July 10, 2026 18:17
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