Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,32 @@ PR-triggered check on the existing Lint workflow — **no new cron/scheduled wor
in `scripts/template_stub_drift.sh` (`TEMPLATE_DRIFT_ALLOWLIST`). Add a path to that allowlist **only** with
a recorded rationale, the same way the exceptions above are documented.

- **Dependabot must not bump the shipped artifacts (#1435).** Dependabot runs in `repo-template` off the
seeded `.github/dependabot.yml`. If that config enables the `github-actions` ecosystem, Dependabot bumps
action versions **inside the shipped workflow stubs** — each bump rewrites a committed blob, so the file no
longer matches the standards-derived baseline and `template-drift` fails **in this repo for a change made in
another repo**. Because a non-required red check still halts pr-review here (`compute_ci_status` has no
required/non-required notion — `scripts/lib/ci-status.sh`, `scripts/review-one-pr.sh`), a Dependabot bump in
`repo-template` silently stops all PR review here with no signal on any PR. **Mechanism:**
`scripts/seed-repo-template.sh` scopes the `github-actions` package-ecosystem **out** of the shipped
`.github/dependabot.yml` (`_dependabot_scope_out_actions`; tests in `tests/test_seed_repo_template.bats`).
The template's workflows are a distribution artifact of `standards/` and their action versions stay current
by **re-seeding** (`bump standards/` → re-run `seed-repo-template.sh`), not by Dependabot — the same
edit-standards-not-the-copy contract as the drift guard itself. This also correctly stops Dependabot from
bumping the first-party channel-tag pins in the caller stubs, which are the sanctioned mutable-ref exception
(see "Release channel tags & the mutable-ref exception"). Other ecosystems (npm/gomod/pip/…) pass through
unchanged, and a consumer that wants Dependabot-managed action updates for its **own** (non-artifact)
workflows adds the `github-actions` ecosystem back when it customizes its stack per `BOOTSTRAP.md`.
- **Why not the alternatives.** *Option 2 — keep Dependabot, automate a re-seed after each bump* — was
rejected: it leaves a permanent drift window between the bump and the re-seed during which
`template-drift` is red and review here is halted. *Option 3 — point Dependabot at
`petry-projects/.github` and let bumps flow to the template by re-seeding* — reaches the same
end state but additionally requires a change in the public standards repo; the scope-out above is
implementable entirely from this repo (which owns `seed-repo-template.sh`) and is a prerequisite for
Option 3 anyway (the template still must not run its own `github-actions` Dependabot). If the standards
repo later grows its own `github-actions` Dependabot + re-seed automation, this scope-out remains the
correct template-side behavior.

### Reusable caller-input contract (`validate-caller-inputs`)

The `validate-caller-inputs` job in `lint.yml` (#1253, epic #1052; regression guard for #1034)
Expand Down
50 changes: 48 additions & 2 deletions scripts/seed-repo-template.sh
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,46 @@ EOF
esac
}

# ── Scope Dependabot out of the byte-identity workflow artifacts (#1435) ───────
# Reads a dependabot.yml on stdin and DROPS the `github-actions` package-ecosystem
# block, passing every other ecosystem (npm/gomod/pip/…) through unchanged.
#
# repo-template's shipped workflows are a DISTRIBUTION ARTIFACT of standards/ and
# are kept current by re-seeding, not by Dependabot. A `github-actions` Dependabot
# run in the template edits those artifacts directly — every bump changes a
# committed blob, drifts template-drift, and (because a non-required red check
# halts pr-review here) silently stops review. Dependabot's github-actions
# ecosystem has no per-file exclusion, so the whole ecosystem is scoped out; this
# also correctly stops Dependabot from bumping the first-party channel-tag pins in
# the caller stubs (the sanctioned mutable-ref exception). See AGENTS.md
# "Template drift guard (repo-template)".
#
# A block is the `- package-ecosystem:` list item and all of its deeper-indented
# child lines; its immediately-preceding comment line(s) are discarded with it.
_dependabot_scope_out_actions() {
awk '
/^[[:space:]]*#/ {
match($0, /^[[:space:]]*/)
if (drop && RLENGTH < drop_indent) { drop = 0 }
pending = pending $0 ORS; next
}
/^[[:space:]]*-[[:space:]]+package-ecosystem:/ {
match($0, /^[[:space:]]*/)
drop_indent = RLENGTH
if ($0 ~ /github-actions/) { drop = 1; pending = "" }
else { drop = 0; printf "%s", pending; pending = ""; print }
next
Comment thread
qodo-code-review[bot] marked this conversation as resolved.
Resolved
}
{
match($0, /^[[:space:]]*/)
if (drop && RLENGTH < drop_indent) { drop = 0 }
if (!drop) { printf "%s", pending; print }
pending = ""
}
END { if (!drop) printf "%s", pending }
'
}
Comment thread
don-petry marked this conversation as resolved.
Resolved

