Skip to content

Conversation

@radical
Copy link
Member

@radical radical commented Dec 15, 2025

This PR introduces GitHub issue/PR comment commands for managing test attributes:

New Commands as comments

Quarantine Tests (flaky tests)

  • /quarantine-test <test-name> <issue-url> - Add [QuarantinedTest] attribute
  • /unquarantine-test <test-name> - Remove [QuarantinedTest] attribute

Disable Tests (ActiveIssue)

  • /disable-test <test-name> <issue-url> - Add [ActiveIssue] attribute
  • /enable-test <test-name> - Remove [ActiveIssue] attribute

Usage

Commands can be used on:

  • Issues: Creates a new PR with the changes
  • Pull Requests: Pushes changes directly to the PR branch
  • With --target-pr: Pushes to a specified PR regardless of where command is posted

Examples

/quarantine-test Namespace.Class.TestMethod https://github.com/dotnet/aspire/issues/1234
/disable-test Namespace.Class.FlakyTest https://github.com/dotnet/aspire/issues/5678
/unquarantine-test Namespace.Class.TestMethod
/enable-test Namespace.Class.TestMethod

Implementation Details

  • Uses QuarantineTools from tools/QuarantineTools for source modifications
  • Supports both quarantine mode ([QuarantinedTest]) and activeissue mode ([ActiveIssue])
  • Validates user has write access before executing
  • Posts progress comments and links to resulting PR

This PR introduces GitHub issue/PR comment commands for managing test attributes:

## New Commands

### Quarantine Tests (flaky tests)
- `/quarantine-test <test-name> <issue-url>` - Add [QuarantinedTest] attribute
- `/unquarantine-test <test-name>` - Remove [QuarantinedTest] attribute

### Disable Tests (ActiveIssue)
- `/disable-test <test-name> <issue-url>` - Add [ActiveIssue] attribute
- `/enable-test <test-name>` - Remove [ActiveIssue] attribute

## Usage

Commands can be used on:
- **Issues**: Creates a new PR with the changes
- **Pull Requests**: Pushes changes directly to the PR branch
- **With --target-pr**: Pushes to a specified PR regardless of where command is posted

## Examples

```
/quarantine-test Namespace.Class.TestMethod dotnet#1234
/disable-test Namespace.Class.FlakyTest dotnet#5678
/unquarantine-test Namespace.Class.TestMethod
/enable-test Namespace.Class.TestMethod
```

## Implementation Details

- Uses QuarantineTools from tools/QuarantineTools for source modifications
- Supports both quarantine mode ([QuarantinedTest]) and activeissue mode ([ActiveIssue])
- Validates user has write access before executing
- Posts progress comments and links to resulting PR
Copilot AI review requested due to automatic review settings December 15, 2025 07:58
@radical radical added the area-engineering-systems infrastructure helix infra engineering repo stuff label Dec 15, 2025
@github-actions
Copy link
Contributor

github-actions bot commented Dec 15, 2025

🚀 Dogfood this PR with:

⚠️ WARNING: Do not do this without first carefully reviewing the code of this PR to satisfy yourself it is safe.

curl -fsSL https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.sh | bash -s -- 13558

Or

  • Run remotely in PowerShell:
iex "& { $(irm https://raw.githubusercontent.com/dotnet/aspire/main/eng/scripts/get-aspire-cli-pr.ps1) } 13558"

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new GitHub Actions workflow that allows repository maintainers to manage test attributes (quarantine/disable tests) directly through issue or PR comments using slash commands. The workflow supports four commands: /quarantine-test, /unquarantine-test, /disable-test, and /enable-test, which apply [QuarantinedTest] and [ActiveIssue] attributes respectively.

Key Changes

  • Implements a comprehensive GitHub Actions workflow with permission checks, argument parsing, and PR creation/update logic
  • Supports flexible targeting: creates new PRs from main, pushes to current PR, or pushes to a specified PR via --target-pr
  • Includes detailed documentation explaining command syntax, parameters, examples, and behavior

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 8 comments.

File Description
.github/workflows/apply-test-attributes.yml New workflow implementing slash commands for test attribute management with argument parsing, permission validation, QuarantineTools execution, and PR automation
.github/workflows/README.md Documentation for the new workflow commands including syntax, parameters, examples, and behavior specifications

radical and others added 4 commits December 15, 2025 03:44
Co-authored-by: Copilot <[email protected]>
- Replace execSync with spawnSync for git commands to prevent shell injection
- Add runGit() helper that passes args as array (no shell interpretation)
- Add null check for pr.head.repo when detecting fork PRs
- Addresses Copilot review feedback on PR dotnet#13558
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 16 comments.

Comment on lines 499 to 500
// Branch name is safe: actionVerb is from controlled lookup (Quarantine/Disable/etc), timestamp is numeric
const branchName = `automated/${actionVerb.toLowerCase()}-test-${timestamp}`;
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The comment mentions that actionVerb is "from controlled lookup (Quarantine/Disable/etc)" and timestamp is numeric, explaining safety. However, while actionVerb comes from a controlled lookup, it's worth noting that the toLowerCase() call converts it to lowercase before use in the branch name. Consider adding a comment that the branch name format is: automated/{quarantine|unquarantine|disable|enable}-test-{timestamp} to make this more explicit.

Copilot uses AI. Check for mistakes.
echo "$OUTPUT"

# Save output for failure comment (escape for GitHub Actions)
EOF="EOF_$(date +%s%N)"
Copy link

Copilot AI Dec 15, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The heredoc delimiter uses a timestamp-based unique identifier to prevent collisions. However, the date command with %N (nanoseconds) is not portable to all Unix systems (e.g., macOS's date doesn't support %N). Since this workflow runs on ubuntu-latest, it works fine, but if portability is needed, consider using $RANDOM or $$ (process ID) instead of %N.

Copilot uses AI. Check for mistakes.
For consistency with the rest of the script and to follow safer practices,
use the runGit helper (which uses spawnSync) for git config commands instead
of execSync. This avoids shell injection vulnerabilities as a defense-in-depth
measure, even though the current hardcoded strings were safe.
@radical radical merged commit 67fad29 into dotnet:main Dec 17, 2025
283 of 284 checks passed
@radical radical deleted the disable-tests-action branch December 17, 2025 05:18
@dotnet-policy-service dotnet-policy-service bot added this to the 13.2 milestone Dec 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-engineering-systems infrastructure helix infra engineering repo stuff

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants