Skip to content

Commit b2c10e4

Browse files
committed
Revert "use only github actions"
This reverts commit 8784ed3.
1 parent c256c81 commit b2c10e4

8 files changed

Lines changed: 255 additions & 0 deletions

File tree

.buildkite/hooks/post-checkout

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
checkout_merge() {
6+
local target_branch=$1
7+
local pr_commit=$2
8+
local merge_branch=$3
9+
10+
if [[ -z "${target_branch}" ]]; then
11+
echo "No pull request target branch"
12+
exit 1
13+
fi
14+
15+
git fetch -v origin "${target_branch}"
16+
git checkout FETCH_HEAD
17+
echo "Current branch: $(git rev-parse --abbrev-ref HEAD)"
18+
19+
# create temporal branch to merge the PR with the target branch
20+
git checkout -b ${merge_branch}
21+
echo "New branch created: $(git rev-parse --abbrev-ref HEAD)"
22+
23+
# set author identity so it can be run git merge
24+
git config user.name "github-merged-pr-post-checkout"
25+
git config user.email "auto-merge@buildkite"
26+
27+
git merge --no-edit "${BUILDKITE_COMMIT}" || {
28+
local merge_result=$?
29+
echo "Merge failed: ${merge_result}"
30+
git merge --abort
31+
exit ${merge_result}
32+
}
33+
}
34+
35+
pull_request="${BUILDKITE_PULL_REQUEST:-false}"
36+
37+
if [[ "${pull_request}" == "false" ]]; then
38+
echo "Not a pull request, skipping"
39+
exit 0
40+
fi
41+
42+
TARGET_BRANCH="${BUILDKITE_PULL_REQUEST_BASE_BRANCH:-master}"
43+
PR_COMMIT="${BUILDKITE_COMMIT}"
44+
PR_ID=${BUILDKITE_PULL_REQUEST}
45+
MERGE_BRANCH="pr_merge_${PR_ID}"
46+
47+
checkout_merge "${TARGET_BRANCH}" "${PR_COMMIT}" "${MERGE_BRANCH}"
48+
49+
echo "Commit information"
50+
git --no-pager log --format=%B -n 1
51+
52+
# Ensure buildkite groups are rendered
53+
echo ""

.buildkite/pipeline.yml

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json
2+
env:
3+
SETUP_GOLANG_VERSION: '1.21.8'
4+
5+
steps:
6+
- label: "Update"
7+
key: update
8+
command:
9+
- ".buildkite/scripts/update-test.sh"
10+
agents:
11+
image: "golang:${SETUP_GOLANG_VERSION}"
12+
cpu: "8"
13+
memory: "4G"
14+
artifact_paths:
15+
- "junit-*.xml"
16+
17+
- label: "Lint"
18+
key: lint
19+
command:
20+
- ".buildkite/scripts/lint.sh"
21+
agents:
22+
image: "golang:${SETUP_GOLANG_VERSION}"
23+
cpu: "8"
24+
memory: "4G"
25+
26+
- label: ":junit: Junit annotate"
27+
plugins:
28+
- junit-annotate#v2.4.1:
29+
artifacts: "junit-*.xml"
30+
fail-build-on-error: true
31+
agents:
32+
provider: "gcp" #junit plugin requires docker
33+
depends_on:
34+
- step: "update"
35+
allow_failure: true

.buildkite/pull-requests.json

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
{
2+
"jobs": [
3+
{
4+
"enabled": true,
5+
"pipelineSlug": "elastic-agent-client",
6+
"allow_org_users": true,
7+
"allowed_repo_permissions": ["admin", "write"],
8+
"allowed_list": ["dependabot[bot]", "mergify[bot]"],
9+
"set_commit_status": true,
10+
"build_on_commit": true,
11+
"build_on_comment": true,
12+
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$",
13+
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$",
14+
"skip_ci_labels": [ ],
15+
"skip_target_branches": [ ],
16+
"skip_ci_on_only_changed": [ ],
17+
"always_require_ci_on_changed": [ ]
18+
}
19+
]
20+
}

