From 44c5803f269c4fa46aa9ef6d356f523656943afd Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 29 Oct 2018 18:08:05 +0100 Subject: [PATCH 01/48] pipeline version 0 --- Jenkinsfile | 335 +++++++++++++++++++++++++++++++++ README.md | 7 +- scripts/jenkins/bench.sh | 11 ++ scripts/jenkins/docker-test.sh | 27 +++ scripts/jenkins/test.sh | 19 ++ 5 files changed, 396 insertions(+), 3 deletions(-) create mode 100644 Jenkinsfile create mode 100755 scripts/jenkins/bench.sh create mode 100755 scripts/jenkins/docker-test.sh create mode 100755 scripts/jenkins/test.sh diff --git a/Jenkinsfile b/Jenkinsfile new file mode 100644 index 000000000..fee975f08 --- /dev/null +++ b/Jenkinsfile @@ -0,0 +1,335 @@ +#!/usr/bin/env groovy + +library identifier: 'apm@master', +retriever: modernSCM( + [$class: 'GitSCMSource', + credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba', + remote: 'git@github.com:elastic/apm-pipeline-library.git']) + +pipeline { + agent any + environment { + HOME = "${env.HUDSON_HOME}" + BASE_DIR="src/go.elastic.co/apm" + JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba" + } + triggers { + cron('0 0 * * 1-5') + githubPush() + } + options { + timeout(time: 1, unit: 'HOURS') + buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '2', daysToKeepStr: '30')) + timestamps() + preserveStashes() + ansiColor('xterm') + disableResume() + durabilityHint('PERFORMANCE_OPTIMIZED') + } + parameters { + string(name: 'branch_specifier', defaultValue: "", description: "the Git branch specifier to build (, , , etc.)") + booleanParam(name: 'linux_ci', defaultValue: true, description: 'Enable Linux build') + booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') + booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integgration test') + booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integgration test') + booleanParam(name: 'integration_test_master_ci', defaultValue: true, description: 'Enable run integgration test') + booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') + booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation') + } + + stages { + /** + Checkout the code and stash it, to use it on other stages. + */ + stage('Checkout') { + agent { label 'master || linux' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + } + + steps { + withEnvWrapper() { + dir("${BASE_DIR}"){ + script{ + if(!branch_specifier){ + echo "Checkout SCM ${GIT_BRANCH}" + checkout scm + } else { + echo "Checkout ${branch_specifier}" + checkout([$class: 'GitSCM', branches: [[name: "${branch_specifier}"]], + doGenerateSubmoduleConfigurations: false, + extensions: [], + submoduleCfg: [], + userRemoteConfigs: [[credentialsId: "${JOB_GIT_CREDENTIALS}", + url: "${GIT_URL}"]]]) + } + env.JOB_GIT_COMMIT = getGitCommitSha() + env.JOB_GIT_URL = "${GIT_URL}" + + github_enterprise_constructor() + + on_change{ + echo "build cause a change (commit or PR)" + } + + on_commit { + echo "build cause a commit" + } + + on_merge { + echo "build cause a merge" + } + + on_pull_request { + echo "build cause PR" + } + gitCreateTag() + } + } + stash allowEmpty: true, name: 'source' + } + } + } + + /** + Build on a linux environment. + */ + stage('build') { + agent { label 'linux' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + } + + when { + beforeAgent true + environment name: 'linux_ci', value: 'true' + } + steps { + withEnvWrapper() { + unstash 'source' + dir("${BASE_DIR}"){ + sh """#!/bin/bash + make install check + """ + } + } + } + } + stage('Parallel stages') { + failFast true + parallel { + stage('test') { + agent { label 'linux' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + } + + when { + beforeAgent true + environment name: 'test_ci', value: 'true' + } + steps { + withEnvWrapper() { + unstash 'source' + dir("${BASE_DIR}"){ + sh """#!/bin/bash + ./scripts/jenkins/test.sh + """ + codecov('apm-agent-go') + } + } + } + post { + always { + coverageReport("${BASE_DIR}/build") + junit(allowEmptyResults: true, + keepLongStdio: true, + testResults: "${BASE_DIR}/build/junit-*.xml") + } + } + } + stage('Benchmarks') { + agent { label 'linux' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + } + + when { + beforeAgent true + allOf { + //branch 'master'; + environment name: 'bench_ci', value: 'true' + } + } + steps { + withEnvWrapper() { + unstash 'source' + dir("${BASE_DIR}"){ + sh """#!/bin/bash + ./scripts/jenkins/bench.sh + """ + sendBenchmarks(file: 'build/bench.out') + } + } + } + post { + always { + junit(allowEmptyResults: true, + keepLongStdio: true, + testResults: "${BASE_DIR}/build/junit-*.xml") + } + } + } + stage('Docker tests') { + agent { label 'linux && docker' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + } + + when { + beforeAgent true + allOf { + //branch 'master'; + environment name: 'integration_test_ci', value: 'true' + } + } + steps { + withEnvWrapper() { + unstash 'source' + dir("${BASE_DIR}"){ + sh """#!/bin/bash + ./scripts/jenkins/docker-test.sh + """ + codecov('apm-agent-go') + } + } + } + post { + always { + coverageReport("${BASE_DIR}/build") + junit(allowEmptyResults: true, + keepLongStdio: true, + testResults: "${BASE_DIR}/build/junit-*.xml") + } + } + } + + /** + run Go integration test with the commit version on master branch. + */ + stage('Integration test master') { + agent { label 'linux' } + when { + beforeAgent true + allOf { + //branch 'master'; + environment name: 'integration_test_master_ci', value: 'true' + } + } + steps { + build( + job: 'apm-server-ci/apm-integration-test-axis-pipeline', + parameters: [ + string(name: 'BUILD_DESCRIPTION', value: "${BUILD_TAG}-INTEST"), + booleanParam(name: "go_Test", value: true), + booleanParam(name: "java_Test", value: false), + booleanParam(name: "ruby_Test", value: false), + booleanParam(name: "python_Test", value: false), + booleanParam(name: "nodejs_Test", value: false)], + wait: true, + propagate: true) + } + } + + /** + run Go integration test with the commit version on a PR. + */ + stage('Integration test PR') { + agent { label 'linux' } + when { + beforeAgent true + allOf { + not { branch 'master' }; + environment name: 'integration_test_pr_ci', value: 'true' + } + } + steps { + build( + job: 'apm-server-ci/apm-integration-test-pipeline', + parameters: [ + string(name: 'BUILD_DESCRIPTION', value: "${BUILD_TAG}-INTEST"), + string(name: 'APM_AGENT_GO_PKG', value: "${BUILD_TAG}"), + booleanParam(name: "go_Test", value: true), + booleanParam(name: "java_Test", value: false), + booleanParam(name: "ruby_Test", value: false), + booleanParam(name: "python_Test", value: false), + booleanParam(name: "nodejs_Test", value: false), + booleanParam(name: "kibana_Test", value: false), + booleanParam(name: "server_Test", value: false)], + wait: true, + propagate: true) + } + } + } + } + + stage('Documentation') { + agent { label 'linux' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + ELASTIC_DOCS = "${env.WORKSPACE}/elastic/docs" + } + + when { + beforeAgent true + allOf { + //branch 'master'; + environment name: 'doc_ci', value: 'true' + } + } + steps { + withEnvWrapper() { + unstash 'source' + dir("${ELASTIC_DOCS}"){ + git "https://github.com/elastic/docs.git" + } + dir("${BASE_DIR}"){ + sh """#!/bin/bash + make docs + """ + } + } + } + post{ + success { + tar(file: "doc-files.tgz", archive: true, dir: "html", pathPrefix: "${BASE_DIR}/docs") + } + } + } + } + post { + always { + echo 'Post Actions' + gitDeleteTag() + } + success { + echo 'Success Post Actions' + } + aborted { + echo 'Aborted Post Actions' + } + failure { + echo 'Failure Post Actions' + //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${NOTIFY_TO}", sendToIndividuals: false]) + } + unstable { + echo 'Unstable Post Actions' + } + } +} \ No newline at end of file diff --git a/README.md b/README.md index eb1bd18fa..faf2ddb4c 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,8 @@ -[![GoDoc](https://godoc.org/github.com/elastic/apm-agent-go?status.svg)](http://godoc.org/github.com/elastic/apm-agent-go) +[![Build Status](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-go/apm-agent-go-mbp/master)](https://apm-ci.elastic.co/job/apm-agent-go/job/apm-agent-go-mbp//job/master/) +[![GoDoc](https://godoc.org/go.elastic.co/apm?status.svg)](http://godoc.org/go.elastic.co/apm) [![Travis-CI](https://travis-ci.org/elastic/apm-agent-go.svg)](https://travis-ci.org/elastic/apm-agent-go) [![AppVeyor](https://ci.appveyor.com/api/projects/status/28fhswvqqc7p90f7?svg=true)](https://ci.appveyor.com/project/AndrewWilkins/apm-agent-go) -[![Go Report Card](https://goreportcard.com/badge/github.com/elastic/apm-agent-go)](https://goreportcard.com/report/github.com/elastic/apm-agent-go) +[![Go Report Card](https://goreportcard.com/badge/go.elastic.co/apm)](https://goreportcard.com/report/go.elastic.co/apm) [![codecov.io](https://codecov.io/github/elastic/apm-agent-go/coverage.svg?branch=master)](https://codecov.io/github/elastic/apm-agent-go?branch=master) # apm-agent-go: APM Agent for Go (beta) @@ -16,7 +17,7 @@ We'd love to hear your feedback, please take a minute to fill out our [survey](h ## Installation ```bash -go get -u github.com/elastic/apm-agent-go +go get -u go.elastic.co/apm ``` ## Requirements diff --git a/scripts/jenkins/bench.sh b/scripts/jenkins/bench.sh new file mode 100755 index 000000000..9a5faeb9e --- /dev/null +++ b/scripts/jenkins/bench.sh @@ -0,0 +1,11 @@ +#!/bin/bash +set -e +export GOPATH=$WORKSPACE +eval "$(gvm $GO_VERSION)" +go get -v -u github.com/jstemmer/go-junit-report +go get -v -t ./... + +export OUT_FILE="build/bench.out" +mkdir -p build +go test -run=NONE -benchmem -bench=. ./... -v 2>&1 | tee ${OUT_FILE} +cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-bench.xml diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh new file mode 100755 index 000000000..649ac1431 --- /dev/null +++ b/scripts/jenkins/docker-test.sh @@ -0,0 +1,27 @@ +#!/bin/bash +set -ex +export GOPATH=$WORKSPACE +eval "$(gvm $GO_VERSION)" +go get -v -u github.com/jstemmer/go-junit-report +go get -v -u github.com/axw/gocov/gocov +go get -v -u github.com/matm/gocov-html +go get -v -u github.com/axw/gocov/... +go get -v -u github.com/AlekSi/gocov-xml + +go get -v -t ./... + +export COV_FILE="build/coverage.cov" +export OUT_FILE="build/test-report.out" +mkdir -p build + +./scripts/docker-compose-testing up -d --build +./scripts/docker-compose-testing run -T --rm go-agent-tests make coverage | tee ${COV_FILE}.raw +echo "mode: atomic" > ${COV_FILE} +grep -v "mode\: atomic" ${COV_FILE}.raw >> ${COV_FILE} +gocov convert "${COV_FILE}" | gocov-html > build/coverage-apm-agent-go-docker-report.html +gocov convert "${COV_FILE}" | gocov-xml > build/coverage-apm-agent-go-docker-report.xml + +./scripts/docker-compose-testing run -T --rm go-agent-tests go test -race ./... -v 2>&1 | tee ${OUT_FILE} +cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-docker.xml + + diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh new file mode 100755 index 000000000..f3c372831 --- /dev/null +++ b/scripts/jenkins/test.sh @@ -0,0 +1,19 @@ +#!/bin/bash +set -e +export GOPATH=$WORKSPACE +eval "$(gvm $GO_VERSION)" +go get -v -u github.com/jstemmer/go-junit-report +go get -v -u github.com/axw/gocov/gocov +go get -v -u github.com/matm/gocov-html +go get -v -u github.com/axw/gocov/... +go get -v -u github.com/AlekSi/gocov-xml + +go get -v -t ./... + +export COV_FILE="build/coverage.cov" +export OUT_FILE="build/test-report.out" +mkdir -p build/codecov +go test -race ./... -v -coverprofile="${COV_FILE}" 2>&1 | tee ${OUT_FILE} +cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go.xml +gocov convert "${COV_FILE}" | gocov-html > build/coverage-apm-agent-go-report.html +gocov convert "${COV_FILE}" | gocov-xml > build/coverage-apm-agent-go-report.xml \ No newline at end of file From 26e3b417f5985d765f6c21921859b89cfba039f0 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 30 Oct 2018 10:33:32 +0100 Subject: [PATCH 02/48] Update Jenkinsfile Co-Authored-By: kuisathaverat --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index fee975f08..cac19f301 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -30,7 +30,7 @@ pipeline { string(name: 'branch_specifier', defaultValue: "", description: "the Git branch specifier to build (, , , etc.)") booleanParam(name: 'linux_ci', defaultValue: true, description: 'Enable Linux build') booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') - booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integgration test') + booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integration test') booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integgration test') booleanParam(name: 'integration_test_master_ci', defaultValue: true, description: 'Enable run integgration test') booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') @@ -332,4 +332,4 @@ pipeline { echo 'Unstable Post Actions' } } -} \ No newline at end of file +} From 0c771335ad025d6aa2a1ff4492ad13f06bbaec26 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 30 Oct 2018 10:33:40 +0100 Subject: [PATCH 03/48] Update Jenkinsfile Co-Authored-By: kuisathaverat --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index cac19f301..1221f88b2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,7 +31,7 @@ pipeline { booleanParam(name: 'linux_ci', defaultValue: true, description: 'Enable Linux build') booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integration test') - booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integgration test') + booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integration test') booleanParam(name: 'integration_test_master_ci', defaultValue: true, description: 'Enable run integgration test') booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation') From ece290f50e5e00d60db025d44071f69c57f3b494 Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 30 Oct 2018 10:33:48 +0100 Subject: [PATCH 04/48] Update Jenkinsfile Co-Authored-By: kuisathaverat --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1221f88b2..50f6bf85b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,7 +32,7 @@ pipeline { booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integration test') booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integration test') - booleanParam(name: 'integration_test_master_ci', defaultValue: true, description: 'Enable run integgration test') + booleanParam(name: 'integration_test_master_ci', defaultValue: true, description: 'Enable run integration test') booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation') } From 4023751075d131163e43c3ef1c7d711444b3dbab Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Tue, 30 Oct 2018 10:46:42 +0100 Subject: [PATCH 05/48] Update scripts/jenkins/docker-test.sh Co-Authored-By: kuisathaverat --- scripts/jenkins/docker-test.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh index 649ac1431..d3d01edcb 100755 --- a/scripts/jenkins/docker-test.sh +++ b/scripts/jenkins/docker-test.sh @@ -3,7 +3,6 @@ set -ex export GOPATH=$WORKSPACE eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report -go get -v -u github.com/axw/gocov/gocov go get -v -u github.com/matm/gocov-html go get -v -u github.com/axw/gocov/... go get -v -u github.com/AlekSi/gocov-xml From ba1a5320af3314f8e99d94635fb62c27f4ab5c49 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 30 Oct 2018 15:48:47 +0100 Subject: [PATCH 06/48] order dependencies --- scripts/jenkins/docker-test.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh index d3d01edcb..2ab0efa60 100755 --- a/scripts/jenkins/docker-test.sh +++ b/scripts/jenkins/docker-test.sh @@ -3,8 +3,8 @@ set -ex export GOPATH=$WORKSPACE eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report -go get -v -u github.com/matm/gocov-html go get -v -u github.com/axw/gocov/... +go get -v -u github.com/matm/gocov-html go get -v -u github.com/AlekSi/gocov-xml go get -v -t ./... From c588d8255fb6120d4b3f03d2251651fea4512b8a Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 31 Oct 2018 11:16:37 +0100 Subject: [PATCH 07/48] some test changes --- Jenkinsfile | 36 +--------------------------------- scripts/jenkins/docker-test.sh | 26 ------------------------ scripts/jenkins/test.sh | 18 ++++++++--------- 3 files changed, 9 insertions(+), 71 deletions(-) delete mode 100755 scripts/jenkins/docker-test.sh diff --git a/Jenkinsfile b/Jenkinsfile index 50f6bf85b..e23c51993 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -144,7 +144,7 @@ pipeline { } post { always { - coverageReport("${BASE_DIR}/build") + coverageReport("${BASE_DIR}/build/coverage") junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/build/junit-*.xml") @@ -184,40 +184,6 @@ pipeline { } } } - stage('Docker tests') { - agent { label 'linux && docker' } - environment { - PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" - GOPATH = "${env.WORKSPACE}" - } - - when { - beforeAgent true - allOf { - //branch 'master'; - environment name: 'integration_test_ci', value: 'true' - } - } - steps { - withEnvWrapper() { - unstash 'source' - dir("${BASE_DIR}"){ - sh """#!/bin/bash - ./scripts/jenkins/docker-test.sh - """ - codecov('apm-agent-go') - } - } - } - post { - always { - coverageReport("${BASE_DIR}/build") - junit(allowEmptyResults: true, - keepLongStdio: true, - testResults: "${BASE_DIR}/build/junit-*.xml") - } - } - } /** run Go integration test with the commit version on master branch. diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh deleted file mode 100755 index 2ab0efa60..000000000 --- a/scripts/jenkins/docker-test.sh +++ /dev/null @@ -1,26 +0,0 @@ -#!/bin/bash -set -ex -export GOPATH=$WORKSPACE -eval "$(gvm $GO_VERSION)" -go get -v -u github.com/jstemmer/go-junit-report -go get -v -u github.com/axw/gocov/... -go get -v -u github.com/matm/gocov-html -go get -v -u github.com/AlekSi/gocov-xml - -go get -v -t ./... - -export COV_FILE="build/coverage.cov" -export OUT_FILE="build/test-report.out" -mkdir -p build - -./scripts/docker-compose-testing up -d --build -./scripts/docker-compose-testing run -T --rm go-agent-tests make coverage | tee ${COV_FILE}.raw -echo "mode: atomic" > ${COV_FILE} -grep -v "mode\: atomic" ${COV_FILE}.raw >> ${COV_FILE} -gocov convert "${COV_FILE}" | gocov-html > build/coverage-apm-agent-go-docker-report.html -gocov convert "${COV_FILE}" | gocov-xml > build/coverage-apm-agent-go-docker-report.xml - -./scripts/docker-compose-testing run -T --rm go-agent-tests go test -race ./... -v 2>&1 | tee ${OUT_FILE} -cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-docker.xml - - diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index f3c372831..cf84e3471 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -3,17 +3,15 @@ set -e export GOPATH=$WORKSPACE eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report -go get -v -u github.com/axw/gocov/gocov -go get -v -u github.com/matm/gocov-html -go get -v -u github.com/axw/gocov/... -go get -v -u github.com/AlekSi/gocov-xml - +go get -v -u code.google.com/p/go.tools/cmd/cover +go get -v -u github.com/t-yuki/gocover-cobertura go get -v -t ./... -export COV_FILE="build/coverage.cov" +export COV_FILE="build/coverage/coverage.cov" export OUT_FILE="build/test-report.out" -mkdir -p build/codecov -go test -race ./... -v -coverprofile="${COV_FILE}" 2>&1 | tee ${OUT_FILE} +mkdir -p build/coverage +go test -race ./... -v -coverprofile="${COV_FILE}" -coverpkg=go.elastic.co/apm/... 2>&1 | tee ${OUT_FILE} cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go.xml -gocov convert "${COV_FILE}" | gocov-html > build/coverage-apm-agent-go-report.html -gocov convert "${COV_FILE}" | gocov-xml > build/coverage-apm-agent-go-report.xml \ No newline at end of file + +go tool cover -html="${COV_FILE}" -o build/coverage-apm-agent-go-report.html +gocover-cobertura < "${COV_FILE}" > build/coverage-apm-agent-go-report.xml From 7fc5752e4d6d7098ee2bf3dfb0a9e99f93717c8f Mon Sep 17 00:00:00 2001 From: Andrew Wilkins Date: Wed, 31 Oct 2018 14:05:21 +0100 Subject: [PATCH 08/48] Update scripts/jenkins/test.sh Co-Authored-By: kuisathaverat --- scripts/jenkins/test.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index cf84e3471..6956e4122 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -3,7 +3,6 @@ set -e export GOPATH=$WORKSPACE eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report -go get -v -u code.google.com/p/go.tools/cmd/cover go get -v -u github.com/t-yuki/gocover-cobertura go get -v -t ./... From c211729a4baa7c9ded82b2aa78671d1d54b9ff3c Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 31 Oct 2018 16:40:55 +0100 Subject: [PATCH 09/48] adjustments in tests --- Jenkinsfile | 34 ++++++++++++++++++++++++++++++++++ scripts/jenkins/docker-test.sh | 25 +++++++++++++++++++++++++ scripts/jenkins/test.sh | 7 ++++--- 3 files changed, 63 insertions(+), 3 deletions(-) create mode 100755 scripts/jenkins/docker-test.sh diff --git a/Jenkinsfile b/Jenkinsfile index e23c51993..1b921a25b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -184,6 +184,40 @@ pipeline { } } } + stage('Docker tests') { + agent { label 'linux && docker' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + } + + when { + beforeAgent true + allOf { + //branch 'master'; + environment name: 'integration_test_ci', value: 'true' + } + } + steps { + withEnvWrapper() { + unstash 'source' + dir("${BASE_DIR}"){ + sh """#!/bin/bash + ./scripts/jenkins/docker-test.sh + """ + codecov('apm-agent-go') + } + } + } + post { + always { + coverageReport("${BASE_DIR}/build/coverage") + junit(allowEmptyResults: true, + keepLongStdio: true, + testResults: "${BASE_DIR}/build/junit-*.xml") + } + } + } /** run Go integration test with the commit version on master branch. diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh new file mode 100755 index 000000000..e1c6f4405 --- /dev/null +++ b/scripts/jenkins/docker-test.sh @@ -0,0 +1,25 @@ +#!/bin/bash +set -e +export GOPATH=$WORKSPACE +eval "$(gvm $GO_VERSION)" +go get -v -u github.com/jstemmer/go-junit-report +go get -v -u github.com/t-yuki/gocover-cobertura +go get -v -t ./... + +export COV_FILE="build/coverage/coverage.cov" +export OUT_FILE="build/test-report.out" +mkdir -p build/coverage + +./scripts/docker-compose-testing up -d --build +./scripts/docker-compose-testing run -T --rm go-agent-tests make coverage | tee ${COV_FILE}.raw + +echo "mode: atomic" > ${COV_FILE} +grep -v "mode\: atomic" ${COV_FILE}.raw >> ${COV_FILE} + +go tool cover -html="${COV_FILE}" -o build/coverage/coverage-apm-agent-go-docker-report.html +gocover-cobertura < "${COV_FILE}" > build/coverage/coverage-apm-agent-go-docker-report.xml + +./scripts/docker-compose-testing run -T --rm go-agent-tests go test -race ./... -v 2>&1 | tee ${OUT_FILE} +cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-docker.xml + + diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index 6956e4122..fd797c018 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -8,9 +8,10 @@ go get -v -t ./... export COV_FILE="build/coverage/coverage.cov" export OUT_FILE="build/test-report.out" -mkdir -p build/coverage +mkdir -p build/coverage + go test -race ./... -v -coverprofile="${COV_FILE}" -coverpkg=go.elastic.co/apm/... 2>&1 | tee ${OUT_FILE} cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go.xml -go tool cover -html="${COV_FILE}" -o build/coverage-apm-agent-go-report.html -gocover-cobertura < "${COV_FILE}" > build/coverage-apm-agent-go-report.xml +go tool cover -html="${COV_FILE}" -o build/coverage/coverage-apm-agent-go-report.html +gocover-cobertura < "${COV_FILE}" > build/coverage/coverage-apm-agent-go-report.xml \ No newline at end of file From a31786fc4ddd58ef16c8a6c72fd187da757f61fc Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Sat, 3 Nov 2018 14:25:16 +0100 Subject: [PATCH 10/48] disable integration test, and remove tags creation --- Jenkinsfile | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 1b921a25b..922a310e7 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -32,7 +32,7 @@ pipeline { booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integration test') booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integration test') - booleanParam(name: 'integration_test_master_ci', defaultValue: true, description: 'Enable run integration test') + booleanParam(name: 'integration_test_master_ci', defaultValue: false, description: 'Enable run integration test') booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation') } @@ -84,7 +84,6 @@ pipeline { on_pull_request { echo "build cause PR" } - gitCreateTag() } } stash allowEmpty: true, name: 'source' @@ -316,7 +315,6 @@ pipeline { post { always { echo 'Post Actions' - gitDeleteTag() } success { echo 'Success Post Actions' From 67e94a95a278791ef8c013bfeb8190b0bca3d133 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 13:53:39 +0100 Subject: [PATCH 11/48] use immutable nodes --- Jenkinsfile | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 922a310e7..f6562bc39 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -95,7 +95,7 @@ pipeline { Build on a linux environment. */ stage('build') { - agent { label 'linux' } + agent { label 'linux && immutable' } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" @@ -120,7 +120,7 @@ pipeline { failFast true parallel { stage('test') { - agent { label 'linux' } + agent { label 'linux && immutable' } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" @@ -151,7 +151,7 @@ pipeline { } } stage('Benchmarks') { - agent { label 'linux' } + agent { label 'linux && immutable' } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" @@ -184,7 +184,7 @@ pipeline { } } stage('Docker tests') { - agent { label 'linux && docker' } + agent { label 'linux && docker && immutable' } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" @@ -222,7 +222,7 @@ pipeline { run Go integration test with the commit version on master branch. */ stage('Integration test master') { - agent { label 'linux' } + agent { label 'linux && immutable' } when { beforeAgent true allOf { @@ -249,7 +249,7 @@ pipeline { run Go integration test with the commit version on a PR. */ stage('Integration test PR') { - agent { label 'linux' } + agent { label 'linux && immutable' } when { beforeAgent true allOf { @@ -278,7 +278,7 @@ pipeline { } stage('Documentation') { - agent { label 'linux' } + agent { label 'linux && immutable' } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" From fc40307286d90e7e3ccf48f75f96e3f5b658e1f3 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 14:01:08 +0100 Subject: [PATCH 12/48] use runbld --- Jenkinsfile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index f6562bc39..3b6f2f391 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -31,7 +31,7 @@ pipeline { booleanParam(name: 'linux_ci', defaultValue: true, description: 'Enable Linux build') booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integration test') - booleanParam(name: 'integration_test_pr_ci', defaultValue: true, description: 'Enable run integration test') + booleanParam(name: 'integration_test_pr_ci', defaultValue: false, description: 'Enable run integration test') booleanParam(name: 'integration_test_master_ci', defaultValue: false, description: 'Enable run integration test') booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation') @@ -109,7 +109,8 @@ pipeline { withEnvWrapper() { unstash 'source' dir("${BASE_DIR}"){ - sh """#!/bin/bash + sh """#!/usr/local/bin/runbld + echo \$PATH make install check """ } From 3aac405040ee5ab0f6a9cd11ad44e9ce66128cdd Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 16:36:15 +0100 Subject: [PATCH 13/48] check and install go --- Jenkinsfile | 3 +- scripts/jenkins/bench.sh | 7 ++ scripts/jenkins/common.bash | 113 +++++++++++++++++++++++++++++++++ scripts/jenkins/docker-test.sh | 7 ++ scripts/jenkins/test.sh | 7 ++ 5 files changed, 135 insertions(+), 2 deletions(-) create mode 100644 scripts/jenkins/common.bash diff --git a/Jenkinsfile b/Jenkinsfile index 3b6f2f391..24d297ad2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -109,8 +109,7 @@ pipeline { withEnvWrapper() { unstash 'source' dir("${BASE_DIR}"){ - sh """#!/usr/local/bin/runbld - echo \$PATH + sh """#!/bin/bash make install check """ } diff --git a/scripts/jenkins/bench.sh b/scripts/jenkins/bench.sh index 9a5faeb9e..5c0358256 100755 --- a/scripts/jenkins/bench.sh +++ b/scripts/jenkins/bench.sh @@ -1,5 +1,12 @@ #!/bin/bash set -e + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. +. ${srcdir}//common.bash + +jenkins_setup + export GOPATH=$WORKSPACE eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report diff --git a/scripts/jenkins/common.bash b/scripts/jenkins/common.bash new file mode 100644 index 000000000..9f8ac1e1e --- /dev/null +++ b/scripts/jenkins/common.bash @@ -0,0 +1,113 @@ +# +# File: common.bash +# +# Common bash routines. +# + +# Script directory: +_sdir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" + +# debug "msg" +# Write a debug message to stderr. +debug() +{ + if [ "$VERBOSE" == "true" ]; then + echo "DEBUG: $1" >&2 + fi +} + +# err "msg" +# Write and error message to stderr. +err() +{ + echo "ERROR: $1" >&2 +} + +# get_go_version +# Read the project's Go version and return it in the GO_VERSION variable. +# On failure it will exit. +get_go_version() { + GO_VERSION=$(cat "${_sdir}/../.go-version") + if [ -z "$GO_VERSION" ]; then + err "Failed to detect the project's Go version" + exit 1 + fi +} + +# install_gimme +# Install gimme to HOME/bin. +install_gimme() { + # Install gimme + if [ ! -f "${HOME}/bin/gimme" ]; then + mkdir -p ${HOME}/bin + curl -sL -o ${HOME}/bin/gimme https://raw.githubusercontent.com/travis-ci/gimme/v1.1.0/gimme + chmod +x ${HOME}/bin/gimme + fi + + GIMME="${HOME}/bin/gimme" + debug "Gimme version $(${GIMME} version)" +} + +# setup_go_root "version" +# This configures the Go version being used. It sets GOROOT and adds +# GOROOT/bin to the PATH. It uses gimme to download the Go version if +# it does not already exist in the ~/.gimme dir. +setup_go_root() { + local version=${1} + + install_gimme + + # Setup GOROOT and add go to the PATH. + ${GIMME} "${version}" > /dev/null + source "${HOME}/.gimme/envs/go${version}.env" 2> /dev/null + + debug "$(go version)" +} + +# setup_go_path "gopath" +# This sets GOPATH and adds GOPATH/bin to the PATH. +setup_go_path() { + local gopath="${1}" + if [ -z "$gopath" ]; then return; fi + + # Setup GOPATH. + export GOPATH="${gopath}" + + # Add GOPATH to PATH. + export PATH="${GOPATH}/bin:${PATH}" + + debug "GOPATH=${GOPATH}" +} + +jenkins_setup() { + : "${HOME:?Need to set HOME to a non-empty value.}" + : "${WORKSPACE:?Need to set WORKSPACE to a non-empty value.}" + + if [ -z ${GO_VERSION:-} ]; then + get_go_version + fi + + # Setup Go. + export GOPATH=${WORKSPACE} + export PATH=${GOPATH}/bin:${PATH} + eval "$(gvm ${GO_VERSION})" + + # Workaround for Python virtualenv path being too long. + export TEMP_PYTHON_ENV=$(mktemp -d) + export PYTHON_ENV="${TEMP_PYTHON_ENV}/python-env" + + # Write cached magefile binaries to workspace to ensure + # each run starts from a clean slate. + export MAGEFILE_CACHE="${WORKSPACE}/.magefile" +} + +docker_setup() { + OS="$(uname)" + case $OS in + 'Darwin') + # Start the docker machine VM (ignore error if it's already running). + docker-machine start default || true + eval $(docker-machine env default) + ;; + esac +} diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh index e1c6f4405..81aeac446 100755 --- a/scripts/jenkins/docker-test.sh +++ b/scripts/jenkins/docker-test.sh @@ -1,5 +1,12 @@ #!/bin/bash set -e + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. +. ${srcdir}//common.bash + +jenkins_setup + export GOPATH=$WORKSPACE eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index fd797c018..4d2a37fef 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -1,5 +1,12 @@ #!/bin/bash set -e + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. +. ${srcdir}//common.bash + +jenkins_setup + export GOPATH=$WORKSPACE eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report From a08cecaa0315206bab3895af1c7cfe13bc0dc5ce Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 16:41:12 +0100 Subject: [PATCH 14/48] check and install go --- Jenkinsfile | 2 +- scripts/jenkins/build.sh | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 scripts/jenkins/build.sh diff --git a/Jenkinsfile b/Jenkinsfile index 24d297ad2..8cfe5d1da 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -110,7 +110,7 @@ pipeline { unstash 'source' dir("${BASE_DIR}"){ sh """#!/bin/bash - make install check + ./scripts/jenkins/build.sh """ } } diff --git a/scripts/jenkins/build.sh b/scripts/jenkins/build.sh new file mode 100644 index 000000000..a4964a8a3 --- /dev/null +++ b/scripts/jenkins/build.sh @@ -0,0 +1,10 @@ +#!/bin/bash +set -e + +srcdir=`dirname $0` +test -z "$srcdir" && srcdir=. +. ${srcdir}//common.bash + +jenkins_setup + +make install check From b31219353b49662f64fa1063e60c9f70a625a32a Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 16:43:32 +0100 Subject: [PATCH 15/48] do not forget to set permissions --- scripts/jenkins/build.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 scripts/jenkins/build.sh diff --git a/scripts/jenkins/build.sh b/scripts/jenkins/build.sh old mode 100644 new mode 100755 From 99e31fd07beadd161ca7b81fa0339d1781e4871a Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 16:46:53 +0100 Subject: [PATCH 16/48] set the GO version --- Jenkinsfile | 1 + 1 file changed, 1 insertion(+) diff --git a/Jenkinsfile b/Jenkinsfile index 8cfe5d1da..d86629187 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,6 +12,7 @@ pipeline { HOME = "${env.HUDSON_HOME}" BASE_DIR="src/go.elastic.co/apm" JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba" + GO_VERSION = "1.10.3" } triggers { cron('0 0 * * 1-5') From d34a3e0c90527c7e1bc33f513272b56a46802e57 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 16:53:32 +0100 Subject: [PATCH 17/48] set the GO version as parameter --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index d86629187..10ae416b3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -12,7 +12,6 @@ pipeline { HOME = "${env.HUDSON_HOME}" BASE_DIR="src/go.elastic.co/apm" JOB_GIT_CREDENTIALS = "f6c7695a-671e-4f4f-a331-acdce44ff9ba" - GO_VERSION = "1.10.3" } triggers { cron('0 0 * * 1-5') @@ -28,7 +27,8 @@ pipeline { durabilityHint('PERFORMANCE_OPTIMIZED') } parameters { - string(name: 'branch_specifier', defaultValue: "", description: "the Git branch specifier to build (, , , etc.)") + string(name: 'branch_specifier', defaultValue: "", description: "the Git branch specifier to build (, , , etc.)") + string(name: 'GO_VERSION', defaultValue: "1.10.3", description: "Go version to use.") booleanParam(name: 'linux_ci', defaultValue: true, description: 'Enable Linux build') booleanParam(name: 'test_ci', defaultValue: true, description: 'Enable test') booleanParam(name: 'integration_test_ci', defaultValue: true, description: 'Enable run integration test') From b14d3e220dea3426d207575ccad7e54c94032656 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 16:56:56 +0100 Subject: [PATCH 18/48] import goimports --- scripts/jenkins/build.sh | 2 ++ 1 file changed, 2 insertions(+) diff --git a/scripts/jenkins/build.sh b/scripts/jenkins/build.sh index a4964a8a3..b284311fa 100755 --- a/scripts/jenkins/build.sh +++ b/scripts/jenkins/build.sh @@ -7,4 +7,6 @@ test -z "$srcdir" && srcdir=. jenkins_setup +go get -u -v golang.org/x/tools/cmd/goimports + make install check From 556e4994cd07f2de1285492abea473ef5c6a7031 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 16:59:44 +0100 Subject: [PATCH 19/48] import goint --- scripts/jenkins/build.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/jenkins/build.sh b/scripts/jenkins/build.sh index b284311fa..bba2685f0 100755 --- a/scripts/jenkins/build.sh +++ b/scripts/jenkins/build.sh @@ -8,5 +8,6 @@ test -z "$srcdir" && srcdir=. jenkins_setup go get -u -v golang.org/x/tools/cmd/goimports +go get -u -v golang.org/x/lint/golint make install check From 09955f9772400ad846590baa41407594257f372e Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 17:03:37 +0100 Subject: [PATCH 20/48] typo --- scripts/jenkins/bench.sh | 2 +- scripts/jenkins/build.sh | 2 +- scripts/jenkins/docker-test.sh | 2 +- scripts/jenkins/test.sh | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/scripts/jenkins/bench.sh b/scripts/jenkins/bench.sh index 5c0358256..f68577be9 100755 --- a/scripts/jenkins/bench.sh +++ b/scripts/jenkins/bench.sh @@ -3,7 +3,7 @@ set -e srcdir=`dirname $0` test -z "$srcdir" && srcdir=. -. ${srcdir}//common.bash +. ${srcdir}/common.bash jenkins_setup diff --git a/scripts/jenkins/build.sh b/scripts/jenkins/build.sh index bba2685f0..26cbccdd0 100755 --- a/scripts/jenkins/build.sh +++ b/scripts/jenkins/build.sh @@ -3,7 +3,7 @@ set -e srcdir=`dirname $0` test -z "$srcdir" && srcdir=. -. ${srcdir}//common.bash +. ${srcdir}/common.bash jenkins_setup diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh index 81aeac446..6d924f3be 100755 --- a/scripts/jenkins/docker-test.sh +++ b/scripts/jenkins/docker-test.sh @@ -3,7 +3,7 @@ set -e srcdir=`dirname $0` test -z "$srcdir" && srcdir=. -. ${srcdir}//common.bash +. ${srcdir}/common.bash jenkins_setup diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index 4d2a37fef..16fc8c594 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -3,7 +3,7 @@ set -e srcdir=`dirname $0` test -z "$srcdir" && srcdir=. -. ${srcdir}//common.bash +. ${srcdir}/common.bash jenkins_setup From 83adaec9b57559ef141561c1b7e597b131061bed Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 17:20:41 +0100 Subject: [PATCH 21/48] merge master changes --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 10ae416b3..dd850b056 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -53,7 +53,7 @@ pipeline { withEnvWrapper() { dir("${BASE_DIR}"){ script{ - if(!branch_specifier){ + if(!env?.branch_specifier){ echo "Checkout SCM ${GIT_BRANCH}" checkout scm } else { From 06ca11890f4f389fceca1b756e6a91e93ed9c68a Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 17:38:23 +0100 Subject: [PATCH 22/48] exit 0 on bench.sh --- scripts/jenkins/bench.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/scripts/jenkins/bench.sh b/scripts/jenkins/bench.sh index f68577be9..9e243d6c2 100755 --- a/scripts/jenkins/bench.sh +++ b/scripts/jenkins/bench.sh @@ -16,3 +16,4 @@ export OUT_FILE="build/bench.out" mkdir -p build go test -run=NONE -benchmem -bench=. ./... -v 2>&1 | tee ${OUT_FILE} cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-bench.xml +exit 0 From 99f5628092b522fa2118e613a49f9b34ef0f6b60 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 17:57:20 +0100 Subject: [PATCH 23/48] testing bench.sh --- scripts/jenkins/bench.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/scripts/jenkins/bench.sh b/scripts/jenkins/bench.sh index 9e243d6c2..64286beb0 100755 --- a/scripts/jenkins/bench.sh +++ b/scripts/jenkins/bench.sh @@ -1,5 +1,5 @@ #!/bin/bash -set -e +set -exo pipefail srcdir=`dirname $0` test -z "$srcdir" && srcdir=. @@ -14,6 +14,5 @@ go get -v -t ./... export OUT_FILE="build/bench.out" mkdir -p build -go test -run=NONE -benchmem -bench=. ./... -v 2>&1 | tee ${OUT_FILE} +go test -run=NONE -benchmem -bench=. ./... -v > ${OUT_FILE} 2>&1 cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-bench.xml -exit 0 From 397ffa588e90ebd5ef24779e591f38c34b11bfa4 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Mon, 5 Nov 2018 19:38:57 +0100 Subject: [PATCH 24/48] testing bench.sh --- scripts/jenkins/bench.sh | 6 +++--- scripts/jenkins/build.sh | 4 ++-- scripts/jenkins/docker-test.sh | 4 ++-- scripts/jenkins/test.sh | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/scripts/jenkins/bench.sh b/scripts/jenkins/bench.sh index 64286beb0..c6dd699c3 100755 --- a/scripts/jenkins/bench.sh +++ b/scripts/jenkins/bench.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set -exo pipefail +#!/usr/bin/env bash +set -euxo pipefail srcdir=`dirname $0` test -z "$srcdir" && srcdir=. @@ -14,5 +14,5 @@ go get -v -t ./... export OUT_FILE="build/bench.out" mkdir -p build -go test -run=NONE -benchmem -bench=. ./... -v > ${OUT_FILE} 2>&1 +go test -run=NONE -benchmem -bench=. ./... -v 2>&1 | tee ${OUT_FILE} cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-bench.xml diff --git a/scripts/jenkins/build.sh b/scripts/jenkins/build.sh index 26cbccdd0..62b73e37c 100755 --- a/scripts/jenkins/build.sh +++ b/scripts/jenkins/build.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set -e +#!/usr/bin/env bash +set -euxo pipefail srcdir=`dirname $0` test -z "$srcdir" && srcdir=. diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh index 6d924f3be..50d4c1a6a 100755 --- a/scripts/jenkins/docker-test.sh +++ b/scripts/jenkins/docker-test.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set -e +#!/usr/bin/env bash +set -euxo pipefail srcdir=`dirname $0` test -z "$srcdir" && srcdir=. diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index 16fc8c594..ec7f56ecb 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -1,5 +1,5 @@ -#!/bin/bash -set -e +#!/usr/bin/env bash +set -euxo pipefail srcdir=`dirname $0` test -z "$srcdir" && srcdir=. From 8f5e104a79bf123e7817caf2b536ae9665834871 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 12:36:40 +0100 Subject: [PATCH 25/48] no report library changes, useless variables --- Jenkinsfile | 1 + scripts/jenkins/bench.sh | 2 -- scripts/jenkins/docker-test.sh | 2 -- scripts/jenkins/test.sh | 2 -- 4 files changed, 1 insertion(+), 6 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index dd850b056..b52266043 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,6 +1,7 @@ #!/usr/bin/env groovy library identifier: 'apm@master', +changelog: false, retriever: modernSCM( [$class: 'GitSCMSource', credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba', diff --git a/scripts/jenkins/bench.sh b/scripts/jenkins/bench.sh index c6dd699c3..dbcc5b6b0 100755 --- a/scripts/jenkins/bench.sh +++ b/scripts/jenkins/bench.sh @@ -7,8 +7,6 @@ test -z "$srcdir" && srcdir=. jenkins_setup -export GOPATH=$WORKSPACE -eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report go get -v -t ./... diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh index 50d4c1a6a..3c71b88bf 100755 --- a/scripts/jenkins/docker-test.sh +++ b/scripts/jenkins/docker-test.sh @@ -7,8 +7,6 @@ test -z "$srcdir" && srcdir=. jenkins_setup -export GOPATH=$WORKSPACE -eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report go get -v -u github.com/t-yuki/gocover-cobertura go get -v -t ./... diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index ec7f56ecb..398435e91 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -7,8 +7,6 @@ test -z "$srcdir" && srcdir=. jenkins_setup -export GOPATH=$WORKSPACE -eval "$(gvm $GO_VERSION)" go get -v -u github.com/jstemmer/go-junit-report go get -v -u github.com/t-yuki/gocover-cobertura go get -v -t ./... From 4b3615fbef290fb74feb176047540217df906988 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 13:34:53 +0100 Subject: [PATCH 26/48] disable ansiColor, test should return 0 as exit code --- Jenkinsfile | 2 +- scripts/jenkins/test.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index b52266043..86b772ee9 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -23,7 +23,7 @@ pipeline { buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '2', daysToKeepStr: '30')) timestamps() preserveStashes() - ansiColor('xterm') + //ansiColor('xterm') disableResume() durabilityHint('PERFORMANCE_OPTIMIZED') } diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index 398435e91..7830a84e3 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -15,7 +15,7 @@ export COV_FILE="build/coverage/coverage.cov" export OUT_FILE="build/test-report.out" mkdir -p build/coverage -go test -race ./... -v -coverprofile="${COV_FILE}" -coverpkg=go.elastic.co/apm/... 2>&1 | tee ${OUT_FILE} +(go test -race ./... -v -coverprofile="${COV_FILE}" -coverpkg=go.elastic.co/apm/... 2>&1 | tee ${OUT_FILE}) || echo -e "\033[31;49mTests FAILED\033[0m" cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go.xml go tool cover -html="${COV_FILE}" -o build/coverage/coverage-apm-agent-go-report.html From e0d7b311e2b40fde1f47f27fb53344985b88dd81 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 15:19:27 +0100 Subject: [PATCH 27/48] stash .git folder --- Jenkinsfile | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 86b772ee9..f592ac585 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -55,7 +55,7 @@ pipeline { dir("${BASE_DIR}"){ script{ if(!env?.branch_specifier){ - echo "Checkout SCM ${GIT_BRANCH}" + echo "Checkout SCM" checkout scm } else { echo "Checkout ${branch_specifier}" @@ -88,7 +88,7 @@ pipeline { } } } - stash allowEmpty: true, name: 'source' + stash allowEmpty: true, name: 'source', useDefaultExcludes: false } } } From 79316bb829cbf1a39476285ccc97b1a7307447ab Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 16:50:25 +0100 Subject: [PATCH 28/48] test --- Jenkinsfile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f592ac585..acb69f9ae 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,6 +40,16 @@ pipeline { } stages { + stage('get Master info'){ + agent { label 'master' } + steps { + sh """ + id + free + ps aux|grep java + """ + } + } /** Checkout the code and stash it, to use it on other stages. */ @@ -173,7 +183,7 @@ pipeline { sh """#!/bin/bash ./scripts/jenkins/bench.sh """ - sendBenchmarks(file: 'build/bench.out') + sendBenchmarks(file: 'build/bench.out', index: "benchmark-go") } } } From b482928e24b639fee31430501a311895d3be1b6e Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 16:59:11 +0100 Subject: [PATCH 29/48] test --- Jenkinsfile | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index acb69f9ae..d8537e04b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -46,7 +46,8 @@ pipeline { sh """ id free - ps aux|grep java + ps aux|grep java + cat /service/jenkins/log/current """ } } From f2b6139d36b4aab373f022b390f3a7bd4758f05f Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 17:00:48 +0100 Subject: [PATCH 30/48] test --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index d8537e04b..180f7e47c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -47,7 +47,7 @@ pipeline { id free ps aux|grep java - cat /service/jenkins/log/current + cat /service/jenkins/log/main/current """ } } From 27d5dc04dab9f49a4d1a8119c0c568835e95007a Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 17:16:21 +0100 Subject: [PATCH 31/48] test --- Jenkinsfile | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 180f7e47c..554469b6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,17 +40,6 @@ pipeline { } stages { - stage('get Master info'){ - agent { label 'master' } - steps { - sh """ - id - free - ps aux|grep java - cat /service/jenkins/log/main/current - """ - } - } /** Checkout the code and stash it, to use it on other stages. */ From 687823b9ad49c4a05cf0fa406bf8699c6a7c1054 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 20:56:42 +0100 Subject: [PATCH 32/48] test --- Jenkinsfile | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 554469b6d..180f7e47c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,6 +40,17 @@ pipeline { } stages { + stage('get Master info'){ + agent { label 'master' } + steps { + sh """ + id + free + ps aux|grep java + cat /service/jenkins/log/main/current + """ + } + } /** Checkout the code and stash it, to use it on other stages. */ From 9179ac20f566a69ff2a6f16dbf03b1c4488d76bf Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Tue, 6 Nov 2018 21:01:27 +0100 Subject: [PATCH 33/48] test --- Jenkinsfile | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 180f7e47c..554469b6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,17 +40,6 @@ pipeline { } stages { - stage('get Master info'){ - agent { label 'master' } - steps { - sh """ - id - free - ps aux|grep java - cat /service/jenkins/log/main/current - """ - } - } /** Checkout the code and stash it, to use it on other stages. */ From f3de2b9abcbe84427283b2ee4b80fd5dfad27d50 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 7 Nov 2018 13:39:16 +0100 Subject: [PATCH 34/48] test --- Jenkinsfile | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 554469b6d..c24d9925d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,6 +40,18 @@ pipeline { } stages { + stage('get Master info'){ + agent { label 'master' } + steps { + sh """ + id + free + ps aux|grep java + ls -la /service/jenkins/log/main/ + cat /service/jenkins/log/main/current + """ + } + } /** Checkout the code and stash it, to use it on other stages. */ From 41c90556f3f597282a2fbaf638aa21aa77b5aa83 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 7 Nov 2018 13:39:49 +0100 Subject: [PATCH 35/48] test --- Jenkinsfile | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c24d9925d..554469b6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,18 +40,6 @@ pipeline { } stages { - stage('get Master info'){ - agent { label 'master' } - steps { - sh """ - id - free - ps aux|grep java - ls -la /service/jenkins/log/main/ - cat /service/jenkins/log/main/current - """ - } - } /** Checkout the code and stash it, to use it on other stages. */ From ecb46b8253a7b20b2522b699e840f7fe6c16fb6b Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 7 Nov 2018 13:42:16 +0100 Subject: [PATCH 36/48] test --- Jenkinsfile | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/Jenkinsfile b/Jenkinsfile index 554469b6d..7e37f753a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,6 +40,22 @@ pipeline { } stages { + stage('get Master info'){ + agent { label 'master' } + steps { + sh """ + id + free + ps aux|grep java + ls -la /service/jenkins/log/main/ + cat '/service/jenkins/log/main/@400000005be1ba6f0585d374.s' + cat '/service/jenkins/log/main/@400000005be1eebf3413db14.s' + cat '/service/jenkins/log/main/@400000005be2bd3b12157694.s' + cat '/service/jenkins/log/main/@400000005be2d68f29a97954.s' + '/service/jenkins/log/main/current' + """ + } + } /** Checkout the code and stash it, to use it on other stages. */ From e4de08d82874eab0882660d9aa9e3860b512abb8 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 7 Nov 2018 14:10:58 +0100 Subject: [PATCH 37/48] test --- Jenkinsfile | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 7e37f753a..554469b6d 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -40,22 +40,6 @@ pipeline { } stages { - stage('get Master info'){ - agent { label 'master' } - steps { - sh """ - id - free - ps aux|grep java - ls -la /service/jenkins/log/main/ - cat '/service/jenkins/log/main/@400000005be1ba6f0585d374.s' - cat '/service/jenkins/log/main/@400000005be1eebf3413db14.s' - cat '/service/jenkins/log/main/@400000005be2bd3b12157694.s' - cat '/service/jenkins/log/main/@400000005be2d68f29a97954.s' - '/service/jenkins/log/main/current' - """ - } - } /** Checkout the code and stash it, to use it on other stages. */ From ebd794a60896fe11974a5638bf73e950f212f41b Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Wed, 7 Nov 2018 15:08:23 +0100 Subject: [PATCH 38/48] typo --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c8af442b..2e491109e 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -[![Build Status](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-go/apm-agent-go-mbp/master)](https://apm-ci.elastic.co/job/apm-agent-go/job/apm-agent-go-mbp//job/master/) +[![Build Status](https://apm-ci.elastic.co/buildStatus/icon?job=apm-agent-go/apm-agent-go-mbp/master)](https://apm-ci.elastic.co/job/apm-agent-go/job/apm-agent-go-mbp/job/master/) [![GoDoc](https://godoc.org/go.elastic.co/apm?status.svg)](http://godoc.org/go.elastic.co/apm) [![Travis-CI](https://travis-ci.org/elastic/apm-agent-go.svg)](https://travis-ci.org/elastic/apm-agent-go) [![AppVeyor](https://ci.appveyor.com/api/projects/status/28fhswvqqc7p90f7?svg=true)](https://ci.appveyor.com/project/AndrewWilkins/apm-agent-go) From fe1b3e6dce365cf590ccecc7b0025a9930e4a777 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 8 Nov 2018 10:42:19 +0100 Subject: [PATCH 39/48] suggested changes --- Jenkinsfile | 1 - scripts/jenkins/build.sh | 2 +- scripts/jenkins/docker-test.sh | 3 +-- 3 files changed, 2 insertions(+), 4 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 554469b6d..af49e785c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -139,7 +139,6 @@ pipeline { sh """#!/bin/bash ./scripts/jenkins/test.sh """ - codecov('apm-agent-go') } } } diff --git a/scripts/jenkins/build.sh b/scripts/jenkins/build.sh index 62b73e37c..9e4e5a033 100755 --- a/scripts/jenkins/build.sh +++ b/scripts/jenkins/build.sh @@ -10,4 +10,4 @@ jenkins_setup go get -u -v golang.org/x/tools/cmd/goimports go get -u -v golang.org/x/lint/golint -make install check +make install precheck diff --git a/scripts/jenkins/docker-test.sh b/scripts/jenkins/docker-test.sh index 3c71b88bf..4ac2016e6 100755 --- a/scripts/jenkins/docker-test.sh +++ b/scripts/jenkins/docker-test.sh @@ -16,7 +16,7 @@ export OUT_FILE="build/test-report.out" mkdir -p build/coverage ./scripts/docker-compose-testing up -d --build -./scripts/docker-compose-testing run -T --rm go-agent-tests make coverage | tee ${COV_FILE}.raw +./scripts/docker-compose-testing run -T --rm go-agent-tests make coverage GOFLAGS=-v 2> >(tee ${OUT_FILE} 1>&2) > ${COV_FILE}.raw echo "mode: atomic" > ${COV_FILE} grep -v "mode\: atomic" ${COV_FILE}.raw >> ${COV_FILE} @@ -24,7 +24,6 @@ grep -v "mode\: atomic" ${COV_FILE}.raw >> ${COV_FILE} go tool cover -html="${COV_FILE}" -o build/coverage/coverage-apm-agent-go-docker-report.html gocover-cobertura < "${COV_FILE}" > build/coverage/coverage-apm-agent-go-docker-report.xml -./scripts/docker-compose-testing run -T --rm go-agent-tests go test -race ./... -v 2>&1 | tee ${OUT_FILE} cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go-docker.xml From 5f46c4919a3f595c4360250f9a8be1e9aeab489a Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 8 Nov 2018 11:13:34 +0100 Subject: [PATCH 40/48] move test stage --- Jenkinsfile | 61 ++++++++++++++++++++++++++--------------------------- 1 file changed, 30 insertions(+), 31 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index af49e785c..9d08e7bfa 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -49,7 +49,6 @@ pipeline { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" } - steps { withEnvWrapper() { dir("${BASE_DIR}"){ @@ -118,39 +117,39 @@ pipeline { } } } + stage('test') { + agent { label 'linux && immutable' } + environment { + PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" + GOPATH = "${env.WORKSPACE}" + } + + when { + beforeAgent true + environment name: 'test_ci', value: 'true' + } + steps { + withEnvWrapper() { + unstash 'source' + dir("${BASE_DIR}"){ + sh """#!/bin/bash + ./scripts/jenkins/test.sh + """ + } + } + } + post { + always { + coverageReport("${BASE_DIR}/build/coverage") + junit(allowEmptyResults: true, + keepLongStdio: true, + testResults: "${BASE_DIR}/build/junit-*.xml") + } + } + } stage('Parallel stages') { failFast true parallel { - stage('test') { - agent { label 'linux && immutable' } - environment { - PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" - GOPATH = "${env.WORKSPACE}" - } - - when { - beforeAgent true - environment name: 'test_ci', value: 'true' - } - steps { - withEnvWrapper() { - unstash 'source' - dir("${BASE_DIR}"){ - sh """#!/bin/bash - ./scripts/jenkins/test.sh - """ - } - } - } - post { - always { - coverageReport("${BASE_DIR}/build/coverage") - junit(allowEmptyResults: true, - keepLongStdio: true, - testResults: "${BASE_DIR}/build/junit-*.xml") - } - } - } stage('Benchmarks') { agent { label 'linux && immutable' } environment { From 59372f40cf55f45d552b3381e045ff52c055e472 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 8 Nov 2018 14:18:44 +0100 Subject: [PATCH 41/48] remove old style github integration, we will use pipeline multibranch job integration --- Jenkinsfile | 1 - 1 file changed, 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index 9d08e7bfa..321db150b 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -16,7 +16,6 @@ pipeline { } triggers { cron('0 0 * * 1-5') - githubPush() } options { timeout(time: 1, unit: 'HOURS') From d53b105ed1685a9a7aa3485dcbe137ec9416aa2e Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 8 Nov 2018 14:52:19 +0100 Subject: [PATCH 42/48] remove covertura on test stage, add trick to see the full logs in color on BO --- Jenkinsfile | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index 321db150b..bdea8dbb2 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -139,7 +139,6 @@ pipeline { } post { always { - coverageReport("${BASE_DIR}/build/coverage") junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/build/junit-*.xml") @@ -159,7 +158,7 @@ pipeline { when { beforeAgent true allOf { - //branch 'master'; + branch 'master'; environment name: 'bench_ci', value: 'true' } } @@ -191,10 +190,7 @@ pipeline { when { beforeAgent true - allOf { - //branch 'master'; - environment name: 'integration_test_ci', value: 'true' - } + environment name: 'integration_test_ci', value: 'true' } steps { withEnvWrapper() { @@ -225,7 +221,7 @@ pipeline { when { beforeAgent true allOf { - //branch 'master'; + branch 'master'; environment name: 'integration_test_master_ci', value: 'true' } } @@ -287,7 +283,7 @@ pipeline { when { beforeAgent true allOf { - //branch 'master'; + branch 'master'; environment name: 'doc_ci', value: 'true' } } @@ -310,6 +306,14 @@ pipeline { } } } + stage('Full log') { + when { + environment name: 'Never', value: 'true' + } + steps { + echo "NOOP" + } + } } post { always { From d099649f5ebd10e3e9135d67bc978ac7241e8e07 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 8 Nov 2018 14:53:17 +0100 Subject: [PATCH 43/48] remove cobertura from the test script --- scripts/jenkins/test.sh | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index 7830a84e3..edfb30395 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -8,15 +8,10 @@ test -z "$srcdir" && srcdir=. jenkins_setup go get -v -u github.com/jstemmer/go-junit-report -go get -v -u github.com/t-yuki/gocover-cobertura go get -v -t ./... -export COV_FILE="build/coverage/coverage.cov" export OUT_FILE="build/test-report.out" -mkdir -p build/coverage +mkdir -p build -(go test -race ./... -v -coverprofile="${COV_FILE}" -coverpkg=go.elastic.co/apm/... 2>&1 | tee ${OUT_FILE}) || echo -e "\033[31;49mTests FAILED\033[0m" +(go test -race ./... -v 2>&1 | tee ${OUT_FILE}) || echo -e "\033[31;49mTests FAILED\033[0m" cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go.xml - -go tool cover -html="${COV_FILE}" -o build/coverage/coverage-apm-agent-go-report.html -gocover-cobertura < "${COV_FILE}" > build/coverage/coverage-apm-agent-go-report.xml \ No newline at end of file From bbdaa726873a76f45c5fd6b4b864ee6e8b350885 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 8 Nov 2018 14:57:06 +0100 Subject: [PATCH 44/48] simplify script --- scripts/jenkins/test.sh | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/scripts/jenkins/test.sh b/scripts/jenkins/test.sh index edfb30395..88d1f8248 100755 --- a/scripts/jenkins/test.sh +++ b/scripts/jenkins/test.sh @@ -10,8 +10,6 @@ jenkins_setup go get -v -u github.com/jstemmer/go-junit-report go get -v -t ./... -export OUT_FILE="build/test-report.out" mkdir -p build -(go test -race ./... -v 2>&1 | tee ${OUT_FILE}) || echo -e "\033[31;49mTests FAILED\033[0m" -cat ${OUT_FILE} | go-junit-report > build/junit-apm-agent-go.xml +(go test -race ./... -v 2>&1 | go-junit-report > build/junit-apm-agent-go.xml) || echo -e "\033[31;49mTests FAILED\033[0m" From eaf0aa1b5388f66c83ab9c14f9a0fa94c516c3eb Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 15 Nov 2018 13:10:36 +0100 Subject: [PATCH 45/48] improvements --- Jenkinsfile | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index bdea8dbb2..e155f3c1a 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -316,21 +316,18 @@ pipeline { } } post { - always { - echo 'Post Actions' + success { + echoColor(text: '[SUCCESS]', colorfg: 'green', colorbg: 'default') } - success { - echo 'Success Post Actions' - } - aborted { - echo 'Aborted Post Actions' + aborted { + echoColor(text: '[ABORTED]', colorfg: 'magenta', colorbg: 'default') } failure { - echo 'Failure Post Actions' + echoColor(text: '[FAILURE]', colorfg: 'red', colorbg: 'default') //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${NOTIFY_TO}", sendToIndividuals: false]) } unstable { - echo 'Unstable Post Actions' + echoColor(text: '[UNSTABLE]', colorfg: 'yellow', colorbg: 'default') } } } From 04921d85d9e71b385cebd5f99773d9dbec69d5a0 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 15 Nov 2018 16:30:51 +0100 Subject: [PATCH 46/48] run it only on PRs --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index e155f3c1a..c1677e6cf 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -248,7 +248,7 @@ pipeline { when { beforeAgent true allOf { - not { branch 'master' }; + changeRequest() environment name: 'integration_test_pr_ci', value: 'true' } } From a6506bcea8c2d92b326d225df71bee6b11193621 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Thu, 22 Nov 2018 18:53:55 +0100 Subject: [PATCH 47/48] add skipDefaultCheckout --- Jenkinsfile | 151 +++++++++++++++++++++++----------------------------- 1 file changed, 68 insertions(+), 83 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index c1677e6cf..f8c71c3d3 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -1,10 +1,10 @@ #!/usr/bin/env groovy -library identifier: 'apm@master', +library identifier: 'apm@master', changelog: false, retriever: modernSCM( - [$class: 'GitSCMSource', - credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba', + [$class: 'GitSCMSource', + credentialsId: 'f6c7695a-671e-4f4f-a331-acdce44ff9ba', remote: 'git@github.com:elastic/apm-pipeline-library.git']) pipeline { @@ -18,7 +18,7 @@ pipeline { cron('0 0 * * 1-5') } options { - timeout(time: 1, unit: 'HOURS') + timeout(time: 1, unit: 'HOURS') buildDiscarder(logRotator(numToKeepStr: '3', artifactNumToKeepStr: '2', daysToKeepStr: '30')) timestamps() preserveStashes() @@ -37,13 +37,13 @@ pipeline { booleanParam(name: 'bench_ci', defaultValue: true, description: 'Enable benchmarks') booleanParam(name: 'doc_ci', defaultValue: true, description: 'Enable build documentation') } - stages { /** Checkout the code and stash it, to use it on other stages. */ stage('Checkout') { agent { label 'master || linux' } + options { skipDefaultCheckout() } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" @@ -57,58 +57,40 @@ pipeline { checkout scm } else { echo "Checkout ${branch_specifier}" - checkout([$class: 'GitSCM', branches: [[name: "${branch_specifier}"]], - doGenerateSubmoduleConfigurations: false, + checkout([$class: 'GitSCM', branches: [[name: "${branch_specifier}"]], + doGenerateSubmoduleConfigurations: false, extensions: [], submoduleCfg: [], - userRemoteConfigs: [[credentialsId: "${JOB_GIT_CREDENTIALS}", + userRemoteConfigs: [[credentialsId: "${JOB_GIT_CREDENTIALS}", url: "${GIT_URL}"]]]) } env.JOB_GIT_COMMIT = getGitCommitSha() env.JOB_GIT_URL = "${GIT_URL}" - github_enterprise_constructor() - - on_change{ - echo "build cause a change (commit or PR)" - } - - on_commit { - echo "build cause a commit" - } - - on_merge { - echo "build cause a merge" - } - - on_pull_request { - echo "build cause PR" - } } } stash allowEmpty: true, name: 'source', useDefaultExcludes: false } } } - /** Build on a linux environment. */ - stage('build') { + stage('build') { agent { label 'linux && immutable' } + options { skipDefaultCheckout() } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" } - - when { + when { beforeAgent true - environment name: 'linux_ci', value: 'true' + environment name: 'linux_ci', value: 'true' } steps { withEnvWrapper() { unstash 'source' - dir("${BASE_DIR}"){ + dir("${BASE_DIR}"){ sh """#!/bin/bash ./scripts/jenkins/build.sh """ @@ -116,31 +98,34 @@ pipeline { } } } + /** + Run unit tests and store the results in Jenkins. + */ stage('test') { agent { label 'linux && immutable' } + options { skipDefaultCheckout() } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" } - - when { + when { beforeAgent true - environment name: 'test_ci', value: 'true' + environment name: 'test_ci', value: 'true' } steps { withEnvWrapper() { unstash 'source' - dir("${BASE_DIR}"){ + dir("${BASE_DIR}"){ sh """#!/bin/bash ./scripts/jenkins/test.sh """ } } } - post { + post { always { - junit(allowEmptyResults: true, - keepLongStdio: true, + junit(allowEmptyResults: true, + keepLongStdio: true, testResults: "${BASE_DIR}/build/junit-*.xml") } } @@ -148,54 +133,60 @@ pipeline { stage('Parallel stages') { failFast true parallel { + /** + Run Benchmarks and send the results to ES. + */ stage('Benchmarks') { agent { label 'linux && immutable' } + options { skipDefaultCheckout() } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" } - - when { + when { beforeAgent true - allOf { + allOf { branch 'master'; - environment name: 'bench_ci', value: 'true' + environment name: 'bench_ci', value: 'true' } } steps { withEnvWrapper() { unstash 'source' - dir("${BASE_DIR}"){ + dir("${BASE_DIR}"){ sh """#!/bin/bash ./scripts/jenkins/bench.sh """ sendBenchmarks(file: 'build/bench.out', index: "benchmark-go") } } - } + } post { always { - junit(allowEmptyResults: true, - keepLongStdio: true, + junit(allowEmptyResults: true, + keepLongStdio: true, testResults: "${BASE_DIR}/build/junit-*.xml") } } } + /** + Run tests in a docker container and store the results in jenkins and codecov. + */ stage('Docker tests') { agent { label 'linux && docker && immutable' } + options { skipDefaultCheckout() } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" } - - when { + when { beforeAgent true - environment name: 'integration_test_ci', value: 'true' + environment name: 'integration_test_ci', value: 'true' } steps { withEnvWrapper() { unstash 'source' - dir("${BASE_DIR}"){ + dir("${BASE_DIR}"){ sh """#!/bin/bash ./scripts/jenkins/docker-test.sh """ @@ -203,31 +194,31 @@ pipeline { } } } - post { - always { + post { + always { coverageReport("${BASE_DIR}/build/coverage") - junit(allowEmptyResults: true, - keepLongStdio: true, + junit(allowEmptyResults: true, + keepLongStdio: true, testResults: "${BASE_DIR}/build/junit-*.xml") } } } - /** run Go integration test with the commit version on master branch. */ - stage('Integration test master') { + stage('Integration test master') { agent { label 'linux && immutable' } - when { + options { skipDefaultCheckout() } + when { beforeAgent true - allOf { + allOf { branch 'master'; - environment name: 'integration_test_master_ci', value: 'true' + environment name: 'integration_test_master_ci', value: 'true' } } steps { build( - job: 'apm-server-ci/apm-integration-test-axis-pipeline', + job: 'apm-server-ci/apm-integration-test-axis-pipeline', parameters: [ string(name: 'BUILD_DESCRIPTION', value: "${BUILD_TAG}-INTEST"), booleanParam(name: "go_Test", value: true), @@ -239,22 +230,22 @@ pipeline { propagate: true) } } - /** run Go integration test with the commit version on a PR. */ - stage('Integration test PR') { + stage('Integration test PR') { agent { label 'linux && immutable' } - when { + options { skipDefaultCheckout() } + when { beforeAgent true - allOf { + allOf { changeRequest() - environment name: 'integration_test_pr_ci', value: 'true' + environment name: 'integration_test_pr_ci', value: 'true' } } steps { build( - job: 'apm-server-ci/apm-integration-test-pipeline', + job: 'apm-server-ci/apm-integration-test-pipeline', parameters: [ string(name: 'BUILD_DESCRIPTION', value: "${BUILD_TAG}-INTEST"), string(name: 'APM_AGENT_GO_PKG', value: "${BUILD_TAG}"), @@ -271,20 +262,22 @@ pipeline { } } } - - stage('Documentation') { + /** + Build the documenattions. + */ + stage('Documentation') { agent { label 'linux && immutable' } + options { skipDefaultCheckout() } environment { PATH = "${env.PATH}:${env.HUDSON_HOME}/go/bin/:${env.WORKSPACE}/bin" GOPATH = "${env.WORKSPACE}" ELASTIC_DOCS = "${env.WORKSPACE}/elastic/docs" } - - when { + when { beforeAgent true - allOf { + allOf { branch 'master'; - environment name: 'doc_ci', value: 'true' + environment name: 'doc_ci', value: 'true' } } steps { @@ -293,7 +286,7 @@ pipeline { dir("${ELASTIC_DOCS}"){ git "https://github.com/elastic/docs.git" } - dir("${BASE_DIR}"){ + dir("${BASE_DIR}"){ sh """#!/bin/bash make docs """ @@ -306,14 +299,6 @@ pipeline { } } } - stage('Full log') { - when { - environment name: 'Never', value: 'true' - } - steps { - echo "NOOP" - } - } } post { success { @@ -322,11 +307,11 @@ pipeline { aborted { echoColor(text: '[ABORTED]', colorfg: 'magenta', colorbg: 'default') } - failure { + failure { echoColor(text: '[FAILURE]', colorfg: 'red', colorbg: 'default') //step([$class: 'Mailer', notifyEveryUnstableBuild: true, recipients: "${NOTIFY_TO}", sendToIndividuals: false]) } - unstable { + unstable { echoColor(text: '[UNSTABLE]', colorfg: 'yellow', colorbg: 'default') } } From f35e3244be0f4baaa257547b8249147c6912ab55 Mon Sep 17 00:00:00 2001 From: Ivan Fernandez Calvo Date: Fri, 23 Nov 2018 12:35:56 +0100 Subject: [PATCH 48/48] codecov changes --- Jenkinsfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Jenkinsfile b/Jenkinsfile index f8c71c3d3..be46abc48 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -190,7 +190,6 @@ pipeline { sh """#!/bin/bash ./scripts/jenkins/docker-test.sh """ - codecov('apm-agent-go') } } } @@ -200,6 +199,7 @@ pipeline { junit(allowEmptyResults: true, keepLongStdio: true, testResults: "${BASE_DIR}/build/junit-*.xml") + codecov(repo: 'apm-agent-go', basedir: "${BASE_DIR}") } } }