Repository navigation
feat(dev-lead): dev-lead:hands-off label to exclude infra PRs from the agent #454
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 all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
fd65bad
feat(dev-lead): skip PRs/issues labeled dev-lead:hands-off
claude ead3a85
fix(reviews): address review comments [skip ci-relay]
donpetry-bot c16ac99
fix(reviews): address review comments [skip ci-relay]
donpetry-bot 402a55e
fix(reviews): address review comments [skip ci-relay]
donpetry-bot 4a5ff44
fix(reviews): address review comments [skip ci-relay]
donpetry-bot 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
29 changes: 29 additions & 0 deletions
29
tests/dev-lead/fixtures/events/issues_labeled_dev_lead_hands_off.json
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,29 @@ | ||
| { | ||
| "_test_expected_intent": "skip", | ||
| "action": "labeled", | ||
| "issue": { | ||
| "number": 100, | ||
| "title": "feat: implement OAuth2 support", | ||
| "body": "We need to add OAuth2 authentication support for third-party integrations.\n\n## Requirements\n- Support Google OAuth2\n- Support GitHub OAuth2\n- Add token refresh logic", | ||
| "state": "open", | ||
| "author_association": "OWNER", | ||
| "labels": [ | ||
| { | ||
| "name": "dev-lead" | ||
| }, | ||
| { | ||
| "name": "dev-lead:hands-off" | ||
| } | ||
| ] | ||
| }, | ||
| "label": { | ||
| "name": "dev-lead" | ||
| }, | ||
| "repository": { | ||
| "full_name": "petry-projects/.github-private" | ||
| }, | ||
| "sender": { | ||
| "login": "donpetry", | ||
| "type": "User" | ||
| } | ||
| } |
45 changes: 45 additions & 0 deletions
45
tests/dev-lead/fixtures/events/pr_review_comment_copilot_hands_off.json
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,45 @@ | ||
| { | ||
| "_test_expected_intent": "skip", | ||
| "action": "created", | ||
| "comment": { | ||
| "id": 2001, | ||
| "body": "This function has a potential null pointer dereference on line 42.", | ||
| "path": "src/utils/helpers.js", | ||
| "line": 42, | ||
| "user": { | ||
| "login": "copilot-pull-request-reviewer[bot]", | ||
| "type": "Bot" | ||
| } | ||
| }, | ||
| "pull_request": { | ||
| "number": 58, | ||
| "title": "feat: utility functions", | ||
| "state": "open", | ||
| "author_association": "OWNER", | ||
| "head": { | ||
| "sha": "hhh888iii999", | ||
| "ref": "feat/utilities", | ||
| "repo": { | ||
| "full_name": "petry-projects/.github-private" | ||
| } | ||
| }, | ||
| "base": { | ||
| "ref": "main", | ||
| "repo": { | ||
| "full_name": "petry-projects/.github-private" | ||
| } | ||
| }, | ||
| "labels": [ | ||
| { | ||
| "name": "dev-lead:hands-off" | ||
| } | ||
| ] | ||
| }, | ||
| "repository": { | ||
| "full_name": "petry-projects/.github-private" | ||
| }, | ||
| "sender": { | ||
| "login": "copilot-pull-request-reviewer[bot]", | ||
| "type": "Bot" | ||
| } | ||
| } |
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,26 @@ | ||
| { | ||
| "_test_expected_intent": "skip", | ||
| "action": "synchronize", | ||
| "number": 53, | ||
| "pull_request": { | ||
| "number": 53, | ||
| "title": "feat: update dev-lead workflow", | ||
| "body": "Automated fix by dev-lead agent.", | ||
| "state": "open", | ||
| "author_association": "OWNER", | ||
| "head": { | ||
| "sha": "ccc333ddd444", | ||
| "ref": "feat/dev-lead-update", | ||
| "repo": { "full_name": "petry-projects/.github-private" } | ||
| }, | ||
| "base": { | ||
| "ref": "main", | ||
| "repo": { "full_name": "petry-projects/.github-private" } | ||
| }, | ||
| "labels": [ | ||
| { "name": "dev-lead:hands-off" } | ||
| ] | ||
| }, | ||
| "repository": { "full_name": "petry-projects/.github-private" }, | ||
| "sender": { "login": "donpetry-bot", "type": "Bot" } | ||
| } |
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,127 @@ | ||
| #!/usr/bin/env bats | ||
| # Unit tests for dev-lead-intent.sh — the `dev-lead:hands-off` label guard. | ||
| # A PR or issue carrying the label is excluded from the agent regardless of the | ||
| # event that would otherwise route it (so the agent doesn't pile commits onto | ||
| # PRs that modify the dev-lead workflow itself). | ||
|
|
||
| SCRIPT_DIR="$(cd "$(dirname "$BATS_TEST_FILENAME")/../../.." && pwd)" | ||
| INTENT_SCRIPT="$SCRIPT_DIR/scripts/dev-lead-intent.sh" | ||
| FIXTURES_DIR="$SCRIPT_DIR/tests/dev-lead/fixtures/events" | ||
|
|
||
| setup() { | ||
| export GITHUB_ENV="$(mktemp)" | ||
| export GITHUB_OUTPUT="$(mktemp)" | ||
| export BOT_USER="donpetry-bot" | ||
| export TRUSTED_BOTS="copilot-pull-request-reviewer[bot],gemini-code-assist[bot],sonarqubecloud[bot],coderabbitai[bot],chatgpt-codex-connector[bot]" | ||
| export TRIGGER_PHRASES="@dev-lead" | ||
| export GITHUB_REPOSITORY="petry-projects/.github-private" | ||
| MOCK_BIN="$(mktemp -d)" | ||
| export PATH="$MOCK_BIN:$PATH" | ||
| } | ||
|
|
||
| teardown() { | ||
| rm -f "$GITHUB_ENV" "$GITHUB_OUTPUT" | ||
| rm -rf "$MOCK_BIN" | ||
| } | ||
|
|
||
| _get_env() { | ||
| local key="$1" | ||
| grep "^${key}=" "$GITHUB_ENV" | cut -d= -f2- | head -1 | ||
| } | ||
|
|
||
| @test "hands-off: bot review comment on a labeled PR → skip (not fix-reviews)" { | ||
| export GITHUB_EVENT_NAME="pull_request_review_comment" | ||
| export GITHUB_EVENT_PATH="$FIXTURES_DIR/pr_review_comment_copilot_hands_off.json" | ||
|
|
||
| run bash "$INTENT_SCRIPT" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [ "$(_get_env INTENT_TYPE)" = "skip" ] | ||
| [ "$(_get_env INTENT_REASON)" = "hands-off-label" ] | ||
| } | ||
|
|
||
| @test "hands-off: control — same bot review comment without the label → fix-reviews" { | ||
| export GITHUB_EVENT_NAME="pull_request_review_comment" | ||
| export GITHUB_EVENT_PATH="$FIXTURES_DIR/pr_review_comment_copilot.json" | ||
|
|
||
| run bash "$INTENT_SCRIPT" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [ "$(_get_env INTENT_TYPE)" = "fix-reviews" ] | ||
| } | ||
|
|
||
| @test "hands-off: issue labeled dev-lead but also hands-off → skip (no pickup)" { | ||
| export GITHUB_EVENT_NAME="issues" | ||
| export GITHUB_EVENT_PATH="$FIXTURES_DIR/issues_labeled_dev_lead_hands_off.json" | ||
|
|
||
| run bash "$INTENT_SCRIPT" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [ "$(_get_env INTENT_TYPE)" = "skip" ] | ||
| [ "$(_get_env INTENT_REASON)" = "hands-off-label" ] | ||
| } | ||
|
|
||
| @test "hands-off: bot sync on labeled PR → skip with hands-off-label (not dev-lead-own-commit)" { | ||
| export GITHUB_EVENT_NAME="pull_request" | ||
| export GITHUB_EVENT_PATH="$FIXTURES_DIR/pr_sync_bot_hands_off.json" | ||
|
|
||
| run bash "$INTENT_SCRIPT" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [ "$(_get_env INTENT_TYPE)" = "skip" ] | ||
| [ "$(_get_env INTENT_REASON)" = "hands-off-label" ] | ||
| } | ||
|
|
||
| @test "hands-off: repository_dispatch ci-failure for labeled PR → skip" { | ||
| # Mock gh to return the hands-off label for the dispatch PR | ||
| cat > "$MOCK_BIN/gh" << 'GHEOF' | ||
| #!/usr/bin/env bash | ||
| echo "dev-lead:hands-off" | ||
| GHEOF | ||
| chmod +x "$MOCK_BIN/gh" | ||
|
|
||
| export GITHUB_EVENT_NAME="repository_dispatch" | ||
| export GITHUB_EVENT_PATH="$FIXTURES_DIR/repository_dispatch_ci_failure.json" | ||
|
|
||
| run bash "$INTENT_SCRIPT" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [ "$(_get_env INTENT_TYPE)" = "skip" ] | ||
| [ "$(_get_env INTENT_REASON)" = "hands-off-label" ] | ||
| } | ||
|
|
||
| @test "hands-off: repository_dispatch ci-failure for unlabeled PR → fix-ci (control)" { | ||
| # Mock gh to return no labels | ||
| cat > "$MOCK_BIN/gh" << 'GHEOF' | ||
| #!/usr/bin/env bash | ||
| exit 0 | ||
| GHEOF | ||
| chmod +x "$MOCK_BIN/gh" | ||
|
|
||
| export GITHUB_EVENT_NAME="repository_dispatch" | ||
| export GITHUB_EVENT_PATH="$FIXTURES_DIR/repository_dispatch_ci_failure.json" | ||
|
|
||
| run bash "$INTENT_SCRIPT" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [ "$(_get_env INTENT_TYPE)" = "fix-ci" ] | ||
| } | ||
|
|
||
| @test "hands-off: repository_dispatch ci-failure with API error → skip (fail closed)" { | ||
| # Mock gh to simulate a failure (e.g. token lacks issue read access) | ||
| cat > "$MOCK_BIN/gh" << 'GHEOF' | ||
| #!/usr/bin/env bash | ||
| echo "gh: request failed: HTTP 403" >&2 | ||
| exit 1 | ||
| GHEOF | ||
| chmod +x "$MOCK_BIN/gh" | ||
|
|
||
| export GITHUB_EVENT_NAME="repository_dispatch" | ||
| export GITHUB_EVENT_PATH="$FIXTURES_DIR/repository_dispatch_ci_failure.json" | ||
|
|
||
| run bash "$INTENT_SCRIPT" | ||
|
|
||
| [ "$status" -eq 0 ] | ||
| [ "$(_get_env INTENT_TYPE)" = "skip" ] | ||
| [ "$(_get_env INTENT_REASON)" = "label-lookup-error" ] | ||
| } |
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.