From 25244538f149cc47b45a1a0ab4a2ecb9d4ccf3ee Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 22 Feb 2022 19:32:43 +0000 Subject: [PATCH 1/3] ci: support dynamic stages (docs only, packaging --- .ci/Jenkinsfile | 34 +++++++++++++++++++++++++++++----- 1 file changed, 29 insertions(+), 5 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 8b50599bb28..3b223ae5e37 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -46,6 +46,10 @@ pipeline { deleteDir() gitCheckout(basedir: "${BASE_DIR}", githubNotifyFirstTimeContributor: true) stash allowEmpty: true, name: 'source', useDefaultExcludes: false + dir("${BASE_DIR}"){ + setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true).toString()) + setEnvVar('PACKAGING_CHANGES', isGitRegionMatch(patterns: [ '(^dev-tools/packaging/.*|.ci/Jenkinsfile)' ], shouldMatchAll: false).toString()) + } } } stage('Lint'){ @@ -66,6 +70,17 @@ pipeline { } } stage('Test') { + when { + // Always when running builds on branches/tags + // On a PR basis, skip if changes are only related to docs. + anyOf { + not { changeRequest() } // If no PR + allOf { // If PR and no docs changes + expression { return env.ONLY_DOCS == "false" } + changeRequest() + } + } + } failFast false matrix { agent {label "${PLATFORM}"} @@ -124,7 +139,8 @@ pipeline { anyOf { expression { return env.GITHUB_COMMENT?.contains('package') } expression { matchesPrLabel(label: 'ci:package') } - // not { changeRequest() } + not { changeRequest() } + expression { return env.PACKAGING_CHANGES == "true" } } // Run packaging only for the linux specific arch expression { return (PLATFORM.contains('ubuntu') || PLATFORM.contains('aarch64')) } @@ -170,10 +186,18 @@ pipeline { } stage('K8s') { when { - // TODO: Run only if changes in - // - "^deploy/kubernetes/.*" - // - "^version/docs/version.asciidoc" - not { changeRequest() } + // Always when running builds on branches/tags + // On a PR basis, skip if changes are only related to docs. + anyOf { + // TODO: Run only if changes in + // - "^deploy/kubernetes/.*" + // - "^version/docs/version.asciidoc" + not { changeRequest() } // If no PR + allOf { // If PR and no docs changes + expression { return env.ONLY_DOCS == "false" } + changeRequest() + } + } } steps { runAllK8s(["v1.23.0", "v1.22.0", "v1.21.1", "v1.20.7", "v1.19.11", "v1.18.19"]) From fec1320dab00a55b8e4cabced77c782e3b8150ee Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 22 Feb 2022 19:36:08 +0000 Subject: [PATCH 2/3] ci: k8s changes validation --- .ci/Jenkinsfile | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 3b223ae5e37..7b7367b66fa 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -49,6 +49,7 @@ pipeline { dir("${BASE_DIR}"){ setEnvVar('ONLY_DOCS', isGitRegionMatch(patterns: [ '.*\\.(asciidoc|md)' ], shouldMatchAll: true).toString()) setEnvVar('PACKAGING_CHANGES', isGitRegionMatch(patterns: [ '(^dev-tools/packaging/.*|.ci/Jenkinsfile)' ], shouldMatchAll: false).toString()) + setEnvVar('K8S_CHANGES', isGitRegionMatch(patterns: [ '(^deploy/kubernetes/.*|^version/docs/version.asciidoc)' ], shouldMatchAll: false).toString()) } } } @@ -188,15 +189,14 @@ pipeline { when { // Always when running builds on branches/tags // On a PR basis, skip if changes are only related to docs. + // Enable if k8s related changes. anyOf { - // TODO: Run only if changes in - // - "^deploy/kubernetes/.*" - // - "^version/docs/version.asciidoc" not { changeRequest() } // If no PR allOf { // If PR and no docs changes expression { return env.ONLY_DOCS == "false" } changeRequest() } + expression { return env.K8S_CHANGES == "true" } // If k8s changes } } steps { From 0317bd3fe1db3bf47a4b9c77cfaf9170559e5028 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Tue, 22 Feb 2022 19:40:44 +0000 Subject: [PATCH 3/3] ci: default k8s similar to the if changes --- .ci/Jenkinsfile | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 7b7367b66fa..82035cd1934 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -124,10 +124,15 @@ pipeline { } stage('K8s') { when { - // TODO: Run only if changes in - // - "^deploy/kubernetes/.*" - // - "^version/docs/version.asciidoc" - expression { return env.PLATFORM == 'ubuntu-20.04 && immutable' } + // Always when running builds on branches/tags + // Enable if k8s related changes. + allOf { + expression { return env.PLATFORM == 'ubuntu-20.04 && immutable' } + anyOf { + not { changeRequest() } // If no PR + expression { return env.K8S_CHANGES == "true" } + } + } } steps { runK8s(k8sVersion: 'v1.23.0', kindVersion: 'v0.11.1', context: "K8s-${PLATFORM}")