-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/default-tls12
- Loading branch information
Showing
79 changed files
with
6,594 additions
and
19,923 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 --no-pager log --format=%B -n 1 | ||
|
||
# Ensure buildkite groups are rendered | ||
echo "" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
echo "Golang version:" | ||
version=$(cat .go-version) | ||
export GO_VERSION="${version}" | ||
echo "${GO_VERSION}" | ||
|
||
# addtional preparation for macos step | ||
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-agent-libs" && "$BUILDKITE_STEP_KEY" == "test-mac" ]]; then | ||
echo "--- prepare env" | ||
source .buildkite/scripts/pre-install-command.sh | ||
with_go ${GO_VERSION} ${SETUP_GVM_VERSION} | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
$env:GO_VERSION = Get-Content -Path .go-version | ||
|
||
# Install gvm and go | ||
# TODO: Move GVM download to the base VM image | ||
$env:GvmVersion = "0.5.2" | ||
[Net.ServicePointManager]::SecurityProtocol = "tls12" | ||
$env:GoVersion = Get-Content -Path .go-version | ||
Invoke-WebRequest -URI https://github.com/andrewkroh/gvm/releases/download/v$env:GvmVersion/gvm-windows-amd64.exe -Outfile C:\Windows\System32\gvm.exe | ||
gvm --format=powershell $env:GO_VERSION | Invoke-Expression | ||
go version | ||
|
||
$GOPATH = $(go env GOPATH) | ||
$env:Path = "$GOPATH\bin;" + $env:Path | ||
[Environment]::SetEnvironmentVariable("GOPATH", "$GOPATH", [EnvironmentVariableTarget]::Machine) | ||
[Environment]::SetEnvironmentVariable("Path", "$GOPATH\bin;$env:Path", [EnvironmentVariableTarget]::Machine) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# yaml-language-server: $schema=https://raw.githubusercontent.com/buildkite/pipeline-schema/main/schema.json | ||
env: | ||
SETUP_MAGE_VERSION: '1.14.0' | ||
SETUP_GVM_VERSION: 'v0.5.0' | ||
|
||
steps: | ||
- label: ":buildkite: Lint" | ||
command: | ||
- ".buildkite/scripts/lint.sh" | ||
agents: | ||
image: golang:${GO_VERSION} | ||
cpu: "8" | ||
memory: "4G" | ||
|
||
- label: ":linux: Test Linux" | ||
key: test-lin | ||
command: | ||
- ".buildkite/scripts/test.sh" | ||
agents: | ||
image: golang:${GO_VERSION} | ||
cpu: "8" | ||
memory: "4G" | ||
artifact_paths: | ||
- "junit-*.xml" | ||
|
||
- label: ":windows: Test Windows" | ||
key: test-win | ||
command: | ||
- ".buildkite/scripts/test.ps1" | ||
agents: | ||
provider: "gcp" | ||
image: "family/ci-windows-2019" | ||
artifact_paths: | ||
- "junit-*.xml" | ||
|
||
- label: ":mac: Test MacOS" | ||
key: test-mac | ||
command: | ||
- ".buildkite/scripts/test.sh junit-report-macos.xml" | ||
agents: | ||
provider: "orka" | ||
imagePrefix: generic-13-ventura-x64 | ||
artifact_paths: | ||
- "junit-*.xml" | ||
|
||
- label: ":junit: Junit annotate" | ||
plugins: | ||
- junit-annotate#v2.4.1: | ||
artifacts: "junit-*.xml" | ||
fail-build-on-error: true | ||
agents: | ||
provider: "gcp" #junit plugin requires docker | ||
depends_on: | ||
- step: "test-lin" | ||
allow_failure: true | ||
- step: "test-win" | ||
allow_failure: true | ||
- step: "test-mac" | ||
allow_failure: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
{ | ||
"jobs": [ | ||
{ | ||
"enabled": true, | ||
"pipelineSlug": "elastic-agent-libs", | ||
"allow_org_users": true, | ||
"allowed_repo_permissions": ["admin", "write"], | ||
"allowed_list": ["github-actions[bot]"], | ||
"set_commit_status": true, | ||
"build_on_commit": true, | ||
"build_on_comment": true, | ||
"trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$", | ||
"always_trigger_comment_regex": "^(?:(?:buildkite\\W+)?(?:build|test)\\W+(?:this|it))|^/test$", | ||
"skip_ci_labels": [ ], | ||
"skip_target_branches": [ ], | ||
"skip_ci_on_only_changed": [ ], | ||
"always_require_ci_on_changed": [ ] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
#!/bin/bash | ||
|
||
set -euo pipefail | ||
|
||
echo "--- Pre install" | ||
source .buildkite/scripts/pre-install-command.sh | ||
add_bin_path | ||
with_mage | ||
|
||
echo "--- Mage notice" | ||
mage notice | ||
|
||
echo "--- Mage check" | ||
mage -v check |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
|
||
source .buildkite/scripts/tooling.sh | ||
|
||
add_bin_path(){ | ||
mkdir -p "${WORKSPACE}/bin" | ||
export PATH="${WORKSPACE}/bin:${PATH}" | ||
} | ||
|
||
with_mage() { | ||
mkdir -p "${WORKSPACE}/bin" | ||
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" | ||
|
||
tar -xvf "${WORKSPACE}/bin/mage.tar.gz" -C "${WORKSPACE}/bin" | ||
chmod +x "${WORKSPACE}/bin/mage" | ||
mage --version | ||
} | ||
|
||
with_go_junit_report() { | ||
go install github.com/jstemmer/go-junit-report/v2@latest | ||
} | ||
|
||
with_go() { | ||
local go_version=$1 | ||
local gvm_version=$2 | ||
url=$(get_gvm_link "${gvm_version}") | ||
WORKSPACE=${WORKSPACE:-"$(pwd)"} | ||
mkdir -p "${WORKSPACE}/bin" | ||
export PATH="${PATH}:${WORKSPACE}/bin" | ||
retry 5 curl -L -o "${WORKSPACE}/bin/gvm" "${url}" | ||
chmod +x "${WORKSPACE}/bin/gvm" | ||
ls ${WORKSPACE}/bin/ | ||
eval "$(gvm $go_version)" | ||
go_path="$(go env GOPATH):$(go env GOPATH)/bin" | ||
export PATH="${PATH}:${go_path}" | ||
go version | ||
} | ||
|
||
# for gvm link | ||
get_gvm_link() { | ||
local gvm_version=$1 | ||
platform_type="$(uname)" | ||
arch_type="$(uname -m)" | ||
[[ ${arch_type} == "aarch64" ]] && arch_type="arm64" # gvm do not have 'aarch64' name for archetecture type | ||
[[ ${arch_type} == "x86_64" ]] && arch_type="amd64" | ||
echo "https://github.com/andrewkroh/gvm/releases/download/${gvm_version}/gvm-${platform_type}-${arch_type}" | ||
} | ||
|
||
# Required env variables: | ||
# WORKSPACE | ||
# SETUP_MAGE_VERSION | ||
WORKSPACE=${WORKSPACE:-"$(pwd)"} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
$ErrorActionPreference = "Stop" # set -e | ||
# Forcing to checkout again all the files with a correct autocrlf. | ||
# Doing this here because we cannot set git clone options before. | ||
function fixCRLF { | ||
Write-Host "-- Fixing CRLF in git checkout --" | ||
git config core.autocrlf input | ||
git rm --quiet --cached -r . | ||
git reset --quiet --hard | ||
} | ||
|
||
function withGoJUnitReport { | ||
Write-Host "-- Install go-junit-report --" | ||
go install github.com/jstemmer/go-junit-report/v2@latest | ||
} | ||
|
||
Write-Host "--- Prepare enviroment" | ||
fixCRLF | ||
withGoJUnitReport | ||
|
||
Write-Host "--- Run test" | ||
$ErrorActionPreference = "Continue" # set +e | ||
mkdir -p build | ||
$OUT_FILE="output-report.out" | ||
go test "./..." -v > $OUT_FILE | ||
$EXITCODE=$LASTEXITCODE | ||
$ErrorActionPreference = "Stop" | ||
|
||
# Buildkite collapse logs under --- symbols | ||
# need to change --- to anything else or switch off collapsing (note: not available at the moment of this commit) | ||
$contest = Get-Content $OUT_FILE | ||
foreach ($line in $contest) { | ||
$changed = $line -replace '---', '----' | ||
Write-Host $changed | ||
} | ||
|
||
Get-Content $OUT_FILE | go-junit-report > "uni-junit-win.xml" | ||
Get-Content "uni-junit-win.xml" -Encoding Unicode | Set-Content -Encoding UTF8 "junit-win.xml" | ||
Remove-Item "uni-junit-win.xml", "$OUT_FILE" | ||
|
||
Exit $EXITCODE |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
#!/bin/bash | ||
junitfile=$1 # filename for jnit annotation plugin | ||
|
||
set -euo pipefail | ||
|
||
echo "--- Pre install" | ||
source .buildkite/scripts/pre-install-command.sh | ||
go version | ||
add_bin_path | ||
with_go_junit_report | ||
|
||
echo "--- Go Test" | ||
set +e | ||
go test -v ./... > tests-report.txt | ||
exit_code=$? | ||
set -e | ||
|
||
# Buildkite collapse logs under --- symbols | ||
# need to change --- to anything else or switch off collapsing (note: not available at the moment of this commit) | ||
awk '{gsub("---", "----"); print }' tests-report.txt | ||
|
||
# Create Junit report for junit annotation plugin | ||
go-junit-report > "${junitfile:-junit-report-linux.xml}" < tests-report.txt | ||
exit $exit_code |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
#!/bin/bash | ||
|
||
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 | ||
} |
Oops, something went wrong.