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
8 changes: 4 additions & 4 deletions .github/scripts/apply-pr-quality-ruleset.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
# petry-projects/markets.
#
# Pull-request rule parameters configured (codified standard, source of truth:
# petry-projects/.github/standards/rulesets/pr-quality.json — see #324):
# petry-projects/.github/standards/rulesets/pr-quality.json — see #323, #324):
# - required_approving_review_count: 1
# - require_code_owner_review: true
# - require_code_owner_review: true (drifted to false — issue #323)
# - required_review_thread_resolution: true
# - dismiss_stale_reviews_on_push: true (the drifted parameter — issue #324)
# - require_last_push_approval: true
Expand Down Expand Up @@ -40,8 +40,8 @@ export GH_TOKEN
EXISTING_ID=$(gh api "repos/$REPO/rulesets" \
--jq ".[] | select(.name == \"$RULESET_NAME\") | .id")

PAYLOAD=$(jq -n '{
name: "pr-quality",
PAYLOAD=$(jq -n --arg name "$RULESET_NAME" '{
name: $name,
target: "branch",
enforcement: "active",
conditions: {
Expand Down
2 changes: 1 addition & 1 deletion .github/scripts/apply-repo-settings.sh
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ echo "Applying code-quality required-status-checks ruleset ..."

"$SCRIPT_DIR/apply-code-quality-ruleset.sh"

echo "Applying pr-quality required-review ruleset ..."
echo "Applying pr-quality pull-request review ruleset ..."

"$SCRIPT_DIR/apply-pr-quality-ruleset.sh"

Expand Down
20 changes: 15 additions & 5 deletions .github/scripts/tests/apply-pr-quality-ruleset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@
#
# The pull_request rule parameters asserted below are the codified standard
# (petry-projects/.github/standards/rulesets/pr-quality.json), the source of
# truth referenced by issue #324.
# truth referenced by issues #323 and #324. require_code_owner_review (#323)
# and dismiss_stale_reviews_on_push (#324) are the parameters that drifted to
# false and must be codified as true.

SCRIPT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)/apply-pr-quality-ruleset.sh"

Expand All @@ -21,7 +23,11 @@ SCRIPT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)/apply-pr-quality-rule
}

@test "script declares the pr-quality ruleset" {
grep -qE '^[[:space:]]+name[[:space:]]*:[[:space:]]*"pr-quality"' "$SCRIPT"
grep -qE 'RULESET_NAME\s*=\s*"pr-quality"' "$SCRIPT"
}
Comment thread
don-petry marked this conversation as resolved.

@test "script requires GH_TOKEN" {
grep -q 'GH_TOKEN' "$SCRIPT"
}

@test "script sets dismiss_stale_reviews_on_push to true (issue #324)" {
Expand All @@ -32,7 +38,7 @@ SCRIPT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)/apply-pr-quality-rule
grep -qE '^[[:space:]]+required_approving_review_count[[:space:]]*:[[:space:]]*1[[:space:]]*,?[[:space:]]*$' "$SCRIPT"
}

@test "script requires code owner review" {
@test "script requires code owner review (issue #323)" {
grep -qE '^[[:space:]]+require_code_owner_review[[:space:]]*:[[:space:]]*true[[:space:]]*,?[[:space:]]*$' "$SCRIPT"
}

Expand All @@ -44,6 +50,10 @@ SCRIPT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)/apply-pr-quality-rule
grep -qE '^[[:space:]]+require_last_push_approval[[:space:]]*:[[:space:]]*true[[:space:]]*,?[[:space:]]*$' "$SCRIPT"
}

@test "script allows only the squash merge method" {
grep -qE '^[[:space:]]+allowed_merge_methods[[:space:]]*:[[:space:]]*\[[[:space:]]*"squash"[[:space:]]*\][[:space:]]*$' "$SCRIPT"
@test "script restricts allowed_merge_methods to squash" {
grep -qE 'allowed_merge_methods:\s*\[\s*"squash"\s*\]' "$SCRIPT"
}
Comment thread
don-petry marked this conversation as resolved.
Comment thread
Copilot marked this conversation as resolved.

@test "script declares a pull_request rule type" {
grep -qE 'type:\s*"pull_request"' "$SCRIPT"
}
Comment thread
don-petry marked this conversation as resolved.
2 changes: 1 addition & 1 deletion .github/scripts/tests/apply-repo-settings.bats
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ SCRIPT="$(cd "$(dirname "$BATS_TEST_FILENAME")/.." && pwd)/apply-repo-settings.s
grep -q 'apply-code-quality-ruleset.sh' "$SCRIPT"
}

@test "script wires in pr-quality ruleset application (issue #324)" {
@test "script wires in pr-quality ruleset application (issues #323, #324)" {
grep -q 'apply-pr-quality-ruleset.sh' "$SCRIPT"
}
Loading