kibana/.buildkite/scripts/steps/code_coverage/util.sh
Tre 5f950e617a
[QA][Code Coverage] follow up pr for ftr auto config handling & fix merge (#131734)
* [QA][Code Coverage] fixup for auto config handling pr

## Summary

Embed buildkite pipeline definition.

Follow up pr to change cc per auto config handling.
Also, resolves https://github.com/elastic/kibana/issues/132706

Increase worker count for `node scripts/build_kibana_platform_plugins` to 4 workers.

Normalize file names within coverage files such that nyc correctly builds the combined summaries.
  _Ci runs this on myriad servers, so the paths are different, which "breaks" nyc's output_

Split the final merge of functional coverage into 2 passes due to [nyc issue](https://github.com/istanbuljs/nyc/issues/1263)

Co-authored-by: kibanamachine <42973632+kibanamachine@users.noreply.github.com>
2022-05-27 12:28:16 +01:00

82 lines
1.6 KiB
Bash
Executable file

#!/usr/bin/env bash
set -euo pipefail
# $1 file name, ex: "target/dir-listing-jest.txt"
# $2 directory to be listed, ex: target/kibana-coverage/jest
dirListing() {
local fileName=$1
local dir=$2
ls -l "$dir" >"$fileName"
printf "\n### %s \n\tlisted to: %s\n" "$dir" "$fileName"
buildkite-agent artifact upload "$fileName"
printf "\n### %s Uploaded\n" "$fileName"
}
replacePaths() {
local dirName=$1
local search=$2
local replace=$3
for x in $(find "$dirName" -maxdepth 1 -type f -name '*.json'); do
node .buildkite/scripts/steps/code_coverage/clean_coverage_paths.js \
"$x" \
"$search" \
"$replace"
done
}
header() {
local fileName=$1
echo "" >"$fileName"
echo "### File Name:" >>"$fileName"
printf "\t%s\n" "$fileName" >>"$fileName"
}
fileHeads() {
local fileName=$1
local dir=$2
local ext=${3:-'*.json'}
header "$fileName"
while read -r x; do
printf "\n### BEGIN %s\n\n" "$x" >>"$fileName"
head -2 "$x" >>"$fileName"
printf "\n### END %s\n\n" "$x" >>"$fileName"
done <<<"$(find "$dir" -maxdepth 1 -type f -name "$ext")"
buildkite-agent artifact upload "$fileName"
printf "\n### %s Uploaded\n" "$fileName"
}
collectAndUpload() {
local fileName=$1
local dir=$2
tar -czf "$fileName" "$dir"
buildkite-agent artifact upload "$fileName"
printf "\n### %s Uploaded\n" "$fileName"
}
# Jest, Jest Integration, and FTR Configs will use this to "tell"
# the last stage they ran.
uploadRanFile() {
local ran=$1
mkdir -p target/ran_files
local fileName="target/ran_files/$ran.txt"
echo "$ran" >"$fileName"
buildkite-agent artifact upload "$fileName"
}