From 26c37128a58224da15706c9d1871b22549474122 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Thu, 8 Sep 2022 16:00:34 +0100 Subject: [PATCH 1/3] ci: enable MacOS M1 stages --- .ci/Jenkinsfile | 70 +++++++++++++++++++++++++++++++++++++++++++++---- 1 file changed, 65 insertions(+), 5 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index ccca5538652..04f4c6ae632 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -43,6 +43,10 @@ pipeline { // disabled by default, but required for merge: // opt-in with 'ci:extended-windows' tag on PR booleanParam(name: 'extended_windows_ci', defaultValue: false, description: 'Enable Extended Windows tests') + + // disabled by default, but required for merge: + // opt-in with 'ci:extended-m1' tag on PR + booleanParam(name: 'extended_m1_ci', defaultValue: false, description: 'Enable M1 tests') } stages { stage('Checkout') { @@ -56,6 +60,7 @@ pipeline { setEnvVar('PACKAGING_CHANGES', isGitRegionMatch(patterns: [ '(^dev-tools/packaging/.*|.ci/Jenkinsfile)' ], shouldMatchAll: false).toString()) setEnvVar('K8S_CHANGES', isGitRegionMatch(patterns: [ '(^deploy/kubernetes/.*|^version/docs/version.asciidoc|.ci/Jenkinsfile)' ], shouldMatchAll: false).toString()) setEnvVar('EXT_WINDOWS_CHANGES', isGitRegionMatch(patterns: [ '.ci/Jenkinsfile' ], shouldMatchAll: false).toString()) + setEnvVar('EXT_M1_CHANGES', isGitRegionMatch(patterns: [ '.ci/Jenkinsfile' ], shouldMatchAll: false).toString()) } } } @@ -245,10 +250,10 @@ pipeline { } stage('Sync K8s') { //This stage opens a PR to kibana Repository in order to sync k8s manifests when { - // Only on main branch + // Only on main branch // Enable if k8s related changes. allOf { - branch 'main' // Only runs for branch main + branch 'main' // Only runs for branch main expression { return env.K8S_CHANGES == "true" } // If k8s changes } } @@ -267,11 +272,11 @@ pipeline { ./creator_k8s_manifest.sh . """) sh(label: '[Clone] Kibana-Repository', script: """ make ci-clone-kibana-repository - cp Makefile ./kibana + cp Makefile ./kibana cd kibana make ci-create-kubernetes-templates-pull-request """) } - } + } } post { always { @@ -364,6 +369,54 @@ pipeline { } } } + stage('m1') { + agent { label 'orka && darwin && aarch64' } + when { + // Always when running builds on branches/tags + // Enable if extended M1 support related changes. + beforeAgent true + anyOf { + not { changeRequest() } + expression { return isExtendedM1Enabled() && env.ONLY_DOCS == "false"} + } + } + stages { + stage('build'){ + steps { + withGithubNotify(context: "Build-${PLATFORM}") { + deleteDir() + unstashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") + withMageEnv(){ + dir("${BASE_DIR}"){ + cmd(label: 'Go build', script: 'mage build') + } + } + } + } + } + stage('Test') { + steps { + withGithubNotify(context: "Test-${PLATFORM}") { + withMageEnv(){ + dir("${BASE_DIR}"){ + withEnv(["TEST_COVERAGE=${isCodeCoverageEnabled()}"]) { + cmd(label: 'Go unitTest', script: 'mage unitTest') + } + } + } + } + } + post { + always { + junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/build/TEST-*.xml") + whenTrue(isCodeCoverageEnabled()) { + coverageReport(baseDir: "**/build", reportFiles: 'TEST-go-unit.html', coverageFiles: 'TEST-go-unit-cov.xml') + } + } + } + } + } + } } post { cleanup { @@ -483,4 +536,11 @@ def isPackageEnabled() { */ def isExtendedWindowsEnabled() { return env.EXT_WINDOWS_CHANGES == "true" || params.extended_windows_ci || env.GITHUB_COMMENT?.contains('extended windows') || matchesPrLabel(label: 'ci:extended-windows') -} \ No newline at end of file +} + +/** +* Wrapper to know if the build should enable the M1 extended support +*/ +def isExtendedM1Enabled() { + return env.EXT_M1_CHANGES == "true" || params.extended_m1_ci || env.GITHUB_COMMENT?.contains('extended m1') || matchesPrLabel(label: 'ci:extended-m1') +} From b41d2d944c83a317a67690ca5b29a18d4a9166a6 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 9 Sep 2022 13:50:02 +0100 Subject: [PATCH 2/3] ci: fix missing parameter --- .ci/Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 04f4c6ae632..63509039b5e 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -383,7 +383,7 @@ pipeline { stages { stage('build'){ steps { - withGithubNotify(context: "Build-${PLATFORM}") { + withGithubNotify(context: "Build-darwin-aarch64") { deleteDir() unstashV2(name: 'source', bucket: "${JOB_GCS_BUCKET}", credentialsId: "${JOB_GCS_CREDENTIALS}") withMageEnv(){ @@ -396,7 +396,7 @@ pipeline { } stage('Test') { steps { - withGithubNotify(context: "Test-${PLATFORM}") { + withGithubNotify(context: "Test-darwin-aarch64") { withMageEnv(){ dir("${BASE_DIR}"){ withEnv(["TEST_COVERAGE=${isCodeCoverageEnabled()}"]) { From c3aef476b7293be84961cb8d171246a5ad3582f2 Mon Sep 17 00:00:00 2001 From: Victor Martinez Date: Fri, 9 Sep 2022 14:57:21 +0100 Subject: [PATCH 3/3] Update .ci/Jenkinsfile --- .ci/Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/.ci/Jenkinsfile b/.ci/Jenkinsfile index 63509039b5e..b98093faba0 100644 --- a/.ci/Jenkinsfile +++ b/.ci/Jenkinsfile @@ -371,6 +371,7 @@ pipeline { } stage('m1') { agent { label 'orka && darwin && aarch64' } + options { skipDefaultCheckout() } when { // Always when running builds on branches/tags // Enable if extended M1 support related changes.