Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
94 changes: 94 additions & 0 deletions .github/pr-shape-check.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
#!/bin/bash
set -euo pipefail

fail() {
printf '%s\n' "$1" >&2
exit 1
}

: "${PR_HEAD_REF:?PR_HEAD_REF is required}"
: "${PR_BASE_REF:?PR_BASE_REF is required}"
: "${PR_NUMBER:?PR_NUMBER is required}"

is_sync_ref() {
local ref=$1
[[ $ref == cursor/upstream-changes-pr-* || $ref == cursor/fork-upstream-updates-* ]]
}

if [[ -n ${PR_OPEN_JSON_FILE:-} ]]; then
open_json=$(cat "$PR_OPEN_JSON_FILE")
else
: "${GITHUB_REPOSITORY:?GITHUB_REPOSITORY is required}"
open_json=$(gh pr list --repo "$GITHUB_REPOSITORY" --state open --limit 200 --json number,headRefName,baseRefName) ||
fail "Could not list open pull requests. The shape check needs that list."
fi

open_count=$(jq 'length' <<<"$open_json")
if (( open_count == 200 )); then
fail "The open pull request list stopped at 200, so a second sync could be missing. Wait, then rerun the check."
fi

sync_heads=$(jq -r --arg n "$PR_NUMBER" '
[ .[]
| select((.number | tostring) != $n)
| select(
(.headRefName | startswith("cursor/upstream-changes-pr-"))
or (.headRefName | startswith("cursor/fork-upstream-updates-"))
)
| "#\(.number) \(.headRefName) -> \(.baseRefName)"
] | .[]
' <<<"$open_json")

if is_sync_ref "$PR_HEAD_REF"; then
if [[ $PR_BASE_REF != "quattro" ]]; then
fail "A sync targets quattro. Retarget this pull request to quattro."
fi
if [[ -n $sync_heads ]]; then
fail "Another sync is already open:
${sync_heads}
Push onto that branch, or wait until it merges."
fi
elif [[ $PR_BASE_REF == "quattro" ]]; then
if [[ -z ${FILE_COUNT:-} ]]; then
: "${HEAD_SHA:?HEAD_SHA is required to count files}"
: "${BASE_SHA:?BASE_SHA is required to count files}"
if ! git cat-file -e "${BASE_SHA}^{commit}" 2>/dev/null; then
git fetch --no-tags origin "$PR_BASE_REF"
fi
if ! git cat-file -e "${HEAD_SHA}^{commit}" 2>/dev/null; then
git fetch --no-tags origin "$HEAD_SHA"
fi
FILE_COUNT=$(git diff --name-only "${BASE_SHA}...${HEAD_SHA}" | grep -c . || true)
fi
if (( FILE_COUNT > 40 )); then
fail "This topic changes ${FILE_COUNT} files. The cap is 40. Split it into a stacked pull request set whose root targets quattro."
fi
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
else
root=$(jq -c --arg base "$PR_BASE_REF" '[.[] | select(.headRefName == $base)]' <<<"$open_json")
root_count=$(jq 'length' <<<"$root")
if (( root_count == 0 )); then
fail "This pull request stacks on ${PR_BASE_REF}, and no open pull request from that branch targets quattro. Open that root into quattro, or retarget this pull request to quattro."
fi
if (( root_count > 1 )); then
fail "More than one open pull request has head ${PR_BASE_REF}. Leave one root, and point that root at quattro."
fi
root_base=$(jq -r '.[0].baseRefName' <<<"$root")
root_number=$(jq -r '.[0].number' <<<"$root")
if [[ $root_base != "quattro" ]]; then
fail "Pull request #${root_number} is the stack root and it targets ${root_base}. The root must target quattro."
fi
fi

if [[ ${PR_MERGED:-false} == "true" ]]; then
: "${MERGE_SHA:?MERGE_SHA is required once the pull request has merged}"
: "${BASE_SHA:?BASE_SHA is required once the pull request has merged}"
if ! git cat-file -e "${MERGE_SHA}^{commit}" 2>/dev/null; then
git fetch --no-tags origin "$MERGE_SHA"
fi
first=$(git rev-parse "${MERGE_SHA}^1")
if [[ $first != "$BASE_SHA" ]]; then
fail "The merge commit ${MERGE_SHA} has first parent ${first}. The pull request named ${PR_BASE_REF} at ${BASE_SHA}. Merge this pull request into ${PR_BASE_REF}. Merge only the sync pull request into quattro."
fi
Comment thread
cursor[bot] marked this conversation as resolved.
Resolved
fi

printf 'ok - %s into %s\n' "$PR_HEAD_REF" "$PR_BASE_REF"
50 changes: 50 additions & 0 deletions .github/workflows/pr-shape.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Check pull request shape

# Syncs, topics on quattro, and one-deep stacks are the three shapes an agent
# can open without landing an import on the wrong base. The two shell tests
# are the layout and polkit checks that already exist. This job runs them.
on:
pull_request:
types: [opened, synchronize, reopened, edited, closed]

permissions:
contents: read
pull-requests: read

jobs:
pr-shape:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Check the pull request shape
env:
PR_HEAD_REF: ${{ github.head_ref }}
PR_BASE_REF: ${{ github.base_ref }}
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_MERGED: ${{ github.event.pull_request.merged }}
MERGE_SHA: ${{ github.event.pull_request.merge_commit_sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
GH_TOKEN: ${{ github.token }}
GITHUB_REPOSITORY: ${{ github.repository }}
run: bash .github/pr-shape-check.sh
- name: Install test commands
if: github.event.action != 'closed'
run: |
sudo apt-get update
sudo apt-get install -y jq lua5.4
if ! command -v lua >/dev/null; then
sudo ln -sf "$(command -v lua5.4)" /usr/bin/lua
fi
- uses: actions/setup-node@v7
if: github.event.action != 'closed'
with:
node-version: 24
- name: Layout and polkit tests
if: github.event.action != 'closed'
run: |
bash test/shell.d/hyprland-floating-workspaces-test.sh
bash test/shell.d/polkit-face-test.sh
5 changes: 0 additions & 5 deletions test/shell.d/unowned-system-paths-test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,6 @@ allowed = {
# upgrade carrying the handler is the one that would hit the conflict, and the
# handler only helps once it is on disk. Package it the release after.
"/usr/lib/chromium/initial_preferences",
# USB and Thunderbolt approval copy their polkit actions from default/polkit
# when that feature is set up. The action exists only for that setup; the
# two files are the whole exception.
"/usr/share/polkit-1/actions/org.omarchy.usb.policy",
"/usr/share/polkit-1/actions/org.omarchy.thunderbolt.policy",
}

# One-time 3.x upgrade. It runs before this rule existed and cannot be made to
Expand Down
Loading