Skip to content

Commit c61f7db

Browse files
committed
Merge remote-tracking branch 'origin/main' into stack-cloud-provider
2 parents ed9e89d + 103eb96 commit c61f7db

File tree

422 files changed

+58398
-2601
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

422 files changed

+58398
-2601
lines changed

.buildkite/hooks/post-checkout

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ MERGE_BRANCH="pr_merge_${PR_ID}"
4747
checkout_merge "${TARGET_BRANCH}" "${PR_COMMIT}" "${MERGE_BRANCH}"
4848

4949
echo "Commit information"
50-
git log --format=%B -n 1
50+
git --no-pager log --format=%B -n 1
5151

5252
# Ensure buildkite groups are rendered
5353
echo ""

.buildkite/hooks/pre-command

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ PRIVATE_CI_GCS_CREDENTIALS_PATH=kv/ci-shared/platform-ingest/private_ci_artifact
3333
# Secrets must be redacted
3434
# https://buildkite.com/docs/pipelines/managing-log-output#redacted-environment-variables
3535

36-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && "$BUILDKITE_STEP_KEY" =~ ^integration-parallel ]]; then
36+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && ("$BUILDKITE_STEP_KEY" =~ ^integration-parallel || "$BUILDKITE_STEP_KEY" =~ ^integration-false_positives) ]]; then
3737
export PRIVATE_CI_GCS_CREDENTIALS_SECRET=$(retry 5 vault kv get -field plaintext ${PRIVATE_CI_GCS_CREDENTIALS_PATH})
3838
fi
3939

@@ -46,7 +46,7 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && "$BUILDKITE_STEP_KEY" =
4646
export GCP_PROJECT_ID=${ELASTIC_PACKAGE_GCP_PROJECT_SECRET}
4747
fi
4848

49-
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && "$BUILDKITE_STEP_KEY" == "integration-parallel-aws" ]]; then
49+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package" && ("$BUILDKITE_STEP_KEY" == "integration-parallel-aws" || "$BUILDKITE_STEP_KEY" == "integration-parallel-aws_logs") ]]; then
5050
export ELASTIC_PACKAGE_AWS_SECRET_KEY=$(retry 5 vault kv get -field secret_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH})
5151
export ELASTIC_PACKAGE_AWS_ACCESS_KEY=$(retry 5 vault kv get -field access_key ${AWS_SERVICE_ACCOUNT_SECRET_PATH})
5252

@@ -70,3 +70,9 @@ if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package-package-storage-publish" &&
7070
# publishing job
7171
export PACKAGE_UPLOADER_GCS_CREDENTIALS_SECRET=$(retry 5 vault kv get -field value ${PACKAGE_UPLOADER_GCS_CREDENTIALS_PATH})
7272
fi
73+
74+
if [[ "$BUILDKITE_PIPELINE_SLUG" == "elastic-package-test-with-integrations" && "$BUILDKITE_STEP_KEY" == "pr-integrations" ]]; then
75+
export GITHUB_USERNAME_SECRET=$(retry 5 vault kv get -field username ${GITHUB_TOKEN_VAULT_PATH})
76+
export GITHUB_EMAIL_SECRET=$(retry 5 vault kv get -field email ${GITHUB_TOKEN_VAULT_PATH})
77+
export GITHUB_TOKEN=$(retry 5 vault kv get -field token ${GITHUB_TOKEN_VAULT_PATH})
78+
fi

.buildkite/pipeline.test-with-integrations-repo.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
env:
2+
SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
23
GOLANG_VERSION: "1.20.3"
4+
GH_CLI_VERSION: "2.29.0"
5+
JQ_VERSION: "1.6"
36

47
steps:
58
- label: ":go: Run check-static"
@@ -9,4 +12,22 @@ steps:
912
image: "golang:${GOLANG_VERSION}"
1013
cpu: "8"
1114
memory: "4G"
15+
- label: ":go: :linux: Run unit tests"
16+
key: unit-tests-linux
17+
command: "make test-go-ci"
18+
artifact_paths:
19+
- "build/test-results/*.xml"
20+
- "build/test-coverage/*.xml"
21+
agents:
22+
image: "golang:${GOLANG_VERSION}"
23+
cpu: "8"
24+
memory: "4G"
25+
- label: ":hammer: Create PR in integrations"
26+
key: pr-integrations
27+
command: ".buildkite/scripts/test-with-integrations.sh"
28+
agents:
29+
provider: "gcp"
30+
depends_on:
31+
- check-static
32+
- unit-tests-linux
1233

