Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: enable MacOS M1 stages #1123

Merged
merged 3 commits into from
Sep 12, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 66 additions & 5 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand All @@ -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())
}
}
}
Expand Down Expand Up @@ -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
}
}
Expand All @@ -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 {
Expand Down Expand Up @@ -364,6 +369,55 @@ pipeline {
}
}
}
stage('m1') {
agent { label 'orka && darwin && aarch64' }
options { skipDefaultCheckout() }
when {
v1v marked this conversation as resolved.
Show resolved Hide resolved
// 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-darwin-aarch64") {
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-darwin-aarch64") {
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 {
Expand Down Expand Up @@ -483,4 +537,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')
}
}

/**
* 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')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If I'm follow this correctly, m1 only runs when specifically request or if we change the Jenkinsfile (from setEnvVar('EXT_M1_CHANGES', isGitRegionMatch(patterns: [ '.ci/Jenkinsfile' ], shouldMatchAll: false).toString()))?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That's correct, the EXT_M1_CHANGES env variable could be changed to something else if needed, so far, I added the .ci/Jenkinsfile to the list of files that should enable this extended validation.

At the moment there are 4 different reasons the stage will run on a PR basis:

  • If a GitHub comment with run extended m1
  • If a GitHub label ci:extended-m1
  • If a Build using the jenkins UI with the parameter extended_m1_ci set true.
  • If a change in the file .ci/Jenkinsfile

}