-
Notifications
You must be signed in to change notification settings - Fork 127
Add more stages to main buildkite pipeline #1130
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
Changes from all commits
37921bc
97b0404
f6c8544
998b1cf
663bab8
6f2a188
fc6229d
03dcd6b
d2f3cab
98c37ad
f6637a5
44ca5f4
5454e7c
93d85c3
20cc88c
693fc97
6d2be6f
7fd2313
4ff6233
3d30f33
d8c528e
2b8a93c
956af89
6a89ace
4c33798
0895e2f
644d36b
30fb51b
aa08b37
0e3c48a
00089c2
0feb72a
daa4de8
8387042
9159ddc
93efa17
670cd89
c153d44
1385a94
3740ebe
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,53 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| checkout_merge() { | ||
| local target_branch=$1 | ||
| local pr_commit=$2 | ||
| local merge_branch=$3 | ||
|
|
||
| if [[ -z "${target_branch}" ]]; then | ||
| echo "No pull request target branch" | ||
| exit 1 | ||
| fi | ||
|
|
||
| git fetch -v origin "${target_branch}" | ||
| git checkout FETCH_HEAD | ||
| echo "Current branch: $(git rev-parse --abbrev-ref HEAD)" | ||
|
|
||
| # create temporal branch to merge the PR with the target branch | ||
| git checkout -b ${merge_branch} | ||
| echo "New branch created: $(git rev-parse --abbrev-ref HEAD)" | ||
|
|
||
| # set author identity so it can be run git merge | ||
| git config user.name "github-merged-pr-post-checkout" | ||
| git config user.email "auto-merge@buildkite" | ||
|
|
||
| git merge --no-edit "${BUILDKITE_COMMIT}" || { | ||
| local merge_result=$? | ||
| echo "Merge failed: ${merge_result}" | ||
| git merge --abort | ||
| exit ${merge_result} | ||
| } | ||
| } | ||
|
|
||
| pull_request="${BUILDKITE_PULL_REQUEST:-false}" | ||
|
|
||
| if [[ "${pull_request}" == "false" ]]; then | ||
| echo "Not a pull request, skipping" | ||
| exit 0 | ||
| fi | ||
|
|
||
| TARGET_BRANCH="${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}" | ||
| PR_COMMIT="${BUILDKITE_COMMIT}" | ||
| PR_ID=${BUILDKITE_PULL_REQUEST} | ||
| MERGE_BRANCH="pr_merge_${PR_ID}" | ||
|
|
||
| checkout_merge "${TARGET_BRANCH}" "${PR_COMMIT}" "${MERGE_BRANCH}" | ||
|
|
||
| echo "Commit information" | ||
| git log --format=%B -n 1 | ||
|
|
||
| # Ensure buildkite groups are rendered | ||
| echo "" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| function retry { | ||
| local retries=$1 | ||
| shift | ||
|
|
||
| local count=0 | ||
| until "$@"; do | ||
| exit=$? | ||
| wait=$((2 ** count)) | ||
| count=$((count + 1)) | ||
| if [ $count -lt "$retries" ]; then | ||
| >&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..." | ||
| sleep $wait | ||
| else | ||
| >&2 echo "Retry $count/$retries exited $exit, no more retries left." | ||
| return $exit | ||
| fi | ||
| done | ||
| return 0 | ||
| } | ||
|
|
||
| GCP_SERVICE_ACCOUNT_SECRET_PATH=secret/ci/elastic-elastic-package/gcp-service-account | ||
| AWS_SERVICE_ACCOUNT_SECRET_PATH=kv/ci-shared/platform-ingest/aws_account_auth | ||
| GITHUB_TOKEN_VAULT_PATH=kv/ci-shared/platform-ingest/github_token | ||
|
|
||
| # Secrets must be redacted | ||
| # https://buildkite.com/docs/pipelines/managing-log-output#redacted-environment-variables | ||
|
|
||
| if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && "$BUILDKITE_STEP_KEY" == "integration-parallel-gcp" ]]; then | ||
| export ELASTIC_PACKAGE_GCP_PROJECT_SECRET=$(retry 5 vault read -field projectId ${GCP_SERVICE_ACCOUNT_SECRET_PATH}) | ||
| export ELASTIC_PACKAGE_GCP_CREDENTIALS_SECRET=$(retry 5 vault read -field credentials ${GCP_SERVICE_ACCOUNT_SECRET_PATH}) | ||
|
|
||
| # Environment variables required by the service deployer | ||
| export GOOGLE_CREDENTIALS=${ELASTIC_PACKAGE_GCP_CREDENTIALS_SECRET} | ||
| export GCP_PROJECT_ID=${ELASTIC_PACKAGE_GCP_PROJECT_SECRET} | ||
| fi | ||
|
|
||
| if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && "$BUILDKITE_STEP_KEY" == "integration-parallel-aws" ]]; then | ||
| export ELASTIC_PACKAGE_AWS_SECRET_KEY=$(retry 5 vault kv get -field secret_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH}) | ||
| export ELASTIC_PACKAGE_AWS_ACCESS_KEY=$(retry 5 vault kv get -field access_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH}) | ||
|
|
||
| # Environment variables required by the service deployer | ||
| export AWS_SECRET_ACCESS_KEY=${ELASTIC_PACKAGE_AWS_SECRET_KEY} | ||
| export AWS_ACCESS_KEY_ID=${ELASTIC_PACKAGE_AWS_ACCESS_KEY} | ||
| fi | ||
|
|
||
| if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && "$BUILDKITE_STEP_KEY" == "release" ]]; then | ||
| export GITHUB_TOKEN=$(retry 5 vault kv get -field token ${GITHUB_TOKEN_VAULT_PATH}) | ||
| fi | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,79 @@ | ||
| #!/bin/bash | ||
|
|
||
| # exit immediately on failure, or if an undefined variable is used | ||
| set -eu | ||
|
|
||
| # begin the pipeline.yml file | ||
| echo "steps:" | ||
| echo " - group: \":terminal: Integration test suite\"" | ||
| echo " key: \"integration-tests\"" | ||
| echo " steps:" | ||
|
|
||
| # Integration tests related stack command | ||
| STACK_COMMAND_TESTS=( | ||
| test-stack-command-default | ||
| test-stack-command-oldest | ||
| test-stack-command-7x | ||
| test-stack-command-86 | ||
| test-stack-command-8x | ||
| ) | ||
|
|
||
| for test in ${STACK_COMMAND_TESTS[@]}; do | ||
| echo " - label: \":go: Running integration test: ${test}\"" | ||
| echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}" | ||
| echo " agents:" | ||
| echo " provider: \"gcp\"" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Provider gcp is required to use docker-like commands. |
||
| echo " artifact_paths:" | ||
| echo " - build/elastic-stack-dump/stack/*/logs/*.log" | ||
| echo " - build/elastic-stack-dump/stack/*/logs/fleet-server-internal/*.log" | ||
| echo " - build/elastic-stack-status/*/*" | ||
| done | ||
|
|
||
| CHECK_PACKAGES_TESTS=( | ||
| test-check-packages-other | ||
| test-check-packages-with-kind | ||
| test-check-packages-with-custom-agent | ||
| test-check-packages-benchmarks | ||
| ) | ||
| for test in ${CHECK_PACKAGES_TESTS[@]}; do | ||
| echo " - label: \":go: Running integration test: ${test}\"" | ||
| echo " command: ./.buildkite/scripts/integration_tests.sh -t ${test}" | ||
| echo " agents:" | ||
| echo " provider: \"gcp\"" | ||
| echo " artifact_paths:" | ||
| echo " - build/test-results/*.xml" | ||
| echo " - build/elastic-stack-dump/stack/check-*/logs/*.log" | ||
| echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/*.log" | ||
| if [[ $test =~ with-kind$ ]]; then | ||
| echo " - build/kubectl-dump.txt" | ||
| fi | ||
| done | ||
|
|
||
| pushd test/packages/parallel > /dev/null | ||
| for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do | ||
| package_name=$(basename ${package}) | ||
| echo " - label: \":go: Running integration test: ${package_name}\"" | ||
| echo " key: \"integration-parallel-${package_name}\"" | ||
| echo " command: ./.buildkite/scripts/integration_tests.sh -t test-check-packages-parallel -p ${package_name}" | ||
| echo " agents:" | ||
| echo " provider: \"gcp\"" | ||
| echo " artifact_paths:" | ||
| echo " - build/test-results/*.xml" | ||
| echo " - build/elastic-stack-dump/stack/check-*/logs/*.log" | ||
| echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/*.log" | ||
| done | ||
|
|
||
| popd > /dev/null | ||
|
|
||
| echo " - label: \":go: Running integration test: test-build-zip\"" | ||
| echo " command: ./.buildkite/scripts/integration_tests.sh -t test-build-zip" | ||
| echo " agents:" | ||
| echo " provider: \"gcp\"" | ||
| echo " artifact_paths:" | ||
| echo " - build/elastic-stack-dump/stack/*/logs/*.log" | ||
| echo " - build/packages/*.sig" | ||
|
|
||
| echo " - label: \":go: Running integration test: test-profiles-command\"" | ||
| echo " command: ./.buildkite/scripts/integration_tests.sh -t test-profiles-command" | ||
| echo " agents:" | ||
| echo " provider: \"gcp\"" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,20 @@ | ||
| env: | ||
| SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151 | ||
| DOCKER_COMPOSE_VERSION: "1.25.5" # "v2.15.1" | ||
jsoriano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| KIND_VERSION: 'v0.17.0' | ||
| K8S_VERSION: 'v1.26.0' | ||
|
|
||
| steps: | ||
| - label: ":go: Run check-static" | ||
| key: check-static | ||
| command: "make check-static" | ||
| agents: | ||
| image: "golang:1.19.5" | ||
| cpu: "8" | ||
| memory: "4G" | ||
|
|
||
| - label: ":go: Run unit tests" | ||
| - label: ":go: :linux: Run unit tests" | ||
| key: unit-tests-linux | ||
| command: "make test-go-ci" | ||
| artifact_paths: | ||
| - "build/test-results/*.xml" | ||
|
|
@@ -19,10 +27,31 @@ steps: | |
| - wait: ~ | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why we are adding this wait step? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This wait forces that the two steps defined previously (Run check static and Run unit tests) are finished before executing the following ones. I wanted to force that way, so in case one of these two steps fail, integration tests are not run. Same behavior as in Jenkins. |
||
| continue_on_failure: true | ||
|
|
||
| - label: "Junit annotate" | ||
| - label: ":pipeline: Trigger Integration tests" | ||
jsoriano marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| command: ".buildkite/pipeline.trigger.integration.tests.sh | buildkite-agent pipeline upload" | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a bit of complexity here. To run integration tests we have this stack of scripts:
There would be any option to reduce this complexity? Maybe we can remove the make targets and call directly the scripts? Though the make targets can be useful to reproduce locally with the same parameters. Or most of the things Food for thought, no need to do anything about this on this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's true, there are more scripts than before with Jenkins. All that logic was defined inside the same groovy file (
As you mention, I would keep
Those dependencies installed in |
||
| depends_on: | ||
| - step: check-static | ||
| allow_failure: false | ||
| - step: unit-tests-linux | ||
| allow_failure: false | ||
|
|
||
| - wait: ~ | ||
| continue_on_failure: true | ||
|
|
||
| - label: ":junit: Junit annotate" | ||
| plugins: | ||
| - junit-annotate#v2.4.1: | ||
| artifacts: "build/test-results/*.xml" | ||
| agents: | ||
| provider: "gcp" | ||
| provider: "gcp" # junit plugin requires docker | ||
|
|
||
| - label: ":github: Release" | ||
| key: "release" | ||
| # build.tag != null && build.branch == "main" | ||
| if: | | ||
| build.tag =~ /^v[0-9]+[.][0-9]+[.][0-9]+$$/ && build.branch == "main" | ||
| command: ".buildkite/scripts/release.sh" | ||
| agents: | ||
| image: "golang:1.19.5" | ||
| cpu: "8" | ||
| memory: "4G" | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,106 @@ | ||
| #!/bin/bash | ||
mrodm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| set -euo pipefail | ||
|
|
||
| PARALLEL_TARGET="test-check-packages-parallel" | ||
| KIND_TARGET="test-check-packages-with-kind" | ||
|
|
||
| usage() { | ||
| echo "$0 [-t <target>] [-h]" | ||
| echo "Trigger integration tests related to a target in Makefile" | ||
| echo -e "\t-t <target>: Makefile target. Mandatory" | ||
| echo -e "\t-p <package>: Package (required for test-check-packages-parallel target)." | ||
| echo -e "\t-h: Show this message" | ||
| } | ||
|
|
||
| with_kubernetes() { | ||
| # FIXME add retry logic | ||
| mkdir -p ${WORKSPACE}/bin | ||
| curl -sSLo ${WORKSPACE}/bin/kind "https://github.com/kubernetes-sigs/kind/releases/download/${KIND_VERSION}/kind-linux-amd64" | ||
| chmod +x ${WORKSPACE}/bin/kind | ||
| kind version | ||
| which kind | ||
|
|
||
| mkdir -p ${WORKSPACE}/bin | ||
| curl -sSLo ${WORKSPACE}/bin/kubectl "https://storage.googleapis.com/kubernetes-release/release/${K8S_VERSION}/bin/linux/amd64/kubectl" | ||
| chmod +x ${WORKSPACE}/bin/kubectl | ||
| kubectl version --client | ||
| which kubectl | ||
| } | ||
|
|
||
| with_go() { | ||
| # FIXME add retry logic | ||
| mkdir -p ${WORKSPACE}/bin | ||
| curl -sL -o ${WORKSPACE}/bin/gvm "https://github.com/andrewkroh/gvm/releases/download/${SETUP_GVM_VERSION}/gvm-linux-amd64" | ||
| chmod +x ${WORKSPACE}/bin/gvm | ||
| eval "$(gvm $(cat .go-version))" | ||
| go version | ||
| which go | ||
| } | ||
|
|
||
| with_docker_compose() { | ||
| # FIXME add retry logic | ||
| mkdir -p ${WORKSPACE}/bin | ||
| curl -SL -o ${WORKSPACE}/bin/docker-compose "https://github.com/docker/compose/releases/download/${DOCKER_COMPOSE_VERSION}/docker-compose-linux-x86_64" | ||
| chmod +x ${WORKSPACE}/bin/docker-compose | ||
| docker-compose version | ||
| } | ||
|
|
||
| TARGET="" | ||
| PACKAGE="" | ||
| while getopts ":t:p:h" o; do | ||
| case "${o}" in | ||
| t) | ||
| TARGET=${OPTARG} | ||
| ;; | ||
| p) | ||
| PACKAGE=${OPTARG} | ||
| ;; | ||
| h) | ||
| usage | ||
| exit 0 | ||
| ;; | ||
| \?) | ||
| echo "Invalid option ${OPTARG}" | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| :) | ||
| echo "Missing argument for -${OPTARG}" | ||
| usage | ||
| exit 1 | ||
| ;; | ||
| esac | ||
| done | ||
|
|
||
| if [[ "${TARGET}" == "" ]]; then | ||
| echo "Missing target" | ||
| usage | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "Current path: $(pwd)" | ||
| WORKSPACE="$(pwd)" | ||
| export PATH="${WORKSPACE}/bin:${PATH}" | ||
| echo "Path: $PATH" | ||
|
|
||
| echo "--- install go" | ||
| with_go | ||
| export PATH="$(go env GOPATH)/bin:${PATH}" | ||
|
|
||
| echo "--- install docker-compose" | ||
| with_docker_compose | ||
|
|
||
| if [[ "${TARGET}" == "${KIND_TARGET}" ]]; then | ||
| echo "--- install kubectl & kind" | ||
| with_kubernetes | ||
| fi | ||
|
|
||
| echo "--- Run integration test ${TARGET}" | ||
| if [[ "${TARGET}" == "${PARALLEL_TARGET}" ]]; then | ||
| make install | ||
| make PACKAGE_UNDER_TEST=${PACKAGE} ${TARGET} | ||
| exit 0 | ||
| fi | ||
|
|
||
| make install ${TARGET} check-git-clean | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| #!/bin/bash | ||
|
|
||
| set -euo pipefail | ||
|
|
||
| echo "--- fetching tags" | ||
| # Ensure that tags are present so goreleaser can build the changelog from the last release. | ||
| git rev-parse --is-shallow-repository | ||
| git fetch origin --tags | ||
|
|
||
| echo "--- running goreleaser" | ||
| # Run latest version of goreleaser | ||
| curl -sL https://git.io/goreleaser | bash | ||
|
|
Uh oh!
There was an error while loading. Please reload this page.