.buildkite/pipeline.trigger.integration.tests.sh

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,29 @@ for test in ${CHECK_PACKAGES_TESTS[@]}; do
4242
echo " provider: \"gcp\""
4343
echo " artifact_paths:"
4444
echo " - build/test-results/*.xml"
45-
echo " - build/elastic-stack-dump/stack/check-*/logs/*.log"
46-
echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/**/*"
47-
echo " - build/elastic-stack-status/*/*"
45+
echo " - build/elastic-stack-dump/check-*/logs/*.log"
46+
echo " - build/elastic-stack-dump/check-*/logs/fleet-server-internal/**/*"
4847
if [[ $test =~ with-kind$ ]]; then
4948
echo " - build/kubectl-dump.txt"
5049
fi
5150
done
5251

52+
pushd test/packages/false_positives > /dev/null
53+
for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do
54+
package_name=$(basename ${package})
55+
echo " - label: \":go: Running integration test (false positive): ${package_name}\""
56+
echo " key: \"integration-false_positives-${package_name}\""
57+
echo " command: ./.buildkite/scripts/integration_tests.sh -t test-check-packages-false-positives -p ${package_name}"
58+
echo " env:"
59+
echo " UPLOAD_SAFE_LOGS: 1"
60+
echo " agents:"
61+
echo " provider: \"gcp\""
62+
echo " artifact_paths:"
63+
echo " - build/test-results/*.xml"
64+
done
65+
66+
popd > /dev/null
67+
5368
pushd test/packages/parallel > /dev/null
5469
for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do
5570
package_name=$(basename ${package})
@@ -62,8 +77,6 @@ for package in $(find . -maxdepth 1 -mindepth 1 -type d) ; do
6277
echo " provider: \"gcp\""
6378
echo " artifact_paths:"
6479
echo " - build/test-results/*.xml"
65-
echo " - build/elastic-stack-dump/stack/check-*/logs/*.log"
66-
echo " - build/elastic-stack-dump/stack/check-*/logs/fleet-server-internal/**/*"
6780
done
6881

6982
popd > /dev/null

.buildkite/pipeline.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ env:
22
SETUP_GVM_VERSION: 'v0.5.0' # https://github.com/andrewkroh/gvm/issues/44#issuecomment-1013231151
33
DOCKER_COMPOSE_VERSION: "v2.17.2"
44
ELASTIC_PACKAGE_COMPOSE_DISABLE_ANSI: "true"
5+
ELASTIC_PACKAGE_COMPOSE_DISABLE_PULL_PROGRESS_INFORMATION: "true"
56
KIND_VERSION: 'v0.17.0'
67
K8S_VERSION: 'v1.26.0'
78

.buildkite/scripts/install_deps.sh

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ with_go() {
3030
eval "$(gvm $(cat .go-version))"
3131
go version
3232
which go
33-
export PATH="$(go env GOPATH)/bin:${PATH}"
33+
export PATH="${PATH}:$(go env GOPATH)/bin"
3434
}
3535

