Repository navigation
ci(pr): require a sync, a capped topic, or a native stack onto quattro #83
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 2 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0f89627
test(polkit): drop the stale unowned-path allowlist entries
cursoragent a9748a2
ci(pr): reject a pull that is not a sync, a topic, or one stack
cursoragent b02fc39
ci(pr): let the translation sync exceed the file cap
cursoragent c617f26
ci(pr): judge a merge against the fetched base tip
cursoragent a5639dd
ci(pr): accept native stacks of any depth and cap every layer
mark-groves bcff904
docs(agents): prefer native stacked pull requests via gh stack
mark-groves 536dab2
ci(pr): mark the GraphQL query variables for shellcheck
mark-groves File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 | ||
| 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 | ||
|
cursor[bot] marked this conversation as resolved.
Resolved
|
||
| fi | ||
|
|
||
| printf 'ok - %s into %s\n' "$PR_HEAD_REF" "$PR_BASE_REF" | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.