-
Notifications
You must be signed in to change notification settings - Fork 1.9k
[None][infra] Using local variables in rerun function #7198
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
Conversation
Signed-off-by: Yiqing Yan <[email protected]>
📝 WalkthroughWalkthroughRefactors rerun logic in jenkins/L0_Test.groovy to use explicit local scoping and per-iteration variables/files. Introduces local variables for rerun test lists, command line construction, flags, XML output, and input file aggregation, avoiding mutation of shared command structures. Control flow and error handling remain unchanged. Changes
Sequence Diagram(s)sequenceDiagram
autonumber
participant J as Jenkins Pipeline
participant R as rerunFailedTests()
participant FS as Filesystem
participant TR as Test Runner
participant RM as Result Merger
J->>R: Invoke rerunFailedTests
R->>FS: Check exists rerun_0.txt
alt rerun file exists
loop times (per-iteration)
R->>FS: Define currentRerunTestList (iteration file)
R->>R: Build newTestCmdLine (filtered + --test-list + --csv + --junit-xml + --reruns)
R->>TR: Execute tests with newTestCmdLine
TR-->>R: JUnit XML, CSV outputs
R->>FS: Collect inputFiles (per-iteration)
end
R->>RM: Merge inputFiles into reports
RM-->>R: Merged results
else no rerun file
R-->>J: Skip reruns
end
R-->>J: Return status (unchanged control flow)
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Suggested reviewers
✨ Finishing Touches🧪 Generate unit tests
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. 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. CodeRabbit Commands (Invoked using PR/Issue comments)Type Other keywords and placeholders
Status, Documentation and Community
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
jenkins/L0_Test.groovy (2)
1181-1189: Declarecountlocally to avoid Groovy CPS/global leakage and potential MissingPropertyException.Inside methods, assigning to an undeclared identifier can resolve to a script/global property under CPS. In parallel stages, this risks cross-stage contamination. Also, depending on compilation context, it may raise a MissingPropertyException.
Recommend declaring
countas a local int.Apply this diff:
- count = sh( + int count = sh( script: "grep -v '^[[:space:]]*\\$' ${currentRerunTestList} | wc -l", returnStdout: true ).trim().toInteger()If you prefer a slightly simpler/robust non-empty line count,
awk 'NF' file | wc -lavoids some locale pitfalls with POSIX classes.
1240-1248: DeclareinputFileslocally to avoid CPS binding bleed and improve readability.
inputFilesis assigned withoutdef, which can become a script-level property under CPS. Make it local.Apply this diff:
- inputFiles = ["${WORKSPACE}/${stageName}/results.xml", + def inputFiles = ["${WORKSPACE}/${stageName}/results.xml", "${WORKSPACE}/${stageName}/rerun_results_1.xml", "${WORKSPACE}/${stageName}/rerun_results_2.xml"]
🧹 Nitpick comments (1)
jenkins/L0_Test.groovy (1)
1209-1219: Avoid mutating the incomingtestCmdLineparameter across iterations. Build a fresh rerun command per attempt.You rebuild
testCmdLineeach loop, but mutating a method parameter is brittle and easy to regress. Construct a newrerunCmdlist instead, then execute it. This isolates rerun customization and keeps the baseline intact.Apply this diff:
- testCmdLine = testCmdLine.findAll { cmd -> + def rerunCmd = testCmdLine.findAll { cmd -> !noNeedLine.any { line -> cmd.contains(line) } && !needToChangeLine.any { line -> cmd.contains(line) } } - testCmdLine += [ + rerunCmd += [ "--test-list=${currentRerunTestList}", "--csv=${WORKSPACE}/${stageName}/rerun_report_${times}.csv", "--junit-xml ${xmlFile}", "--reruns ${times - 1}" ] @@ - ${testCmdLine.join(" ")} + ${rerunCmd.join(" ")}
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
jenkins/L0_Test.groovy(4 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (1)
jenkins/L0_Test.groovy (1)
1170-1176: Good change: scope rerun_0 path locally.Using a local
def rerunTestListforrerun_0.txtreduces accidental leakage into broader scope and keeps the intent clear. Behavior is preserved.
Signed-off-by: Yiqing Yan <[email protected]>
Signed-off-by: Yiqing Yan <[email protected]>
|
/bot run --stage-list "A10-TensorRT-1" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
tests/integration/defs/accuracy/test_cli_flow.py(1 hunks)
🧰 Additional context used
📓 Path-based instructions (2)
**/*.py
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
**/*.py: Python code must target Python 3.8+
Python indentation: 4 spaces, no tabs
Maintain module namespace in imports (from package.subpackage import foo; then use foo.SomeClass())
Python file names use snake_case
Python class names use PascalCase
Python functions/methods and local variables use snake_case; variables starting with a number get k_ prefix (e.g., k_99th_percentile)
Global variables use G_ prefixed UPPER_SNAKE_CASE (e.g., G_MY_GLOBAL)
Constants use UPPER_SNAKE_CASE in Python
Avoid shadowing variables from outer scopes in Python
Initialize all externally visible members of a Python class in init
Prefer docstrings for interfaces used outside a file; comments for local code
Use Google-style docstrings for classes and functions (Sphinx-parsable)
Document attributes/variables inline with short docstrings
Avoid reflection when simple alternatives exist (e.g., prefer explicit parameters over dict(**locals()))
In try/except, catch the narrowest exceptions possible
For duck-typing with try/except, keep try body minimal and put logic in else
Files:
tests/integration/defs/accuracy/test_cli_flow.py
**/*.{cpp,cxx,cc,cu,h,hpp,hxx,hh,cuh,py}
📄 CodeRabbit inference engine (CODING_GUIDELINES.md)
Prepend NVIDIA copyright header (current year) to all source files
Files:
tests/integration/defs/accuracy/test_cli_flow.py
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
|
PR_Github #16365 [ run ] triggered by Bot |
Signed-off-by: Yiqing Yan <[email protected]>
|
/bot run --stage-list "A10-TensorRT-1" |
|
PR_Github #16365 [ run ] completed with state |
|
PR_Github #16387 [ run ] triggered by Bot |
|
PR_Github #16387 [ run ] completed with state |
Signed-off-by: Yiqing Yan <[email protected]>
|
/bot run |
|
PR_Github #16415 [ run ] triggered by Bot |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
jenkins/L0_Test.groovy (2)
1181-1189: Declare loop-local variable ‘count’ to avoid CPS binding leakage and potential compilation issuesInside methods, assigning to an undeclared variable can leak into the script binding under CPS or even fail compilation. Declare it as a local with def (or a type).
Apply this diff:
- count = sh( + def int count = sh( script: "grep -v '^[[:space:]]*\\$' ${currentRerunTestList} | wc -l", returnStdout: true ).trim().toInteger()
1240-1248: Ensure only existing XML files are passed to test_rerun.pytest_rerun.py’s
generate_rerun_reportandmerge_junit_xmlsboth callET.parse(...)on every path in--input-files. If a rerun didn’t occur, itsrerun_results_{n}.xmlwon’t exist and Python will raise FileNotFoundError, causing the Jenkins step to fail. Defensively buildinputFilesusingfileExists(...)in the pipeline.Affected locations:
- jenkins/L0_Test.groovy, lines 1240–1248 (generate_rerun_report)
- jenkins/L0_Test.groovy, lines 1250–1256 (merge_junit_xmls)
Suggested refactor:
- def inputFiles = ["${WORKSPACE}/${stageName}/results.xml", - "${WORKSPACE}/${stageName}/rerun_results_1.xml", - "${WORKSPACE}/${stageName}/rerun_results_2.xml"] + // Always include the original results, then add any existing rerun files + def inputFiles = ["${WORKSPACE}/${stageName}/results.xml"] + ["1","2"].each { t -> + def p = "${WORKSPACE}/${stageName}/rerun_results_${t}.xml" + if (fileExists(p)) { + inputFiles += [p] + } else { + echo "Skipping missing rerun results file: ${p}" + } + }Apply the same pattern before both the
generate_rerun_reportandmerge_junit_xmlsinvocations so that only existing XMLs are merged.
🧹 Nitpick comments (3)
jenkins/L0_Test.groovy (3)
1172-1176: Early-exit on non-rerunnable failures is correct; minor naming nitThe logic to abort reruns when rerun_0.txt exists matches the comment and avoids wasted cycles. Consider renaming the local variable to clarify its purpose (e.g., cannotRerunList) to make future maintenance clearer.
1200-1219: Rerun command reconstruction: non-mutating, per-iteration scoping LGTM; two optional tweaks
- You correctly avoid mutating testCmdLine and strip conflicting flags — nice.
- Optional: include "--reruns" in noNeedLine to future-proof against upstream changes that might add it to the base command.
- Optional: if you want identical junit output verbosity between first run and reruns, keep "-o junit_logging=out-err".
Apply this diff to future-proof the filter:
- def noNeedLine = ["--splitting-algorithm", "--splits", "--group", "--waives-file", "--cov"] + def noNeedLine = ["--splitting-algorithm", "--splits", "--group", "--waives-file", "--cov", "--reruns"]
1220-1223: Minor: consider quoting arguments with spaces in join() (optional)You’re already joining a list of args; a few entries have embedded spaces (e.g., "--junit-xml ${xmlFile}"). Groovy won’t fix quoting for you. It works now, but if a path ever contains spaces, this would break. Optional improvement: quote items with spaces before join.
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
💡 Knowledge Base configuration:
- MCP integration is disabled by default for public repositories
- Jira integration is disabled by default for public repositories
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
jenkins/L0_Test.groovy(5 hunks)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: Pre-commit Check
🔇 Additional comments (3)
jenkins/L0_Test.groovy (3)
1198-1199: Good: localize isRerunFailedDeclaring isRerunFailed with def confines it to the function scope and eliminates parallel-stage races.
1206-1207: Good: per-attempt xmlFile is locally scopedLocal xmlFile avoids cross-attempt clobbering/races.
1523-1527: Call site wiring looks correctCapturing the boolean from rerunFailedTests and surfacing failure preserves existing control flow while enabling the improved rerun behavior.
|
PR_Github #16415 [ run ] completed with state |
|
/bot run |
|
PR_Github #16506 [ run ] triggered by Bot |
|
PR_Github #16506 [ run ] completed with state |
Summary by CodeRabbit
Refactor
Bug Fixes
Description
Test Coverage
GitHub Bot Help
/bot [-h] ['run', 'kill', 'skip', 'reuse-pipeline'] ...Provide a user friendly way for developers to interact with a Jenkins server.
Run
/bot [-h|--help]to print this help message.See details below for each supported subcommand.
run [--reuse-test (optional)pipeline-id --disable-fail-fast --skip-test --stage-list "A10-PyTorch-1, xxx" --gpu-type "A30, H100_PCIe" --test-backend "pytorch, cpp" --add-multi-gpu-test --only-multi-gpu-test --disable-multi-gpu-test --post-merge --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx" --detailed-log --debug(experimental)]Launch build/test pipelines. All previously running jobs will be killed.
--reuse-test (optional)pipeline-id(OPTIONAL) : Allow the new pipeline to reuse build artifacts and skip successful test stages from a specified pipeline or the last pipeline if no pipeline-id is indicated. If the Git commit ID has changed, this option will be always ignored. The DEFAULT behavior of the bot is to reuse build artifacts and successful test results from the last pipeline.--disable-reuse-test(OPTIONAL) : Explicitly prevent the pipeline from reusing build artifacts and skipping successful test stages from a previous pipeline. Ensure that all builds and tests are run regardless of previous successes.--disable-fail-fast(OPTIONAL) : Disable fail fast on build/tests/infra failures.--skip-test(OPTIONAL) : Skip all test stages, but still run build stages, package stages and sanity check stages. Note: Does NOT update GitHub check status.--stage-list "A10-PyTorch-1, xxx"(OPTIONAL) : Only run the specified test stages. Examples: "A10-PyTorch-1, xxx". Note: Does NOT update GitHub check status.--gpu-type "A30, H100_PCIe"(OPTIONAL) : Only run the test stages on the specified GPU types. Examples: "A30, H100_PCIe". Note: Does NOT update GitHub check status.--test-backend "pytorch, cpp"(OPTIONAL) : Skip test stages which don't match the specified backends. Only support [pytorch, cpp, tensorrt, triton]. Examples: "pytorch, cpp" (does not run test stages with tensorrt or triton backend). Note: Does NOT update GitHub pipeline status.--only-multi-gpu-test(OPTIONAL) : Only run the multi-GPU tests. Note: Does NOT update GitHub check status.--disable-multi-gpu-test(OPTIONAL) : Disable the multi-GPU tests. Note: Does NOT update GitHub check status.--add-multi-gpu-test(OPTIONAL) : Force run the multi-GPU tests in addition to running L0 pre-merge pipeline.--post-merge(OPTIONAL) : Run the L0 post-merge pipeline instead of the ordinary L0 pre-merge pipeline.--extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx"(OPTIONAL) : Run the ordinary L0 pre-merge pipeline and specified test stages. Examples: --extra-stage "H100_PCIe-TensorRT-Post-Merge-1, xxx".--detailed-log(OPTIONAL) : Enable flushing out all logs to the Jenkins console. This will significantly increase the log volume and may slow down the job.--debug(OPTIONAL) : Experimental feature. Enable access to the CI container for debugging purpose. Note: Specify exactly one stage in thestage-listparameter to access the appropriate container environment. Note: Does NOT update GitHub check status.For guidance on mapping tests to stage names, see
docs/source/reference/ci-overview.mdand the
scripts/test_to_stage_mapping.pyhelper.kill
killKill all running builds associated with pull request.
skip
skip --comment COMMENTSkip testing for latest commit on pull request.
--comment "Reason for skipping build/test"is required. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.reuse-pipeline
reuse-pipelineReuse a previous pipeline to validate current commit. This action will also kill all currently running builds associated with the pull request. IMPORTANT NOTE: This is dangerous since lack of user care and validation can cause top of tree to break.