Merge pull request #1015 from ludovic111/ci/codeowners

🤖 Agent: merged after verify passed, security-1's dry runs on the branch, and an independent review whose findings were all fixed. CODEOWNERS for the release pipeline and update code. The protection itself (tools/ci/protect_pipeline.sh --apply) waits for the switch to the GitHub App.
This commit is contained in:
Ludovic Marie
2026-10-19 16:29:12 +02:00
committed by GitHub
2 changed files with 71 additions and 0 deletions
+17
View File
@@ -0,0 +1,17 @@
# Changes to these files wait for Ludovic's review once branch protection requires code owners' reviews
# (tools/ci/protect_pipeline.sh, docs/security.md). They are what builds, signs and ships releases, the code that
# checks downloads before installing them (backend.rs downloads, installs and updates the launcher itself; links.json
# says where from; the Cargo.toml files pick the crates that do it), and this file. Everything else merges as soon as
# `verify` passes.
/.github/ @ludovic111
/tools/ci/ @ludovic111
/tools/release_train.py @ludovic111
/tools/release_channels.py @ludovic111
/crates/horizon-release-sign/ @ludovic111
/crates/horizon-server/src/update.rs @ludovic111
/crates/horizon-server/Cargo.toml @ludovic111
/launcher/src/signed.rs @ludovic111
/launcher/src/backend.rs @ludovic111
/launcher/links.json @ludovic111
/launcher/Cargo.toml @ludovic111
/packaging/ @ludovic111
+54
View File
@@ -0,0 +1,54 @@
#!/usr/bin/env bash
# Makes main's branch protection require the code owners' review (docs/security.md): a pull request that
# changes a file .github/CODEOWNERS lists waits for Ludovic's approval; every other one still merges as soon as
# `verify` passes (no approvals are required otherwise). Approvals are dismissed by a later push. Everything
# else in the protection (the required `verify` from GitHub Actions, admins included) is kept as it is.
#
# Ludovic is the only code owner, and GitHub never counts an author's approval of their own pull request, so his
# own pull requests to listed files could never merge. He is therefore the one account allowed to bypass the
# pull-request rules (bypass_pull_request_allowances). The alternative, not enforcing the protection on admins,
# would also let an admin merge without `verify`; here `verify` stays required for everyone, admins and Ludovic
# included (enforce_admins stays on), and only the review requirement has an exception, for him alone.
#
# Apply it only once agents open, push and merge pull requests as the horizon-agent GitHub App, not as ludovic111:
# while agents use his token, his bypass is theirs too, and their changes to listed files would skip his review.
#
# tools/ci/protect_pipeline.sh # print the protection it would set, change nothing
# tools/ci/protect_pipeline.sh --apply # set it (needs the maintainer's admin login)
set -euo pipefail
repo=${GITHUB_REPOSITORY:-ludovic111/horizon}
api="repos/$repo/branches/main/protection"
body=$(gh api "$api" | jq '{
required_status_checks: (.required_status_checks
| {strict, checks: [.checks[] | {context, app_id}]}),
enforce_admins: .enforce_admins.enabled,
required_pull_request_reviews: {
require_code_owner_reviews: true,
required_approving_review_count: 0,
dismiss_stale_reviews: true,
require_last_push_approval: false,
bypass_pull_request_allowances: {users: ["ludovic111"], teams: [], apps: []}
},
restrictions: null,
required_linear_history: .required_linear_history.enabled,
allow_force_pushes: .allow_force_pushes.enabled,
allow_deletions: .allow_deletions.enabled,
required_conversation_resolution: .required_conversation_resolution.enabled,
lock_branch: .lock_branch.enabled,
allow_fork_syncing: .allow_fork_syncing.enabled
}')
echo "$body"
if [[ "${1:-}" == --apply ]]; then
gh api -X PUT "$api" --input - <<< "$body" > /dev/null
set_now=$(gh api "$api" --jq '[.required_pull_request_reviews.require_code_owner_reviews,
.enforce_admins.enabled, ([.required_pull_request_reviews.bypass_pull_request_allowances.users[]?.login]
| index("ludovic111") != null), ([.required_status_checks.checks[].context] | index("verify") != null)]
| map(tostring) | join(" ")')
if [[ "$set_now" != "true true true true" ]]; then
echo "GitHub didn't keep everything (code owners, admins enforced, Ludovic's bypass, verify): $set_now" >&2
exit 1
fi
echo "main now requires code owners' reviews; Ludovic may bypass them; verify is required for everyone."
else
echo "(not applied: run with --apply)"
fi