Skip to content

Commit 0dba19c

Browse files
Get hardware distro version from map (#415)
Don't need the downstream branch matching in distroVersion() since it will always be just 1 or 2 commits ahead of the base branch we are looking for and can be found by walking back to find the base branch eliminating the need to maintain an RE for it. If not determined by the pipeline job (in env.BASE_BRANCH_NAME) find the base branch by walking backward until we find a valid base branch. Use this when trying to use the branch/distro/version map. Actually add the pragmas to the environment in pragmasToEnv() in addition to returning the string that was added. Sync the skipping logic for the RPMs test stages. Add a Test-downstream-test pragma to allow skipping testing in the downstream jobs. Make sure to fetch any updates in the downstream testing job setup. In getFunctionalTestStage() detail which branch is being checked out. Add some rudimentary unit testing to a couple of functions. Signed-off-by: Brian J. Murrell <[email protected]>
1 parent 5b98eba commit 0dba19c

File tree

7 files changed

+73
-22
lines changed

7 files changed

+73
-22
lines changed

Jenkinsfile

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ pipeline {
253253
status: 'SUCCESS'
254254
}
255255
}
256-
} //stage('publishToRepository RPM tests')
256+
} // stage('publishToRepository RPM tests')
257257
stage('publishToRepository DEB tests') {
258258
when {
259259
beforeAgent true
@@ -293,7 +293,7 @@ pipeline {
293293
status: 'SUCCESS'
294294
}
295295
}
296-
} //stage('publishToRepository DEB tests')
296+
} // stage('publishToRepository DEB tests')
297297
stage('provisionNodes on EL 9 with master Repo') {
298298
when {
299299
beforeAgent true
@@ -368,8 +368,8 @@ pipeline {
368368
failure_artifacts: env.STAGE_NAME))
369369
}
370370
// runTest handles SCM notification via stepResult
371-
} //stage('provisionNodes with slurm EL8')
372-
stage('provisionNodes with slurm Leap15') {
371+
} // stage('provisionNodes on EL 8 with slurm') {
372+
stage('provisionNodes on Leap 15 with slurm') {
373373
when {
374374
beforeAgent true
375375
expression {
@@ -398,7 +398,7 @@ pipeline {
398398
failure_artifacts: env.STAGE_NAME))
399399
}
400400
// runTest handles SCM notification via stepResult
401-
} //stage('provisionNodes_with_slurm_leap15')
401+
} // stage('provisionNodes on Leap 15 with slurm') {
402402
stage('Commit Pragma tests') {
403403
steps {
404404
script {
@@ -744,6 +744,7 @@ pipeline {
744744
cd \$dir
745745
fi
746746
if git checkout \$branch_name; then
747+
git fetch origin
747748
git rebase \$source_branch
748749
else
749750
if ! git checkout -b \$branch_name \$source_branch; then
@@ -763,11 +764,13 @@ pipeline {
763764
if [ -n "$(git status -s)" ]; then
764765
git commit -m "Update pipeline-lib branch to self''' +
765766
(cachedCommitPragma('Test-skip-build', 'true') == 'true' ? '' :
766-
'\n\nSkip-unit-tests: true') + '''" Jenkinsfile
767-
git push -f origin $branch_name:$branch_name
767+
'\n\nSkip-unit-tests: true') +
768+
(cachedCommitPragma('Test-downstream-test', 'true') == 'true' ? '' :
769+
'\n\nSkip-test: true') + '''" Jenkinsfile
768770
else
769771
git show
770772
fi
773+
git push -f origin $branch_name:$branch_name
771774
sleep 10'''
772775
sh label: 'Delete local test branch',
773776
script: '''dir="daos-''' + env.TEST_BRANCH.replaceAll('/', '-') + '''"
@@ -784,8 +787,10 @@ pipeline {
784787
} // withCredentials
785788
build job: 'daos-stack/daos/' + test_branch(env.TEST_BRANCH),
786789
parameters: [string(name: 'TestTag',
787-
value: cachedCommitPragma('Test-tag',
788-
'load_mpi test_core_files test_pool_info_query')),
790+
value: cachedCommitPragma(
791+
'Test-tag',
792+
'load_mpi test_core_files ' +
793+
'test_pool_info_query')),
789794
string(name: 'CI_RPM_TEST_VERSION',
790795
value: cachedCommitPragma('Test-skip-build', 'false') == 'true' ?
791796
daosLatestVersion(env.TEST_BRANCH) : ''),
@@ -801,7 +806,7 @@ pipeline {
801806
booleanParam(name: 'CI_medium_TEST', value: true),
802807
booleanParam(name: 'CI_large_TEST', value: false)
803808
]
804-
} //steps
809+
} // steps
805810
post {
806811
success {
807812
/* groovylint-disable-next-line DuplicateMapLiteral */

vars/branchTypeRE.groovy

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,9 @@ String call(String branch_type) {
2727
case 'downstream':
2828
// Match a downstream testing branch e.g. ci-daos-do-packer-ofed-images-PR-11-release-2.2,
2929
// ci-daos-do-packer-ofed-images-PR-11-master
30-
return(/^ci-daos-.+-(?:release\/[\d.]+|master)$/)
30+
// ci-daos-stack-pipeline-lib-PR-415-weekly-testing
31+
// ci-daos-stack-pipeline-lib-PR-415-weekly-2.4-testing
32+
return(/^ci-daos-.+-(?:release\/[\d.]+|master|weekly-(?:[\d.]+-)?testing)$/)
3133

3234
case 'testing':
3335
// Match any *-testing branch (including weekly and provider)

vars/distroVersion.groovy

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,32 @@ String call() {
1313

1414
String call(String distro) {
1515
String branch = 'master'
16-
if ((env.BRANCH_NAME =~ branchTypeRE('release') ||
17-
env.BRANCH_NAME =~ branchTypeRE('downstream') ||
18-
env.BRANCH_NAME =~ branchTypeRE('testing')) &&
19-
(env.BRANCH_NAME =~ '/\\d+\\.\\d+')) {
20-
branch = env.BRANCH_NAME.replaceFirst(/^.*(\d+\.\d+).*$/, '\$1')
16+
if (env.BRANCH_NAME =~ branchTypeRE('release') ||
17+
env.BRANCH_NAME =~ branchTypeRE('testing')) {
18+
if (env.BRANCH_NAME =~ /\d+\.\d+/) {
19+
branch = env.BRANCH_NAME.replaceFirst(/^.*(\d+\.\d+).*$/, '\$1')
20+
}
21+
} else {
22+
if (env.BASE_BRANCH_NAME) {
23+
branch = env.BASE_BRANCH_NAME
24+
} else {
25+
// find the base branch
26+
branch = sh(label: 'Find base branch',
27+
script: '''set -eux -o pipefail
28+
max_commits=200
29+
base_branch_re='^ origin/(master|release/)'
30+
n=0
31+
while [ "$n" -lt "$max_commits" ]; do
32+
if git branch -r --contains HEAD~$n |
33+
grep -E "$base_branch_re" | sed -e 's/^ *[^\\/]*\\///'; then
34+
exit 0
35+
fi
36+
((n++)) || true
37+
done
38+
echo "Could not find a base branch within $max_commits commits" >&2
39+
exit 1''',
40+
returnStdout: true).trim().replaceFirst(/^.*(\d+\.\d+).*$/, '\$1')
41+
}
2142
}
2243

2344
return distroVersion(distro, branch)

vars/getFunctionalTestStage.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ Map call(Map kwargs = [:]) {
6060
} else {
6161
node(cachedCommitPragma("Test-label${pragma_suffix}", label)) {
6262
// Ensure access to any branch provisioning scripts exist
63-
echo "[${name}] Check out from version control"
63+
echo "[${name}] Check out '${base_branch}' from version control"
6464
if (base_branch) {
6565
checkoutScm(
6666
url: 'https://github.com/daos-stack/daos.git',

vars/hwDistroTarget2.groovy

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ List call(String size) {
2020
// el8
2121
// NOTE: the default distro does not get set, here below if the DAOS Jenkinsfile has a CI_HARDWARE_DISTRO parameter
2222
String distro = cachedCommitPragma('EL8-target', 'el' +
23-
cachedCommitPragma('EL8-version', '8'))
23+
cachedCommitPragma('EL8-version',
24+
distroVersion('el8')))
2425
if (params.CI_HARDWARE_DISTRO) {
2526
distro = params.CI_HARDWARE_DISTRO
2627
}
@@ -35,4 +36,4 @@ List call() {
3536
+ 1..-1].toLowerCase())
3637
}
3738
return (parseStageInfo()['target'] =~ /([a-z]+)(.*)/)[0][1..2]
38-
}
39+
}

vars/pragmasToEnv.groovy

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@ String call(String commit_message) {
2525
}
2626
}
2727

28-
// note this converts the Map to a string in the format "{foo=bar}"
29-
// instead of the expected format of "[foo:bar]"
28+
// put the pragms into the environment
29+
env.pragmas = pragmas
30+
31+
// note this converts the Map to a string in the format "{foo= bar, bat= ball}"
32+
// instead of the expected format of "[foo:bar, bat:ball]"
3033
return pragmas
3134
}
3235

@@ -42,5 +45,19 @@ Void call() {
4245
returnStdout: true).trim()
4346
env.pragmas = pragmasToEnv(env.COMMIT_MESSAGE)
4447

45-
return
48+
return env.pragmas
4649
}
50+
51+
// Unit Testing
52+
/* groovylint-disable-next-line CompileStatic */
53+
env = [:]
54+
assert(call('''Debug for env.pragmas
55+
56+
Skip-build: true
57+
Skip-PR-comments: true
58+
59+
Required-githooks: true
60+
61+
Signed-off-by: Brian J. Murrell <[email protected]>''') ==
62+
'{skip-build= true, skip-pr-comments= true, required-githooks= true,' +
63+
' signed-off-by= Brian J. Murrell <[email protected]>}')

vars/skipStage.groovy

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -494,6 +494,7 @@ boolean call(Map config = [:]) {
494494
(quickFunctional() &&
495495
!paramsValue('CI_RPMS_el8_6_TEST', true) &&
496496
!run_default_skipped_stage('test-el-8.6-rpms')) ||
497+
(rpmTestVersion() != '') ||
497498
stageAlreadyPassed()
498499
case 'Test Leap 15 RPMs':
499500
case 'Test Leap 15.2 RPMs':
@@ -504,10 +505,14 @@ boolean call(Map config = [:]) {
504505
stageAlreadyPassed()
505506
case 'Test RPMs on Leap 15.4':
506507
return !paramsValue('CI_RPMS_leap15.4_TEST', true) ||
508+
target_branch =~ branchTypeRE('weekly') ||
507509
skip_stage_pragma('test') ||
508510
skip_stage_pragma('test-rpms') ||
509511
skip_stage_pragma('test-leap-15.4-rpms', 'true') ||
510512
docOnlyChange(target_branch) ||
513+
(quickFunctional() &&
514+
!paramsValue('CI_RPMS_leap15_4_TEST', true) &&
515+
!run_default_skipped_stage('test-leap-15.4-rpms')) ||
511516
(rpmTestVersion() != '') ||
512517
stageAlreadyPassed()
513518
case 'Scan CentOS 7 RPMs':

0 commit comments

Comments
 (0)