Skip to content

Commit f41abeb

Browse files
patchmemoryclaude
andcommitted
chore: add dev submodule sync workflow and update branching docs
- Add .github/workflows/dev-submodule-sync.yml: enforce dev/ submodule freshness on PRs; auto-bump on main - Update docs/branching-and-ci.md: document dev submodule freshness policy 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
1 parent 05c6d5f commit f41abeb

2 files changed

Lines changed: 84 additions & 0 deletions

File tree

Lines changed: 83 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,83 @@
1+
name: Dev Submodule Sync
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
push:
7+
branches: [ main ]
8+
9+
permissions:
10+
contents: write
11+
12+
jobs:
13+
verify-dev-submodule:
14+
if: github.event_name == 'pull_request'
15+
runs-on: ubuntu-latest
16+
steps:
17+
- name: Checkout (no submodules)
18+
uses: actions/checkout@v4
19+
with:
20+
fetch-depth: 0
21+
- name: Read submodule config
22+
id: cfg
23+
run: |
24+
url=$(git config -f .gitmodules --get submodule.dev.url)
25+
branch=$(git config -f .gitmodules --get submodule.dev.branch || echo main)
26+
echo "url=$url" >> $GITHUB_OUTPUT
27+
echo "branch=$branch" >> $GITHUB_OUTPUT
28+
- name: Get recorded submodule SHA
29+
id: recorded
30+
run: |
31+
rec=$(git ls-tree HEAD dev | awk '{print $3}')
32+
echo "sha=$rec" >> $GITHUB_OUTPUT
33+
- name: Get latest upstream SHA for dev submodule
34+
id: upstream
35+
run: |
36+
set -e
37+
url="${{ steps.cfg.outputs.url }}"
38+
branch="${{ steps.cfg.outputs.branch }}"
39+
latest=$(git ls-remote "$url" "refs/heads/$branch" | awk '{print $1}')
40+
echo "sha=$latest" >> $GITHUB_OUTPUT
41+
- name: Compare and fail if behind
42+
run: |
43+
echo "Recorded: ${{ steps.recorded.outputs.sha }}"
44+
echo "Upstream: ${{ steps.upstream.outputs.sha }}"
45+
if [ -z "${{ steps.upstream.outputs.sha }}" ]; then
46+
echo "Could not resolve upstream dev submodule SHA. Skipping check.";
47+
exit 0;
48+
fi
49+
if [ "${{ steps.recorded.outputs.sha }}" != "${{ steps.upstream.outputs.sha }}" ]; then
50+
echo "::error::dev/ submodule is behind. Please bump dev to ${{ steps.upstream.outputs.sha }} (branch ${{ steps.cfg.outputs.branch }}).";
51+
echo "Tip: git -C dev fetch origin && git -C dev checkout ${{ steps.cfg.outputs.branch }} && git add dev && git commit -m 'chore(submodule): bump dev'";
52+
exit 1;
53+
fi
54+
echo "dev/ submodule is up-to-date. ✅"
55+
56+
sync-dev-submodule-on-main:
57+
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
58+
runs-on: ubuntu-latest
59+
steps:
60+
- name: Checkout with token
61+
uses: actions/checkout@v4
62+
with:
63+
fetch-depth: 0
64+
- name: Initialize and update submodule to latest configured branch
65+
run: |
66+
git submodule sync --recursive
67+
git submodule update --init --remote dev
68+
- name: Commit submodule pointer if changed
69+
run: |
70+
set -e
71+
if ! git diff --quiet -- dev; then
72+
new_sha=$(git ls-tree HEAD dev | awk '{print $3}')
73+
# The above SHA is from HEAD; we need the updated working tree's target
74+
# Refresh index and compute the updated SHA from the working tree
75+
git add dev
76+
new_sha=$(git ls-tree :dev | awk '{print $3}') || true
77+
git config user.name "github-actions[bot]"
78+
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
79+
git commit -m "chore(submodule): bump dev to latest"
80+
git push
81+
else
82+
echo "No submodule changes to commit."
83+
fi

docs/branching-and-ci.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ Goal: Keep the development flow simple and reliable by working on one active bra
3131
- Unit tests and smoke checks run on every PR.
3232
- E2E smoke (where applicable) runs within a few minutes (<5s/spec target).
3333
- Required checks must be green before merge.
34+
- Dev submodule freshness: PRs to main must keep dev/ submodule at the latest commit of its configured branch (see .gitmodules). A CI check enforces this, and main auto-syncs dev/ after merge.
3435

3536
## Tips
3637
- Use `python -m dev.cli ready-queue` to confirm current priorities.

0 commit comments

Comments
 (0)