# _emit_baseline <path> — print a baseline file's shipped content.
_emit_baseline() {
local path="$1" row source
Expand All @@ -356,13 +396,15 @@ _emit_baseline() {
echo "::error::unknown baseline file: $path" >&2
return 2
fi
local content std_path
local content std_path scope_actions=0
if [ "$source" = "gen" ]; then
_gen_baseline "$path"
else
if [ "$source" = "fetch" ]; then
# Dependabot special case: the standards path is DEPENDABOT_STACK-derived.
# Scope github-actions out so a Dependabot bump can't drift the template (#1435).
std_path="standards/dependabot/${DEPENDABOT_STACK}.yml"
scope_actions=1
elif [ "${source#fetch:}" != "$source" ]; then
# General verbatim fetch: source=fetch:<standards-path> (e.g. .gitleaks.toml).
std_path="${source#fetch:}"
Expand All @@ -379,7 +421,11 @@ _emit_baseline() {
echo "::error::could not fetch ${std_path} from ${STANDARDS_REPO}" >&2
return 1
fi
printf '%s\n' "$content"
if [ "$scope_actions" = 1 ]; then
printf '%s\n' "$content" | _dependabot_scope_out_actions
else
printf '%s\n' "$content"
fi
fi
}

Expand Down
135 changes: 135 additions & 0 deletions tests/test_seed_repo_template.bats
Original file line number Diff line number Diff line change
Expand Up @@ -359,6 +359,141 @@ EOF
[[ "$output" == *"could not fetch standards/dependabot/frontend.yml"* ]]
}

# ── #1435: Dependabot must not bump the byte-identity workflow artifacts ───────
# repo-template's shipped workflows are a distribution artifact of standards/ and
# are kept current by re-seeding, not by Dependabot. A github-actions Dependabot
# run in the template edits those artifacts directly and drifts template-drift.
# The seed therefore scopes the github-actions package-ecosystem out of the
# shipped .github/dependabot.yml; other ecosystems (npm/gomod/…) pass through.
@test "scope-out: removes the github-actions ecosystem, keeps npm (#1435)" {
source "$SEED"
out="$(printf '%s\n' \
'version: 2' \
'updates:' \
' - package-ecosystem: "github-actions"' \
' directory: "/"' \
' schedule:' \
' interval: weekly' \
' - package-ecosystem: "npm"' \
' directory: "/"' \
| _dependabot_scope_out_actions)"
[[ "$out" != *"github-actions"* ]]
[[ "$out" == *"package-ecosystem: \"npm\""* ]]
[[ "$out" == *"version: 2"* ]]
}

@test "scope-out: removes a github-actions block that is LAST in the list (#1435)" {
source "$SEED"
out="$(printf '%s\n' \
'version: 2' \
'updates:' \
' - package-ecosystem: gomod' \
' directory: "/"' \
' - package-ecosystem: github-actions' \
' directory: "/"' \
' open-pull-requests-limit: 10' \
| _dependabot_scope_out_actions)"
[[ "$out" != *"github-actions"* ]]
[[ "$out" != *"open-pull-requests-limit"* ]] # its child lines go too
[[ "$out" == *"package-ecosystem: gomod"* ]]
}

@test "scope-out: removes a github-actions block in the MIDDLE, keeps both siblings (#1435)" {
source "$SEED"
out="$(printf '%s\n' \
'updates:' \
' - package-ecosystem: npm' \
' - package-ecosystem: github-actions' \
' directory: "/"' \
' - package-ecosystem: pip' \
| _dependabot_scope_out_actions)"
[[ "$out" != *"github-actions"* ]]
[[ "$out" == *"package-ecosystem: npm"* ]]
[[ "$out" == *"package-ecosystem: pip"* ]]
}

@test "scope-out: discards the dropped block's leading comment (#1435)" {
source "$SEED"
out="$(printf '%s\n' \
'updates:' \
' # GitHub Actions — version updates (keep actions current)' \
' - package-ecosystem: "github-actions"' \
' directory: "/"' \
' # npm deps' \
' - package-ecosystem: "npm"' \
| _dependabot_scope_out_actions)"
[[ "$out" != *"GitHub Actions"* ]] # the block's own comment is gone
[[ "$out" == *"# npm deps"* ]] # a kept block keeps its comment
[[ "$out" == *"package-ecosystem: \"npm\""* ]]
}

@test "scope-out: a standalone comment inside the dropped block does not leak (#1435)" {
source "$SEED"
out="$(printf '%s\n' \
'updates:' \
' - package-ecosystem: "github-actions"' \
' directory: "/"' \
' # inline note that belongs to the dropped block' \
' schedule:' \
' interval: weekly' \
' - package-ecosystem: "npm"' \
| _dependabot_scope_out_actions)"
[[ "$out" != *"github-actions"* ]]
[[ "$out" != *"inline note"* ]] # the mid-block comment is dropped too
[[ "$out" == *"package-ecosystem: \"npm\""* ]]
}

@test "scope-out: a config with no github-actions passes through unchanged (#1435)" {
source "$SEED"
in="$(printf '%s\n' 'version: 2' 'updates:' ' - package-ecosystem: npm' ' directory: "/"')"
out="$(printf '%s' "$in" | _dependabot_scope_out_actions)"
[ "$out" = "$in" ]
}
Comment thread
don-petry marked this conversation as resolved.
Resolved

@test "scope-out: keeps subsequent top-level keys after a dropped block (#1435)" {
source "$SEED"
out="$(printf '%s\n' \
'updates:' \
' - package-ecosystem: github-actions' \
' directory: "/"' \
'registries:' \
' some-registry:' \
' type: docker-registry' \
| _dependabot_scope_out_actions)"
[[ "$out" != *"github-actions"* ]]
[[ "$out" == *"registries:"* ]]
[[ "$out" == *"some-registry:"* ]]
}

@test "scope-out: preserves trailing comments at the end of the file (#1435)" {
source "$SEED"
out="$(printf '%s\n' \
'updates:' \
' - package-ecosystem: npm' \
'# trailing comment' \
| _dependabot_scope_out_actions)"
[[ "$out" == *"# trailing comment"* ]]
}

@test "baseline: emitted dependabot.yml ships with github-actions scoped out (#1435)" {
cat > "$STANDARDS_DIR/standards/dependabot/frontend.yml" <<'EOF'
version: 2
updates:
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: weekly
- package-ecosystem: "npm"
directory: "/"
schedule:
interval: weekly
EOF
run env DEPENDABOT_STACK=frontend bash "$SEED" --emit-baseline .github/dependabot.yml
[ "$status" -eq 0 ]
[[ "$output" != *"github-actions"* ]]
[[ "$output" == *"package-ecosystem: \"npm\""* ]]
}

# ── seeding orchestration: DRY_RUN ────────────────────────────────────────────
@test "DRY_RUN: exits 0, names the target repo, makes no write API calls" {
_stub_gh
Expand Down
Loading