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] Pipeline #14

Merged
merged 13 commits into from
Dec 16, 2020
84 changes: 84 additions & 0 deletions .ci/Jenkinsfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
#!/usr/bin/env groovy

@Library('apm@current') _

pipeline {
agent { label 'ubuntu-18 && immutable' }
environment {
REPO = "go-windows"
BASE_DIR = "src/github.com/elastic/${env.REPO}"
JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba"
PIPELINE_LOG_LEVEL = 'INFO'
GO111MODULE = 'on'
}
options {
timeout(time: 1, unit: 'HOURS')
buildDiscarder(logRotator(numToKeepStr: '20', artifactNumToKeepStr: '20', daysToKeepStr: '30'))
timestamps()
ansiColor('xterm')
disableResume()
durabilityHint('PERFORMANCE_OPTIMIZED')
rateLimitBuilds(throttle: [count: 60, durationName: 'hour', userBoost: true])
quietPeriod(10)
}
triggers {
issueCommentTrigger('(?i)(.*(?:jenkins\\W+)?run\\W+(?:the\\W+)?tests(?:\\W+please)?.*|^\\/test$)')
}
stages {
stage('Checkout') {
steps {
deleteDir()
gitCheckout(basedir: "${BASE_DIR}")
stash allowEmpty: true, name: 'source', useDefaultExcludes: false
}
}
stage('Test') {
failFast false
matrix {
options { skipDefaultCheckout() }
axes {
axis {
name 'GO_VERSION'
values '1.12'
}
axis {
name 'PLATFORM'
values 'ubuntu-18 && immutable', 'windows-2019 && immutable'
}
}
stages {
stage('Test') {
agent { label "${PLATFORM}" }
options { skipDefaultCheckout() }
steps {
withGithubNotify(context: "Test-${GO_VERSION}-${PLATFORM}") {
deleteDir()
unstash 'source'
withGoEnv(version: "${GO_VERSION}"){
dir("${BASE_DIR}"){
whenTrue(isUnix()) {
sh(label: "go test for ${GO_VERSION} in ${PLATFORM}", script: '.ci/scripts/test.sh')
}
whenFalse(isUnix()) {
bat(label: "go test for ${GO_VERSION} in ${PLATFORM}", script: '.ci/scripts/test.bat')
}
}
}
}
}
post {
always {
junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/build/*.xml")
}
}
}
}
}
}
}
post {
cleanup {
notifyBuildResult(prComment: true)
}
}
}
14 changes: 14 additions & 0 deletions .ci/scripts/test.bat
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
set
set GO111MODULE=off
go get -u github.com/elastic/go-licenser
set GO111MODULE=on
go mod verify
go-licenser -d
go run .ci/scripts/check_format.go
go run .ci/scripts/check_lint.go

mkdir -p build
SET OUT_FILE=build\output-report.out
go test "./..." -v > %OUT_FILE% | type %OUT_FILE%
go get -v -u github.com/jstemmer/go-junit-report
go-junit-report > build\junit-%GO_VERSION%.xml < %OUT_FILE%
19 changes: 19 additions & 0 deletions .ci/scripts/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -euxo pipefail

GO111MODULE=off go get -u github.com/elastic/go-licenser
go mod verify
go-licenser -d
go run .ci/scripts/check_format.go
go run .ci/scripts/check_lint.go

# Run the tests
set +e
export OUT_FILE="build/test-report.out"
mkdir -p build
go test -v ./... | tee ${OUT_FILE}
status=$?
go get -v -u github.com/jstemmer/go-junit-report
go-junit-report > "build/junit-${GO_VERSION}.xml" < ${OUT_FILE}

exit ${status}