3636
with_docker_compose() {
@@ -39,3 +39,30 @@ with_docker_compose() {
3939
chmod +x ${WORKSPACE}/bin/docker-compose
4040
docker-compose version
4141
}
42+
43+
with_github_cli() {
44+
mkdir -p ${WORKSPACE}/bin
45+
mkdir -p ${WORKSPACE}/tmp
46+
47+
local gh_filename="gh_${GH_CLI_VERSION}_linux_amd64"
48+
local gh_tar_file="${gh_filename}.tar.gz"
49+
local gh_tar_full_path="${WORKSPACE}/tmp/${gh_tar_file}"
50+
51+
retry 5 curl -sL -o ${gh_tar_full_path} "https://github.com/cli/cli/releases/download/v${GH_CLI_VERSION}/${gh_tar_file}"
52+
53+
# just extract the binary file from the tar.gz
54+
tar -C ${WORKSPACE}/bin -xpf ${gh_tar_full_path} ${gh_filename}/bin/gh --strip-components=2
55+
56+
chmod +x ${WORKSPACE}/bin/gh
57+
rm -rf ${WORKSPACE}/tmp
58+
59+
gh version
60+
}
61+
62+
with_jq() {
63+
mkdir -p ${WORKSPACE}/bin
64+
retry 5 curl -sL -o ${WORKSPACE}/bin/jq "https://github.com/stedolan/jq/releases/download/jq-${JQ_VERSION}/jq-linux64"
65+
66+
chmod +x ${WORKSPACE}/bin/jq
67+
jq --version
68+
}

.buildkite/scripts/integration_tests.sh

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,15 @@ source .buildkite/scripts/install_deps.sh
2424
source .buildkite/scripts/tooling.sh
2525

2626
PARALLEL_TARGET="test-check-packages-parallel"
27+
FALSE_POSITIVES_TARGET="test-check-packages-false-positives"
2728
KIND_TARGET="test-check-packages-with-kind"
2829
TMP_FOLDER_TEMPLATE="${TMP_FOLDER_TEMPLATE_BASE}.XXXXXXXXX"
2930
GOOGLE_CREDENTIALS_FILENAME="google-cloud-credentials.json"
3031

3132
JOB_GCS_BUCKET_INTERNAL="fleet-ci-temp-internal"
3233

33-
REPO_NAME=$(repoName "${BUILDKITE_REPO}")
34-
REPO_BUILD_TAG="${REPO_NAME}/${BUILDKITE_BUILD_NUMBER}"
35-
34+
REPO_NAME=$(repo_name "${BUILDKITE_REPO}")
35+
REPO_BUILD_TAG="${REPO_NAME}/$(buildkite_pr_branch_build_id)"
3636
TARGET=""
3737
PACKAGE=""
3838
while getopts ":t:p:h" o; do
@@ -109,7 +109,7 @@ if [[ "${TARGET}" == "${KIND_TARGET}" ]]; then
109109
fi
110110

111111
echo "--- Run integration test ${TARGET}"
112-
if [[ "${TARGET}" == "${PARALLEL_TARGET}" ]]; then
112+
if [[ "${TARGET}" == "${PARALLEL_TARGET}" ]] || [[ "${TARGET}" == "${FALSE_POSITIVES_TARGET}" ]]; then
113113
make install
114114

115115
# allow to fail this command, to be able to upload safe logs

.buildkite/scripts/signAndPublishPackage.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ cleanup() {
1616

1717
trap cleanup EXIT
1818

19-
isAlreadyPublished() {
19+
is_already_published() {
2020
local packageZip=$1
2121

2222
if curl -s --head https://package-storage.elastic.co/artifacts/packages/${packageZip} | grep -q "HTTP/2 200" ; then
@@ -34,7 +34,7 @@ if ! command -v gsutil &> /dev/null ; then
3434
fi
3535

3636

37-
REPO_NAME=$(repoName "${BUILDKITE_REPO}")
37+
REPO_NAME=$(repo_name "${BUILDKITE_REPO}")
3838
BUILD_TAG="buildkite-${BUILDKITE_PIPELINE_SLUG}-${BUILDKITE_BUILD_NUMBER}"
3939

4040
REPO_BUILD_TAG="${REPO_NAME}/${BUILD_TAG}"
@@ -76,7 +76,7 @@ google_cloud_auth_publishing() {
7676
echo "${gsUtilLocation}"
7777
}
7878

79-
signPackage() {
79+
sign_package() {
8080
local package=${1}
8181
local packageZip=$(basename ${package})
8282

@@ -110,7 +110,7 @@ signPackage() {
110110
rm -r "${gsUtilLocation}"
111111
}
112112

113-
publishPackage() {
113+
publish_package() {
114114
local package=$1
115115
local packageZip=$(basename ${package})
116116

@@ -154,14 +154,14 @@ ls -l "${BUILD_PACKAGES_PATH}"
154154
for package in $(ls ${BUILD_PACKAGES_PATH}/*.zip); do
155155
echo "isAlreadyInstalled ${package}?"
156156
packageZip=$(basename ${package})
157-
if isAlreadyPublished ${packageZip} ; then
157+
if is_already_published ${packageZip} ; then
158158
echo "Skipping. ${packageZip} already published"
159159
continue
160160
fi
161161

162162
echo "Signing package ${packageZip}"
163-
signPackage "${package}"
163+
sign_package "${package}"
164164

165165
echo "Publishing package ${packageZip}"
166-
publishPackage "${package}"
166+
publish_package "${package}"
167167
done

0 commit comments

Comments
 (0)