Skip to content

Update test cleaner workflow to delete branches with prefix test-safe-outputs-custom-engine/#607

Merged
pelikhan merged 3 commits intomainfrom
copilot/update-test-cleaner-workflow
Sep 9, 2025
Merged

Update test cleaner workflow to delete branches with prefix test-safe-outputs-custom-engine/#607
pelikhan merged 3 commits intomainfrom
copilot/update-test-cleaner-workflow

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Sep 9, 2025

The test cleaner workflow was not cleaning up test branches created by the test-safe-outputs-custom-engine workflow, leading to branch accumulation over time.

Problem

The test-safe-outputs-custom-engine workflow creates branches with names starting with test-safe-outputs-custom-engine/ when testing pull request creation functionality. These branches were not being cleaned up by the existing test cleaner workflow, which only handled:

  • Issues with prefix "[Custom Engine Test]"
  • Pull requests with prefix "[Custom Engine Test]"
  • Discussions with prefix "[Custom Engine Test]"

Solution

Extended the test cleaner workflow to also delete branches matching the pattern test-safe-outputs-custom-engine/*:

  1. Added branch cleanup functionality - Uses GitHub REST API to list all repository branches and filters for those starting with the specified prefix
  2. Updated permissions - Changed contents permission from read to write to allow branch deletion operations
  3. Added error handling - Includes comprehensive error handling to ensure cleanup continues even if individual branch deletions fail
  4. Maintained backward compatibility - All existing cleanup functionality remains unchanged

Technical Details

  • Uses github.rest.repos.listBranches to retrieve all branches (paginated with 100 per page)
  • Filters branches using JavaScript startsWith() method for the prefix test-safe-outputs-custom-engine/
  • Deletes branches using github.rest.git.deleteRef with proper ref formatting (heads/${branchName})
  • Provides console logging for monitoring cleanup operations
  • Gracefully handles API errors and continues processing remaining branches

Testing

  • Validated workflow syntax with actionlint
  • Confirmed YAML syntax is valid
  • All existing tests continue to pass
  • Successfully ran make agent-finish validation suite

Warning

Firewall rules blocked me from connecting to one or more addresses (expand for details)

I tried to connect to the following addresses, but was blocked by firewall rules:

  • api.contoso.com
    • Triggering command: /tmp/go-build2776020575/b278/cli.test -test.testlogfile=/tmp/go-build2776020575/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build3164563366/b278/cli.test -test.testlogfile=/tmp/go-build3164563366/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)
    • Triggering command: /tmp/go-build3834470846/b278/cli.test -test.testlogfile=/tmp/go-build3834470846/b278/testlog.txt -test.paniconexit0 -test.timeout=10m0s -test.v=true (dns block)

If you need me to access, download, or install something from one of these locations, you can either:


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

…-outputs-custom-engine/

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Update test cleaner workflow to delete all branches starting with "test-safe-outputs-custom-engine/" Update test cleaner workflow to delete branches with prefix test-safe-outputs-custom-engine/ Sep 9, 2025
Copilot AI requested a review from pelikhan September 9, 2025 05:38
@pelikhan pelikhan marked this pull request as ready for review September 9, 2025 05:50
@pelikhan pelikhan merged commit 398efa9 into main Sep 9, 2025
9 checks passed
@pelikhan pelikhan deleted the copilot/update-test-cleaner-workflow branch September 9, 2025 13:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants