CI: Refactor Jenkinsfile helpers into implicit Shared Library #2092
+762
−763
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Motivation
The primary
mlir/utils/jenkins/Jenkinsfilehas grown to over 1500 lines, with the vast majority being helper functions defined at the top. This makes the file difficult to read, maintain, and navigate.This PR refactors all this helper logic into an implicit Shared Library stored in the
vars/directory at the repository root. This greatly simplifies the Jenkinsfile, organizes helper code by purpose, and makes the logic reusable and easier to manage.This approach also ensures that any PRs modifying the shared library code will use the new code from that same PR for testing, rather than the one from the
developbranch.Technical Details
Created
vars/directory: Added a newvars/directory at the repository root. This is automatically loaded by Jenkins as an implicit library.Grouped Functions into Objects: All Groovy helper functions were moved from the Jenkinsfile and grouped into new "singleton" objects in the
vars/directory:scmUtils.groovy: ForgitHealthCheck()androbustScmCheckout().nodeUtils.groovy: ForresetGPUs(),checkNodeHealth(),dockerArgs(),get_gpu_architecture(), withHealthyNode(), etc.buildUtils.groovy: ForbuildProject(),buildCK(),getAndBuildMIGraphX(), etc.testUtils.groovy: ForpreMergeCheck(),setLitWorkerCount(),parameterSweep(), etc.reportUtils.groovy: ForpostProcessPerfRes()and archivePerfDB().ciLogic.groovy: For getLabelFromCodepath(),shouldRunFromChip(),resetBuild(), etc.generalUtils.groovy: ForsplitConfigFile().Updated
Jenkinsfile:def nodeUtils = nodeUtils(this)).pipelineblock to use their new object namespace (e.g.,checkNodeHealth()is now nodeUtils.checkNodeHealth()).Handled Global State: The global
@Field DOCKER_ARGS_BY_NODEvariable remains in theJenkinsfile. The Jenkinsfile'sthis(script) context is passed tonodeUtilsso it can read/write to this variable usingscript.DOCKER_ARGS_BY_NODE.