chore: Add script to detect which tests to run in CI#1563
chore: Add script to detect which tests to run in CI#1563HofmeisterAn merged 6 commits intodevelopfrom
Conversation
✅ Deploy Preview for testcontainers-dotnet ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
Summary by CodeRabbit
WalkthroughThe changes implement selective test execution in CI pipelines by analyzing changed files and branch context. A new decision engine in Filter-TestProjects.ps1 filters which test projects run based on protected branches, global changes, and module-specific patterns. Collection scripts ensure safe JSON output, and workflow conditions prevent running CI jobs when no tests are collected. Changes
Sequence DiagramsequenceDiagram
actor Workflow as CI Workflow
participant Collect as Collect-TestProjects.ps1
participant Filter as Filter-TestProjects.ps1
participant SRT as Should-RunTests
participant Env as Environment<br/>(Branch, Changed Files)
Workflow->>Collect: Invoke with test projects
Collect->>Filter: Pipe test projects
loop For each test project
Filter->>SRT: Invoke Should-RunTests(ModuleName)
SRT->>Env: Read branch & changed files
alt Protected Branch
SRT-->>Filter: Include test
else Global Changes Detected
SRT-->>Filter: Include test
else Module-Specific Changes
SRT-->>Filter: Include test
else No Relevant Changes
SRT-->>Filter: Skip test
end
end
Filter->>Collect: Output filtered projects
Collect->>Workflow: Return JSON array or []
alt Non-empty test-projects
Workflow->>Workflow: Run CI job
else Empty test-projects
Workflow->>Workflow: Skip CI job (conditional)
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20–25 minutes
Poem
Pre-merge checks and finishing touches❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
✨ Finishing touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Actionable comments posted: 1
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (4)
.github/scripts/Collect-TestProjects.ps1(1 hunks).github/scripts/Filter-TestProjects.ps1(1 hunks).github/workflows/cicd.yml(1 hunks).github/workflows/test-report.yml(1 hunks)
I think file extensions are not necessary here, regex matching $GLOBAL_PATTERNS probably covers all cases. I used to check extensions in my version just to shorten $GLOBAL_PATTERNS a bit (mine has only "src/Testcontainers/"). |
What does this PR do?
This PR adds a script that filters which test projects need to run based on the list of changed files.
The CI workflow gathers all available test projects and passes them to the script for filtering.
For the
mainanddevelopbranches, all tests still run as usual.@digital88 WDYT? It's quite aligned with your version. This version doesn't yet make use of file extensions, which we should probably include. I also like the comments and explanations in your version, which we should add as well.
Why is it important?
This should help reduce CI usage and overall build time, especially for pull requests.
Related issues