Skip to content

Commit 09d32cb

Browse files
committed
ci: catch and auto-fix AGENTS.md usage-rules drift
Nothing previously ran `mix usage_rules.sync` automatically, so an ash/oban bump could silently drift AGENTS.md's generated block with nothing catching it (verified it's currently in sync, but that's incidental, not enforced). Adds a `--check` gate to ci.yaml for drift introduced within a PR, plus a new usage-rules-sync workflow that applies the sync and opens a PR if anything changed, for drift from any other source. See #79.
1 parent 15b33cd commit 09d32cb

2 files changed

Lines changed: 62 additions & 0 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ jobs:
4747
run: mix deps.get
4848
-
4949
run: mix format --check-formatted
50+
-
51+
# Catches drift introduced within this PR (e.g. an ash/oban bump
52+
# without re-running the sync) - see #79. The reactive auto-fix
53+
# for drift from any other source lives in its own workflow
54+
# (usage-rules-sync.yaml), not here.
55+
run: mix usage_rules.sync --check
5056
-
5157
run: mix test
5258

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
---
2+
name: usage-rules-sync
3+
4+
on: # yamllint disable-line rule:truthy
5+
push:
6+
branches: [main]
7+
workflow_dispatch:
8+
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
jobs:
14+
sync:
15+
name: Sync AGENTS.md usage rules
16+
runs-on: ubuntu-latest
17+
defaults:
18+
run:
19+
working-directory: app
20+
steps:
21+
-
22+
uses: actions/checkout@v7
23+
-
24+
uses: erlef/setup-beam@v1
25+
with:
26+
otp-version: "29.0.3"
27+
elixir-version: "1.20.3"
28+
disable_problem_matchers: true
29+
-
30+
run: mix deps.get
31+
-
32+
# Applies non-interactively. Verified this is a no-op (exit 0, no
33+
# changes) when AGENTS.md is already in sync with the current
34+
# usage_rules config, so this workflow is safe to run on every
35+
# push to main with no extra guard needed - see #79.
36+
name: Sync AGENTS.md from the current usage_rules config
37+
run: mix usage_rules.sync --yes
38+
-
39+
# No-op (no PR opened, nothing pushed) when there's nothing to
40+
# commit - verified against the action's own docs. Note: a PR
41+
# opened here via the default GITHUB_TOKEN queues ci.yaml's own
42+
# run but leaves it pending manual approval (GitHub's anti-loop
43+
# protection for token-authored PRs) - not a full CI skip, just
44+
# an extra click before it runs.
45+
name: Open a PR if the sync produced any changes
46+
uses: peter-evans/create-pull-request@v8
47+
with:
48+
commit-message: "chore: sync AGENTS.md usage rules"
49+
title: "chore: sync AGENTS.md usage rules"
50+
body: >-
51+
Auto-generated by the usage-rules-sync workflow - `mix
52+
usage_rules.sync` found the checked-in AGENTS.md out of sync
53+
with the current ash/oban usage-rules content and applied the
54+
update.
55+
branch: usage-rules-sync
56+
delete-branch: true

0 commit comments

Comments
 (0)