.buildkite/scripts/lint.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
echo "--- Prepare enviroment"
6+
source .buildkite/scripts/pre-install-command.sh
7+
add_bin_path
8+
with_mage
9+
10+
echo "--- Run linter"
11+
mage -debug check
12+
13+
echo "--- Run Go Vet"
14+
go vet ./...
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
#!/bin/bash
2+
set -euo pipefail
3+
4+
source .buildkite/scripts/tooling.sh
5+
6+
add_bin_path(){
7+
mkdir -p "${WORKSPACE}/bin"
8+
export PATH="${WORKSPACE}/bin:${PATH}"
9+
}
10+
11+
with_mage() {
12+
mkdir -p "${WORKSPACE}/bin"
13+
retry 5 curl -sL -o "${WORKSPACE}/bin/mage.tar.gz" "https://github.com/magefile/mage/releases/download/v${SETUP_MAGE_VERSION}/mage_${SETUP_MAGE_VERSION}_Linux-64bit.tar.gz"
14+
15+
tar -xvf "${WORKSPACE}/bin/mage.tar.gz" -C "${WORKSPACE}/bin"
16+
chmod +x "${WORKSPACE}/bin/mage"
17+
mage --version
18+
}
19+
20+
with_go_junit_report() {
21+
go install github.com/jstemmer/go-junit-report/v2@latest
22+
}
23+
24+
# Required env variables:
25+
# WORKSPACE
26+
# SETUP_MAGE_VERSION
27+
WORKSPACE=${WORKSPACE:-"$(pwd)"}
28+
SETUP_MAGE_VERSION=${SETUP_MAGE_VERSION:-"1.14.0"}

.buildkite/scripts/tooling.sh

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#!/bin/bash
2+
3+
retry() {
4+
local retries=$1
5+
shift
6+
7+
local count=0
8+
until "$@"; do
9+
exit=$?
10+
wait=$((2 ** count))
11+
count=$((count + 1))
12+
if [ $count -lt "$retries" ]; then
13+
>&2 echo "Retry $count/$retries exited $exit, retrying in $wait seconds..."
14+
sleep $wait
15+
else
16+
>&2 echo "Retry $count/$retries exited $exit, no more retries left."
17+
return $exit
18+
fi
19+
done
20+
return 0
21+
}

.buildkite/scripts/update-test.sh

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
echo "--- Prepare enviroment"
6+
source .buildkite/scripts/pre-install-command.sh
7+
apt-get update
8+
apt-get install unzip
9+
curl -sSfL -o protoc.zip https://github.com/protocolbuffers/protobuf/releases/download/v3.19.4/protoc-3.19.4-linux-x86_64.zip
10+
unzip -o protoc.zip -d /usr/local
11+
which protoc
12+
add_bin_path
13+
with_mage
14+
with_go_junit_report
15+
16+
echo "--- Update proto"
17+
mage -debug update
18+
19+
echo "--- Run tests"
20+
set +e
21+
go test -race ./...| tee tests-report.txt
22+
exit_code=$?
23+
set -e
24+
25+
# Create Junit report for junit annotation plugin
26+
go-junit-report > junit-report.xml < tests-report.txt
27+
exit $exit_code

catalog-info.yaml

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
# Declare a Backstage Component that represents your application.
2+
---
3+
# yaml-language-server: $schema=https://json.schemastore.org/catalog-info.json
4+
apiVersion: backstage.io/v1alpha1
5+
kind: Component
6+
metadata:
7+
name: elastic-agent-client
8+
9+
spec:
10+
type: library
11+
owner: group:ingest-fp
12+
system: platform-ingest
13+
lifecycle: production
14+
15+
---
16+
# yaml-language-server: $schema=https://gist.githubusercontent.com/elasticmachine/988b80dae436cafea07d9a4a460a011d/raw/e57ee3bed7a6f73077a3f55a38e76e40ec87a7cf/rre.schema.json
17+
apiVersion: backstage.io/v1alpha1
18+
kind: Resource
19+
metadata:
20+
name: buildkite-pipeline-elastic-agent-client
21+
description: 'Pipeline for the Elastic Agent Client project'
22+
links:
23+
- title: Pipeline
24+
url: https://buildkite.com/elastic/elastic-agent-client
25+
26+
spec:
27+
type: buildkite-pipeline
28+
owner: group:ingest-fp
29+
system: platform-ingest
30+
implementation:
31+
apiVersion: buildkite.elastic.dev/v1
32+
kind: Pipeline
33+
metadata:
34+
name: elastic-agent-client
35+
description: 'Pipeline for the Elastic Agent Client project'
36+
spec:
37+
branch_configuration: "main"
38+
pipeline_file: ".buildkite/pipeline.yml"
39+
provider_settings:
40+
build_pull_request_forks: false
41+
build_pull_requests: true # requires filter_enabled and filter_condition settings as below when used with buildkite-pr-bot
42+
build_tags: true
43+
filter_enabled: true
44+
filter_condition: >-
45+
build.pull_request.id == null || (build.creator.name == 'elasticmachine' && build.pull_request.id != null)
46+
repository: elastic/elastic-agent-client
47+
cancel_intermediate_builds: true
48+
cancel_intermediate_builds_branch_filter: '!main'
49+
skip_intermediate_builds: true
50+
skip_intermediate_builds_branch_filter: '!main'
51+
env:
52+
ELASTIC_PR_COMMENTS_ENABLED: 'true'
53+
teams:
54+
ingest-fp:
55+
access_level: MANAGE_BUILD_AND_READ
56+
everyone:
57+
access_level: READ_ONLY

0 commit comments

Comments
 (0)