-
Notifications
You must be signed in to change notification settings - Fork 0
GIT-869c63k1e: enforce ClickUp branch/PR/commit linking guardrails #89
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
TonyCasey
merged 10 commits into
main
from
codex/GIT-869c63k1e_clickup-linking-guardrails
Feb 17, 2026
Merged
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
de28a19
chore: add claude to test.txt
TonyCasey 487fc1a
Add codex to test file
TonyCasey d6e2dce
feat: add runtime.json for cross-hook agent/model detection (GIT-123)
TonyCasey 45c8607
fix: address PR review comments
TonyCasey 12941eb
chore: enforce ClickUp linking guardrails GIT-869c63k1e
TonyCasey 033ba7c
test: reduce duplication in runtime service tests GIT-869c63k1e
TonyCasey c9980e7
test: remove duplicated runtime read assertions GIT-869c63k1e
TonyCasey 3d90836
fix: address review comments in runtime and stop handler GIT-869c63k1e
TonyCasey 2786409
ci: enforce sonar and inline review governance GIT-869c63k1e
TonyCasey 8380710
fix: address PR governance and review feedback GIT-869c63k1e
TonyCasey 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,14 @@ | ||
| ## Summary | ||
|
|
||
| Describe what changed and why. | ||
|
|
||
| ## ClickUp Task | ||
|
|
||
| Task ID: `GIT-` | ||
|
|
||
| Task Link: https://app.clickup.com/t/ | ||
|
|
||
| ## Validation | ||
|
|
||
| - [ ] Build passes locally | ||
| - [ ] Tests pass locally |
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,34 @@ | ||
| name: ClickUp Linking Checks | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, edited, synchronize, reopened, ready_for_review] | ||
| branches: [main] | ||
|
|
||
| jobs: | ||
| validate-clickup-linking: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Validate branch and PR include ClickUp task ID | ||
| env: | ||
| BRANCH_NAME: ${{ github.event.pull_request.head.ref }} | ||
| PR_TITLE: ${{ github.event.pull_request.title }} | ||
| PR_BODY: ${{ github.event.pull_request.body }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| BRANCH_NO_PREFIX="${BRANCH_NAME#codex/}" | ||
|
|
||
| if [[ ! "$BRANCH_NO_PREFIX" =~ ^GIT-[A-Za-z0-9]+_.+ ]]; then | ||
| echo "Branch name must match codex/GIT-<taskId>_<taskName> (example: codex/GIT-123abc_fix-mcp-auth)." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| TASK_ID="${BRANCH_NO_PREFIX%%_*}" | ||
|
|
||
| if [[ "$PR_TITLE" != *"$TASK_ID"* ]] && [[ "${PR_BODY:-}" != *"$TASK_ID"* ]]; then | ||
| echo "PR title or body must include task ID: $TASK_ID" >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "ClickUp linking checks passed for task ID: $TASK_ID" |
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,148 @@ | ||
| name: PR Governance | ||
|
|
||
| on: | ||
| pull_request: | ||
| types: [opened, edited, synchronize, reopened, ready_for_review] | ||
| branches: [main] | ||
|
|
||
| permissions: | ||
| contents: read | ||
| pull-requests: read | ||
|
|
||
| jobs: | ||
| enforce-governance: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Enforce Sonar quality gate and new issues policy | ||
| env: | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| SONAR_ORGANIZATION: ${{ vars.SONAR_ORGANIZATION || github.repository_owner }} | ||
| SONAR_PROJECT_KEY: ${{ vars.SONAR_PROJECT_KEY || replace(github.repository, '/', '_') }} | ||
| SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} | ||
| SONAR_MAX_POLL_ITERATIONS: "30" | ||
| SONAR_POLL_INTERVAL_SECONDS: "10" | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| MAX_POLL_ITERATIONS="${SONAR_MAX_POLL_ITERATIONS:-30}" | ||
| POLL_INTERVAL_SECONDS="${SONAR_POLL_INTERVAL_SECONDS:-10}" | ||
| SONAR_AUTH_ARGS=() | ||
| if [[ -n "${SONAR_TOKEN:-}" ]]; then | ||
| SONAR_AUTH_ARGS=(-u "${SONAR_TOKEN}:") | ||
| fi | ||
|
|
||
| quality_status="" | ||
| attempt=1 | ||
| while (( attempt <= MAX_POLL_ITERATIONS )); do | ||
| response="$( | ||
| curl -sS "${SONAR_AUTH_ARGS[@]}" \ | ||
| "https://sonarcloud.io/api/project_pull_requests/list?organization=${SONAR_ORGANIZATION}&project=${SONAR_PROJECT_KEY}" | ||
| )" | ||
| quality_status="$(jq -r --arg pr "${PR_NUMBER}" '.pullRequests[]? | select(.key == $pr) | .status.qualityGateStatus' <<<"$response")" | ||
|
|
||
| if [[ -n "$quality_status" && "$quality_status" != "NONE" ]]; then | ||
| break | ||
| fi | ||
|
|
||
| sleep "${POLL_INTERVAL_SECONDS}" | ||
| attempt=$((attempt + 1)) | ||
| done | ||
|
|
||
| if [[ -z "$quality_status" || "$quality_status" == "NONE" ]]; then | ||
| echo "Sonar result not ready for PR #${PR_NUMBER}." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$quality_status" != "OK" ]]; then | ||
| echo "Sonar quality gate must pass. Current status: ${quality_status}" >&2 | ||
|
TonyCasey marked this conversation as resolved.
|
||
| exit 1 | ||
| fi | ||
|
|
||
| issues_response="$( | ||
| curl -sS "${SONAR_AUTH_ARGS[@]}" \ | ||
| "https://sonarcloud.io/api/issues/search?organization=${SONAR_ORGANIZATION}&componentKeys=${SONAR_PROJECT_KEY}&pullRequest=${PR_NUMBER}&issueStatuses=OPEN,CONFIRMED&sinceLeakPeriod=true&ps=1" | ||
| )" | ||
| new_issues="$(jq -r '.total // 0' <<<"$issues_response")" | ||
|
|
||
| if [[ "$new_issues" != "0" ]]; then | ||
| echo "PR introduces ${new_issues} Sonar new issue(s). New issues must be 0." >&2 | ||
| exit 1 | ||
| fi | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| echo "Sonar checks passed: quality gate OK and 0 new issues." | ||
|
|
||
| - name: Enforce inline review replies and resolved threads | ||
| env: | ||
| PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| REPO_OWNER: ${{ github.repository_owner }} | ||
| REPO_NAME: ${{ github.event.repository.name }} | ||
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| run: | | ||
| set -euo pipefail | ||
|
|
||
| query=' | ||
| query($owner:String!, $repo:String!, $number:Int!) { | ||
| repository(owner:$owner, name:$repo) { | ||
| pullRequest(number:$number) { | ||
| author { login } | ||
| reviewThreads(first:100) { | ||
| pageInfo { | ||
| hasNextPage | ||
| } | ||
| nodes { | ||
| id | ||
| isResolved | ||
| isOutdated | ||
| comments(first:100) { | ||
|
TonyCasey marked this conversation as resolved.
|
||
| pageInfo { | ||
| hasNextPage | ||
| } | ||
| nodes { | ||
| author { login } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| } | ||
| }' | ||
|
|
||
| response="$(gh api graphql -f query="$query" -F owner="$REPO_OWNER" -F repo="$REPO_NAME" -F number="$PR_NUMBER")" | ||
|
TonyCasey marked this conversation as resolved.
|
||
| pr_author="$(jq -r '.data.repository.pullRequest.author.login' <<<"$response")" | ||
|
|
||
| has_more_threads="$(jq -r '.data.repository.pullRequest.reviewThreads.pageInfo.hasNextPage' <<<"$response")" | ||
| has_more_comments="$(jq -r ' | ||
| .data.repository.pullRequest.reviewThreads.nodes | ||
| | any(.comments.pageInfo.hasNextPage == true) | ||
| ' <<<"$response")" | ||
|
|
||
| if [[ "$has_more_threads" == "true" || "$has_more_comments" == "true" ]]; then | ||
| echo "Review thread pagination limit reached; increase pagination handling before enforcing this check." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| unresolved_count="$(jq -r ' | ||
| .data.repository.pullRequest.reviewThreads.nodes | ||
| | map(select(.isOutdated | not)) | ||
| | map(select(.isResolved | not)) | ||
| | length | ||
| ' <<<"$response")" | ||
|
|
||
| missing_inline_reply_count="$(jq -r --arg author "$pr_author" ' | ||
| .data.repository.pullRequest.reviewThreads.nodes | ||
| | map(select(.isOutdated | not)) | ||
| | map(select(([.comments.nodes[]?.author.login] | index($author)) | not)) | ||
| | length | ||
| ' <<<"$response")" | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
|
|
||
| if [[ "$missing_inline_reply_count" != "0" ]]; then | ||
| echo "Each active review thread must include an inline reply from PR author (${pr_author})." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| if [[ "$unresolved_count" != "0" ]]; then | ||
| echo "All active review threads must be resolved before merge." >&2 | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Review thread checks passed." | ||
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
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
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.