[CK] Extract Jenkinsfile helpers into vars/ck.groovy shared library#7743
Conversation
Move all 35 helper functions from the monolithic Jenkinsfile into
a separate vars/ck.groovy file, following MiOpen's existing pattern.
Pure code movement — no logic changes, no renames, no stage name
changes.
rocmnode() remains in the Jenkinsfile because it's used in agent{}
labels throughout the declarative pipeline. The library is loaded
in the "Determine CI Execution" stage via checkout scm + load.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Jenkins Declarative Pipeline does not allow method calls on objects
(ck.foo()) directly in steps{} blocks — they must be inside script{}
blocks. The original bare function calls worked because they were in
the same compilation unit, but loading via ck = load "vars/ck.groovy"
makes them object method calls.
Also fixes ck.ck.checkoutComposableKernel() typo (double ck prefix).
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Extract all inline shell commands and build arguments from Jenkinsfile
environment{} blocks into named functions in ck.groovy. Jenkinsfile now
contains only pipeline structure: stage names, when conditions, agent
labels, and single-line ck.runXxx() calls.
New functions: runClangFormat, runClangFormatAndCppcheck,
runFullGroupedConvTileTests, runGroupedConvLargeCaseTests,
runComprehensiveConvDatasetTests, runTileEngineBasicTests,
runTileEngineGemmTests, runBuildCKAndTests, runBuildInstancesOnly.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
Resolved conflicts by keeping our clean ck.groovy-based structure throughout. Incorporated develop's new additions: - Add BUILD_GFX1250 param and gfx1250 build stage (private docker, no reboot) - Add runBuildCKForGfx1250() to ck.groovy - Update cmake_build() to use default ROCm compiler for gfx1250 targets - ROCMVERSION default already updated to 7.13 in our branch - TILE_ENGINE_SAMPLING_TIER=daily already in our runTileEngineGemmTests() Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Phase 1 copied helper functions from the original monolith, but develop had already updated three of them before our branch point: - cmake_build: restore RUN_ROCM_CK_TESTS cmake flag, ninja trace archival after full builds, gfx1250 skip-tests logic, and BUILD_INSTANCES_ONLY package stashing that were added in commits 316fded and de93737 - getBaseDockerImageName: revert private-registry branching by ROCM version (develop reverted this back to always use public registry) - getPytorchTestsCmds: restore mkdir/cp from Jenkins workspace path (develop updated this from /tmp/pytorch in commit 7e032ad) Also restore show_node_info() hostname line from commit 47e8768 (John Robbins) that was dropped during Phase 1 extraction. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
gfx1250 is now a case in the existing switch rather than a separate function. Its unique args (private docker image, no_reboot, DISABLE_DL_KERNELS) are passed via extraBuildArgs/extraSetupArgs. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Develop added deleteDir() at the top of 25 stage steps{} blocks to
ensure a clean workspace before each stage runs. These were lost when
conflicts were resolved by keeping our side. Restores them in the same
stages that develop had them, excluding the 5 downstream test stages
(Pytorch, AITER, FA) which never had them.
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
There was a problem hiding this comment.
Pull request overview
This PR refactors the Composable Kernel Jenkins pipeline by moving the Jenkinsfile’s helper logic into a separately loaded Groovy script (vars/ck.groovy), leaving the Jenkinsfile primarily responsible for declarative pipeline structure and stage definitions.
Changes:
- Added
projects/composablekernel/vars/ck.groovycontaining the extracted helper functions plus new stage-wrapper functions. - Simplified
projects/composablekernel/Jenkinsfiletoloadthe helper script once and callck.*helpers (wrapped inscript {}where required). - Replaced several large inline stage
environment{}/steps{}command blocks with wrapper calls (e.g., clang-format/cppcheck, grouped-conv tests, tile-engine tests, build-and-test stages).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| projects/composablekernel/vars/ck.groovy | New loaded helper script containing extracted pipeline helpers and stage-wrapper functions. |
| projects/composablekernel/Jenkinsfile | Updated declarative pipeline to load ck.groovy and delegate stage logic to ck.* helpers. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
…ineGemmTests Restore TILE_ENGINE_SAMPLING_TIER=daily cmake flag for all three arch branches (gfx942, gfx950, gfx1201) and correct gfx942's benchmark output filename from results.json to gemm_universal_results.json, matching develop. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
- Drop class Version and parseVersion() from ck.groovy; both became dead code when getBaseDockerImageName was synced to develop (which removed the ROCm version branch that was their only call site) - Change `def ck` to `ck = null` at script scope to match MiOpen's utils pattern (global binding vs local variable) - Add null guard around `ck = load` to match MiOpen's lazy-load idiom Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
|
curious if you plan to add tests for the pipeline code? e.g. https://github.com/jenkinsci/JenkinsPipelineUnit |
Three functional changes from develop commit e34ac06: 1. cmake_build: add BUILD_INSTANCES_ONLY to profiler package build condition 2. process_results: move sh steps inside each try{} block so a missing stash does not abort subsequent uploads 3. runBuildInstancesOnly: add GPU_ARCHS and setup_args=NO_CK_BUILD Jenkinsfile conflict resolved by keeping ck.runBuildInstancesOnly() and discarding the monolith helpers from develop (already in ck.groovy). Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
Jenkins charset reader rejected the UTF-8 right-arrow (→) on line 24. Replace with ASCII -> to avoid MalformedInputException. Co-Authored-By: Claude Sonnet 4 <noreply@anthropic.com>
| } | ||
| } | ||
| } | ||
| stage("Process Performance Test Results") |
There was a problem hiding this comment.
I know this isn't part of this PR, but just calling out the Process Performance Test Results does not have the SHOULD_RUN_CI guard in place. We may want to add this later.
| script { | ||
| checkoutComposableKernel() | ||
| env.SHOULD_RUN_CI = String.valueOf(params.FORCE_CI.toBoolean() || shouldRunCICheck()) | ||
| checkout scm |
There was a problem hiding this comment.
Related to my other comment; if we move your scripts into a shared library, we won't have to call "checkout scm" and "ck.checkoutComposableKernel()" in the same stage.
- Replace inline load mechanism with @Library('ck') annotation for
restart-from-stage safety (ck is available at parse time)
- Move smart build comment block from ck.groovy to Jenkinsfile
- Fix indentation in Build_CK performance test block
- Remove return this from ck.groovy (not needed for shared libraries)
Requires one-time Jenkins admin setup: register Global Pipeline Library
named 'ck' pointing to this repo with Library Path
'projects/composablekernel/'.
Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
@Library requires Jenkins admin config and always loads from a fixed branch, preventing testing of ck.groovy changes on PR branches. Instead, use a loadCk() guard function that each stage calls before using ck.*. The null check makes it a no-op after first load, and restart-from-stage works because every stage can bootstrap itself. Also fixes indentation in FMHA and process_results script blocks. Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
- Resolve merge conflict: keep refactored Jenkinsfile, discard monolith helpers from develop - Apply PR #7894 fix to ck.groovy: wrap docker manifest inspect with withDockerRegistry credentials - Remove redundant nested script {} block in pipeline failure post Co-Authored-By: Claude Opus 4 <noreply@anthropic.com>
As gardener, I see that this is only modifying the Jenkinsfile, so will allow this to bypass TheRock CI as it's unrelated. |
[CK] Extract Jenkinsfile helpers into vars/ck.groovy shared
library (#7743)
## Motivation
The CK Jenkinsfile is a 2,215-line monolith mixing helper function
definitions with pipeline stage declarations. This makes it difficult to
review, modify, or extend CI stages without wading through unrelated
infrastructure code.
## Technical Details
Extract all helper functions from the Jenkinsfile into vars/ck.groovy,
loaded at runtime via ck = load "vars/ck.groovy" in the first stage. The
Jenkinsfile is reduced from 2,215 lines to 810 lines containing only the
pipeline structure.
- 36 helper functions moved to ck.groovy with no logic changes
- 10 new stage-wrapper functions (runBuildCKAndTests,
runTileEngineGemmTests, runClangFormat, etc.) extract inline
environment{}/steps{} business logic from stages, eliminating the
MethodTooLargeException caused by CPS-transformed shell strings
exceeding the JVM 64KB bytecode limit
- All ck. method calls in steps{} blocks wrapped in script{} as required
by Jenkins Declarative Pipeline
- rocmnode() remains in the Jenkinsfile (needed for agent{} labels
before ck is loaded)
- CRON_SETTINGS / POLL_SPEC remain in the Jenkinsfile (triggers{}
evaluates at parse time before any workspace is available)
- No stage names changed
## Test Plan
- Jenkinsfile validated against the Jenkins Pipeline Linter
(/pipeline-model-converter/validate)
- All 35 shared helper functions diffed line-by-line against develop to
verify no regressions
- Merge from develop incorporated and verified (gfx1250 stage, ROCm 7.13
default, cmake_build updates)
## Test Result
- Linter: passes
- Function diff vs develop: all 35 functions match exactly
- Awaiting Jenkins run to confirm end-to-end stage execution
## Submission Checklist
- [ x ] Look over the contributing guidelines at
https://github.com/ROCm/ROCm/blob/develop/CONTRIBUTING.md#pull-requests.
Motivation
The CK Jenkinsfile is a 2,215-line monolith mixing helper function definitions with pipeline stage declarations. This makes it difficult to review, modify, or extend CI stages without wading through unrelated infrastructure code.
Technical Details
Extract all helper functions from the Jenkinsfile into vars/ck.groovy, loaded at runtime via ck = load "vars/ck.groovy" in the first stage. The Jenkinsfile is reduced from 2,215 lines to 810 lines containing only the pipeline structure.
Test Plan
Test Result
Submission Checklist