From 23bb8b0afc25f2d09819bebf1a2d31baa0e305d5 Mon Sep 17 00:00:00 2001 From: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com> Date: Fri, 19 Jun 2026 15:42:39 +0000 Subject: [PATCH 1/2] =?UTF-8?q?feat:=20implement=20issue=20#320=20?= =?UTF-8?q?=E2=80=94=20Compliance:=20check-suite-prefs-unreadable?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/apply-repo-settings.sh | 4 +- tests/integration/apply-repo-settings.bats | 54 ++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 tests/integration/apply-repo-settings.bats diff --git a/scripts/apply-repo-settings.sh b/scripts/apply-repo-settings.sh index 39377bb3..bef99466 100755 --- a/scripts/apply-repo-settings.sh +++ b/scripts/apply-repo-settings.sh @@ -107,10 +107,10 @@ PAYLOAD info "Configuring check-suite preferences for $ORG/$REPO ..." if [ "$DRY_RUN" = true ]; then - skip "DRY_RUN — would PATCH repos/$ORG/$REPO/check-suite/preferences:" + skip "DRY_RUN — would PATCH repos/$ORG/$REPO/check-suites/preferences:" echo "$CHECK_SUITE_PAYLOAD" | jq '.' else - echo "$CHECK_SUITE_PAYLOAD" | gh api -X PATCH "repos/$ORG/$REPO/check-suite/preferences" --input - > /dev/null + echo "$CHECK_SUITE_PAYLOAD" | gh api -X PATCH "repos/$ORG/$REPO/check-suites/preferences" --input - > /dev/null ok "check-suite auto-trigger disabled for Claude (ID=$CLAUDE_APP_ID) and CodeRabbit (ID=$CODERABBIT_APP_ID)" fi diff --git a/tests/integration/apply-repo-settings.bats b/tests/integration/apply-repo-settings.bats new file mode 100644 index 00000000..eacf5df6 --- /dev/null +++ b/tests/integration/apply-repo-settings.bats @@ -0,0 +1,54 @@ +#!/usr/bin/env bats +# Integration tests for scripts/apply-repo-settings.sh +# +# These tests stub the `gh` and `jq` CLIs so the script can run without network +# access or real credentials, and assert that it targets the correct GitHub REST +# endpoint for check-suite preferences (`check-suites/preferences`, plural). + +setup() { + REPO_ROOT="$(cd "$BATS_TEST_DIRNAME/../.." && pwd)" + SCRIPT="$REPO_ROOT/scripts/apply-repo-settings.sh" + + BIN_DIR="$BATS_TEST_TMPDIR/bin" + mkdir -p "$BIN_DIR" + CALL_LOG="$BATS_TEST_TMPDIR/gh-calls.log" + + # Mock `gh`: record every invocation, satisfy the repo-identity safety check, + # and succeed on the PATCH without making a network call. + cat > "$BIN_DIR/gh" <> "$CALL_LOG" +if [ "\$1" = "repo" ] && [ "\$2" = "view" ]; then + echo "petry-projects/broodly" + exit 0 +fi +# Drain stdin for the PATCH --input - call so the pipe does not break. +if [ "\$1" = "api" ]; then + cat > /dev/null 2>&1 || true + exit 0 +fi +exit 0 +MOCK + chmod +x "$BIN_DIR/gh" + + export PATH="$BIN_DIR:$PATH" + export GH_TOKEN="test-token" +} + +@test "applies check-suite preferences via the plural check-suites/preferences endpoint" { + run bash "$SCRIPT" broodly + [ "$status" -eq 0 ] + grep -q "api -X PATCH repos/petry-projects/broodly/check-suites/preferences" "$CALL_LOG" +} + +@test "never targets the non-existent singular check-suite/preferences endpoint" { + run bash "$SCRIPT" broodly + [ "$status" -eq 0 ] + ! grep -qE "repos/petry-projects/broodly/check-suite/preferences" "$CALL_LOG" +} + +@test "dry-run makes no PATCH call" { + run bash "$SCRIPT" broodly --dry-run + [ "$status" -eq 0 ] + ! grep -q "api -X PATCH" "$CALL_LOG" +} From 7e539d8669aff81c166be2c616c6afe57dc1b04d Mon Sep 17 00:00:00 2001 From: donpetry-bot <281750570+donpetry-bot@users.noreply.github.com> Date: Fri, 19 Jun 2026 15:53:16 +0000 Subject: [PATCH 2/2] chore: apply manual instructions [skip ci-relay] --- tests/integration/apply-repo-settings.bats | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/integration/apply-repo-settings.bats b/tests/integration/apply-repo-settings.bats index eacf5df6..5271c5a1 100644 --- a/tests/integration/apply-repo-settings.bats +++ b/tests/integration/apply-repo-settings.bats @@ -31,6 +31,14 @@ exit 0 MOCK chmod +x "$BIN_DIR/gh" + # Mock `jq`: pass stdin through to stdout so dry-run output works without + # requiring jq to be installed on the host. + cat > "$BIN_DIR/jq" <