Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(agent/agentcontainers): filter out "is test run" devcontainers #18568

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

Conversation

mafredri
Copy link
Member

@mafredri mafredri commented Jun 25, 2025

This change filters out "devcontainer.is_test_run" devcontainers, a label set by @devconainters/cli when running tests.

Related #18545

image

@mafredri mafredri changed the title fix(agent/agentcontainers): filter out "is a test" devcontainers fix(agent/agentcontainers): filter out "is test run" devcontainers Jun 25, 2025
Copy link
Contributor

@Copilot 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

Adds support to exclude devcontainers marked as test runs by introducing a new label and adjusting the filtering logic, along with tests to verify this behavior.

  • Introduce DevcontainerIsTestRunLabel constant
  • Update processUpdatedContainersLocked to handle the new test-run label
  • Add test cases that include containers labeled as test runs

Reviewed Changes

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

File Description
agent/agentcontainers/devcontainer.go Define DevcontainerIsTestRunLabel constant
agent/agentcontainers/api.go Modify include/filter logic to account for the test-run label
agent/agentcontainers/api_test.go Insert test cases for containers with DevcontainerIsTestRunLabel

@@ -571,7 +571,8 @@ func (api *API) processUpdatedContainersLocked(ctx context.Context, updated code
slog.F("config_file", configFile),
)

if len(api.containerLabelIncludeFilter) > 0 {
// Filter out devcontainer tests, unless explicitly set in include filters.
if len(api.containerLabelIncludeFilter) > 0 || container.Labels[DevcontainerIsTestRunLabel] == "true" {

This comment was marked as off-topic.

Comment on lines 797 to 804
ID: "test-container-1",
FriendlyName: "test-container-1",
Running: true,
Labels: map[string]string{
agentcontainers.DevcontainerLocalFolderLabel: "/workspace/test1",
agentcontainers.DevcontainerConfigFileLabel: "/workspace/test1/.devcontainer/devcontainer.json",
agentcontainers.DevcontainerIsTestRunLabel: "true",
},
Copy link
Preview

Copilot AI Jun 25, 2025

Choose a reason for hiding this comment

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

[nitpick] The test block for a test-container-1 with DevcontainerIsTestRunLabel is duplicated across multiple test cases. Consider extracting this repeated setup into a helper function or shared test data to reduce duplication.

Suggested change
ID: "test-container-1",
FriendlyName: "test-container-1",
Running: true,
Labels: map[string]string{
agentcontainers.DevcontainerLocalFolderLabel: "/workspace/test1",
agentcontainers.DevcontainerConfigFileLabel: "/workspace/test1/.devcontainer/devcontainer.json",
agentcontainers.DevcontainerIsTestRunLabel: "true",
},
getTestContainer1(),

Copilot uses AI. Check for mistakes.

Copy link
Contributor

@DanielleMaywood DanielleMaywood left a comment

Choose a reason for hiding this comment

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

Nice

@mafredri mafredri marked this pull request as ready for review June 25, 2025 10:55
@mafredri mafredri enabled auto-merge (squash) June 25, 2025 10:55
@mafredri mafredri merged commit 434b546 into main Jun 25, 2025
35 checks passed
@mafredri mafredri deleted the mafredri/fix-agent-agentcontainers-filter-test-containers branch June 25, 2025 11:06
@github-actions github-actions bot locked and limited conversation to collaborators Jun 25, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants