Skip to content

Commit

Permalink
Merge branch 'main' into chart_expressions-xy-show-tooltip
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored May 30, 2022
2 parents 273d280 + afb1889 commit 27029b8
Show file tree
Hide file tree
Showing 118 changed files with 1,893 additions and 1,066 deletions.
36 changes: 18 additions & 18 deletions .buildkite/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion .buildkite/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@
"version": "1.0.0",
"private": true,
"dependencies": {
"kibana-buildkite-library": "git+https://git@github.com/elastic/kibana-buildkite-library#ae4994aba5f2e72edcc5914e2aa208086e4b7ea3"
"kibana-buildkite-library": "git+https://git@github.com/elastic/kibana-buildkite-library#4ecaba35293fb635cf92ca205ee84fca52f19e2e"
}
}
2 changes: 2 additions & 0 deletions .buildkite/pipelines/artifacts.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ steps:

- command: KIBANA_DOCKER_CONTEXT=cloud .buildkite/scripts/steps/artifacts/docker_context.sh
label: 'Docker Context Verification'
soft_fail: true
agents:
queue: n2-2
timeout_in_minutes: 30
Expand All @@ -74,6 +75,7 @@ steps:

- command: .buildkite/scripts/steps/artifacts/cloud.sh
label: 'Cloud Deployment'
soft_fail: true
agents:
queue: n2-2
timeout_in_minutes: 30
Expand Down
30 changes: 30 additions & 0 deletions .buildkite/pipelines/code_coverage/daily.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
steps:
- command: .buildkite/scripts/lifecycle/pre_build.sh
label: Pre-Build
timeout_in_minutes: 10
agents:
queue: kibana-default

- wait

- command: .buildkite/scripts/steps/test/pick_test_group_run_order.sh
label: 'Pick Test Group Run Order'
agents:
queue: kibana-default
env:
FTR_CONFIGS_DEPS: ''
LIMIT_CONFIG_TYPE: 'unit,functional,integration'
JEST_UNIT_SCRIPT: '.buildkite/scripts/steps/code_coverage/jest.sh'
JEST_INTEGRATION_SCRIPT: '.buildkite/scripts/steps/code_coverage/jest_integration.sh'
FTR_CONFIGS_SCRIPT: '.buildkite/scripts/steps/code_coverage/ftr_configs.sh'

- command: .buildkite/scripts/steps/code_coverage/ingest.sh
label: 'Merge and Ingest'
agents:
queue: c2-16
depends_on:
- jest
- jest-integration
- ftr-configs
timeout_in_minutes: 30
key: ingest
4 changes: 4 additions & 0 deletions .buildkite/pipelines/es_snapshots/promote.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,7 @@ steps:
command: .buildkite/scripts/steps/es_snapshots/promote.sh
agents:
queue: kibana-default
- wait
- trigger: kibana-agent-packer-cache
async: true
branches: main
1 change: 1 addition & 0 deletions .buildkite/scripts/common/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export KIBANA_DIR
export XPACK_DIR="$KIBANA_DIR/x-pack"

export CACHE_DIR="$HOME/.kibana"
export ES_CACHE_DIR="$HOME/.es-snapshot-cache"
PARENT_DIR="$(cd "$KIBANA_DIR/.."; pwd)"
export PARENT_DIR
export WORKSPACE="${WORKSPACE:-$PARENT_DIR}"
Expand Down
6 changes: 6 additions & 0 deletions .buildkite/scripts/packer_cache.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,10 @@ source .buildkite/scripts/common/util.sh
source .buildkite/scripts/common/env.sh
source .buildkite/scripts/common/setup_node.sh

export FORCE_BOOTSTRAP_REMOTE_CACHE=true

yarn kbn bootstrap

for version in $(cat versions.json | jq -r '.versions[].version'); do
node scripts/es snapshot --download-only --base-path "$ES_CACHE_DIR" --version "$version"
done
20 changes: 14 additions & 6 deletions .buildkite/scripts/steps/artifacts/cloud.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,22 @@ set -euo pipefail

source .buildkite/scripts/steps/artifacts/env.sh

echo "--- Publish Cloud image"
echo "--- Build and publish Cloud image"
mkdir -p target
cd target

buildkite-agent artifact download "kibana-cloud-$FULL_VERSION-docker-image.tar.gz" . --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"
docker load --input kibana-cloud-$FULL_VERSION-docker-image.tar.gz
buildkite-agent artifact download "kibana-$FULL_VERSION-linux-x86_64.tar.gz" ./target --build "${KIBANA_BUILD_ID:-$BUILDKITE_BUILD_ID}"

node scripts/build \
--skip-initialize \
--skip-generic-folders \
--skip-platform-folders \
--skip-archives \
--docker-images \
--skip-docker-ubi \
--skip-docker-ubuntu \
--skip-docker-contexts

docker load --input target/kibana-cloud-$FULL_VERSION-docker-image.tar.gz

TAG="$FULL_VERSION-$GIT_COMMIT"
KIBANA_BASE_IMAGE="docker.elastic.co/kibana-ci/kibana-cloud:$FULL_VERSION"
Expand All @@ -25,8 +35,6 @@ trap 'docker logout docker.elastic.co' EXIT
docker push "$KIBANA_TEST_IMAGE"
docker logout docker.elastic.co

cd -

echo "--- Create deployment"
CLOUD_DEPLOYMENT_NAME="kibana-artifacts-$TAG"

Expand Down
2 changes: 1 addition & 1 deletion .buildkite/scripts/steps/artifacts/env.sh
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ if [[ "$RELEASE_BUILD" == "true" ]]; then
WORKFLOW="staging"
else
FULL_VERSION="$QUALIFIER_VERSION-SNAPSHOT"
BUILD_ARGS="--version-qualifier=$VERSION_QUALIFIER"
BUILD_ARGS="--skip-docker-cloud --version-qualifier=$VERSION_QUALIFIER"
WORKFLOW="snapshot"
fi

Expand Down
1 change: 1 addition & 0 deletions .buildkite/scripts/steps/checks.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export DISABLE_BOOTSTRAP_VALIDATION=false
.buildkite/scripts/bootstrap.sh

.buildkite/scripts/steps/checks/precommit_hook.sh
.buildkite/scripts/steps/checks/ftr_configs.sh
.buildkite/scripts/steps/checks/bazel_packages.sh
.buildkite/scripts/steps/checks/telemetry.sh
.buildkite/scripts/steps/checks/ts_projects.sh
Expand Down
9 changes: 9 additions & 0 deletions .buildkite/scripts/steps/checks/ftr_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh

echo --- Check FTR Configs
checks-reporter-with-killswitch "Check FTR Configs" \
node scripts/check_ftr_configs
14 changes: 14 additions & 0 deletions .buildkite/scripts/steps/code_coverage/clean_coverage_paths.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0 and the Server Side Public License, v 1; you may not use this file except
* in compliance with, at your election, the Elastic License 2.0 or the Server
* Side Public License, v 1.
*/

const { readFileSync, writeFileSync } = require('fs');

const file = process.argv[2];
const search = process.argv[3];
const replace = process.argv[4];
writeFileSync(file, readFileSync(file).toString().replaceAll(search, replace));
122 changes: 122 additions & 0 deletions .buildkite/scripts/steps/code_coverage/ftr_configs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,122 @@
#!/usr/bin/env bash

set -euo pipefail

source .buildkite/scripts/common/util.sh
source .buildkite/scripts/steps/code_coverage/merge.sh
source .buildkite/scripts/steps/code_coverage/util.sh
source .buildkite/scripts/steps/code_coverage/node_scripts.sh

export CODE_COVERAGE=1 # Kibana is bootstrapped differently for code coverage
echo "--- KIBANA_DIR: $KIBANA_DIR"
.buildkite/scripts/bootstrap.sh
buildPlatformPlugins
is_test_execution_step

export JOB_NUM=$BUILDKITE_PARALLEL_JOB
export JOB=ftr-configs-${JOB_NUM}

functionalTarget="$KIBANA_DIR/target/kibana-coverage/functional"
FAILED_CONFIGS_KEY="${BUILDKITE_STEP_ID}${BUILDKITE_PARALLEL_JOB:-0}"

# a FTR failure will result in the script returning an exit code of 10
exitCode=0
configs="${FTR_CONFIG:-}"

if [[ "$configs" == "" ]]; then
echo "--- Downloading ftr test run order"
buildkite-agent artifact download ftr_run_order.json .
configs=$(jq -r '.groups[env.JOB_NUM | tonumber].names | .[]' ftr_run_order.json)
fi

echo "--- Config(s) for this FTR Group:"
echo "${configs[@]}"

failedConfigs=""
results=()

while read -r config; do
if [[ ! "$config" ]]; then
continue
fi
echo "--- Begin config $config"

start=$(date +%s)

# prevent non-zero exit code from breaking the loop
set +e
runFTRInstrumented "$config"
lastCode=$?
set -e
dasherize() {
local withoutExtension=${1%.*}
dasherized=$(echo "$withoutExtension" | tr '\/' '\-')
}
dasherize "$config"

if [[ -d "$functionalTarget" ]]; then
echo "--- Server and / or Client side code coverage collected"
if [[ -f "target/kibana-coverage/functional/coverage-final.json" ]]; then
# We potentially have more than one file with the same name being created,
# so we make them unique here.
mv target/kibana-coverage/functional/coverage-final.json "target/kibana-coverage/functional/${dasherized}-server-coverage.json"
fi
fi

timeSec=$(($(date +%s) - start))
if [[ $timeSec -gt 60 ]]; then
min=$((timeSec / 60))
sec=$((timeSec - (min * 60)))
duration="${min}m ${sec}s"
else
duration="${timeSec}s"
fi

results+=("- $config
duration: ${duration}
result: ${lastCode}")

if [ $lastCode -ne 0 ]; then
exitCode=10
echo "FTR exited with code $lastCode"
echo "^^^ +++"

if [[ "$failedConfigs" ]]; then
failedConfigs="${failedConfigs}"$'\n'"$config"
else
failedConfigs="$config"
fi
fi

echo "--- Config complete: $config"
done <<<"$configs"

# Each browser unload event, creates a new coverage file.
# So, we merge them here.
if [[ -d "$functionalTarget" ]]; then
reportMergeFunctional
uniqueifyFunctional "$(date +%s)"
else
echo "--- Code coverage not found in: $functionalTarget"
fi

# Nyc uses matching absolute paths for reporting / merging
# So, set all coverage json files to a specific prefx.
# The prefix will be changed to the kibana dir, in the final stage,
# so nyc doesnt error.
echo "--- Normalize file paths prefix"
replacePaths "$KIBANA_DIR/target/kibana-coverage/functional" "$KIBANA_DIR" "CC_REPLACEMENT_ANCHOR"

if [[ "$failedConfigs" ]]; then
buildkite-agent meta-data set "$FAILED_CONFIGS_KEY" "$failedConfigs"
fi

echo "--- FTR configs complete, result(s):"
printf "%s\n" "${results[@]}"
echo ""

# So the last step "knows" this config ran
uploadRanFile "ftr_configs"

# Force exit 0 to ensure the next build step starts.
exit 0
Loading

0 comments on commit 27029b8

Please sign in to comment.