[APM] Run cypress record on merge (#161068)

## Summary

closes https://github.com/elastic/kibana/issues/154551 

Run cypress record on merge when `Team:APM` label in applied

I need to run `add_gh_labels_to_bk_metadata` script because labels are
not available on merge pipeline.


Tested here:
https://buildkite.com/elastic/kibana-pull-request/builds/141233#01893fd7-e2f9-432b-86a3-f80515f343c4
This commit is contained in:
Katerina Patticha 2023-07-10 21:32:04 +02:00 committed by GitHub
parent 3a05b7bcd7
commit bfaf5e063f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -11,9 +11,16 @@ APM_CYPRESS_RECORD_KEY="$(retry 5 5 vault read -field=CYPRESS_RECORD_KEY secret/
export JOB=kibana-apm-cypress
IS_FLAKY_TEST_RUNNER=${CLI_COUNT:-0}
GH_APM_TEAM_LABEL="Team:APM"
#Enabling cypress dashboard recording when PR is labeled with `apm:cypress-record` and we are not using the flaky test runner
if [[ "$IS_FLAKY_TEST_RUNNER" -ne 1 ]] && is_pr_with_label "apm:cypress-record"; then
if (! is_pr); then
echo "--- Add GH labels to buildkite metadata"
ts-node .buildkite/scripts/steps/add_gh_labels_to_bk_metadata.ts BUILDKITE_MESSAGE true
GH_ON_MERGE_LABELS="$(buildkite-agent meta-data get gh_labels)"
fi
# Enabling cypress dashboard recording when PR is labeled with `apm:cypress-record` and we are not using the flaky test runner OR on merge with Team:APM label applied
if ([[ "$IS_FLAKY_TEST_RUNNER" -ne 1 ]] && is_pr_with_label "apm:cypress-record") || ([[ $GH_ON_MERGE_LABELS == *"$GH_APM_TEAM_LABEL"* ]]); then
CYPRESS_ARGS="--record --key "$APM_CYPRESS_RECORD_KEY" --parallel --ci-build-id "${BUILDKITE_BUILD_ID}""
else
CYPRESS_ARGS=""