From e66450ea4c75365463698a16f23849bae7c9a0c0 Mon Sep 17 00:00:00 2001 From: Alex Szabo Date: Tue, 17 Sep 2024 12:41:33 +0200 Subject: [PATCH] [CI] Run PR against chrome-beta (#192257) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ## Summary This PR's goal is to enable developers (or automation) to test against chrome-beta with a PR label - to adjust sensitive tests, or to foresee test breakages. ⚠️ Risk: a PR verified/built with the chrome beta setting, would pass the PR tests, but might not pass the on-merge suite in the end. Addresses: https://github.com/elastic/kibana-operations/issues/199 Depends on: https://github.com/elastic/ci-agent-images/pull/907 It highlights the errors visible only on the next versions: https://buildkite.com/elastic/kibana-pull-request/builds/233373 And it doesn't break with non-beta run: https://buildkite.com/elastic/kibana-pull-request/builds/233716 --- .../ci-stats/pick_test_group_run_order.ts | 32 +++++++++++++++++-- .buildkite/scripts/steps/test/ftr_configs.sh | 13 ++++++++ 2 files changed, 43 insertions(+), 2 deletions(-) diff --git a/.buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts b/.buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts index 1f50bccbf804..7379ab526321 100644 --- a/.buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts +++ b/.buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts @@ -197,6 +197,32 @@ function getEnabledFtrConfigs(patterns?: string[]) { } } +/** + * Collects environment variables from labels on the PR + * TODO: extract this (and other functions from this big file) to a separate module + */ +function collectEnvFromLabels() { + const LABEL_MAPPING: Record> = { + 'ci:use-chrome-beta': { + USE_CHROME_BETA: 'true', + }, + }; + + const envFromlabels: Record = {}; + if (!process.env.GITHUB_PR_LABELS) { + return envFromlabels; + } else { + const labels = process.env.GITHUB_PR_LABELS.split(','); + labels.forEach((label) => { + const env = LABEL_MAPPING[label]; + if (env) { + Object.assign(envFromlabels, env); + } + }); + return envFromlabels; + } +} + export async function pickTestGroupRunOrder() { const bk = new BuildkiteClient(); const ciStats = new CiStatsClient(); @@ -273,9 +299,10 @@ export async function pickTestGroupRunOrder() { .filter(Boolean) : ['build']; - const FTR_EXTRA_ARGS: Record = process.env.FTR_EXTRA_ARGS + const ftrExtraArgs: Record = process.env.FTR_EXTRA_ARGS ? { FTR_EXTRA_ARGS: process.env.FTR_EXTRA_ARGS } : {}; + const envFromlabels: Record = collectEnvFromLabels(); const { defaultQueue, ftrConfigsByQueue } = getEnabledFtrConfigs(FTR_CONFIG_PATTERNS); @@ -514,7 +541,8 @@ export async function pickTestGroupRunOrder() { agents: expandAgentQueue(queue), env: { FTR_CONFIG_GROUP_KEY: key, - ...FTR_EXTRA_ARGS, + ...ftrExtraArgs, + ...envFromlabels, }, retry: { automatic: [ diff --git a/.buildkite/scripts/steps/test/ftr_configs.sh b/.buildkite/scripts/steps/test/ftr_configs.sh index e9500a224470..67fbfd9c95b2 100755 --- a/.buildkite/scripts/steps/test/ftr_configs.sh +++ b/.buildkite/scripts/steps/test/ftr_configs.sh @@ -57,6 +57,19 @@ while read -r config; do start=$(date +%s) + if [[ "${USE_CHROME_BETA:-}" =~ ^(1|true)$ ]]; then + echo "USE_CHROME_BETA was set - using google-chrome-beta" + export TEST_BROWSER_BINARY_PATH="$(which google-chrome-beta)" + + # download the beta version of chromedriver + export CHROMEDRIVER_VERSION=$(curl https://googlechromelabs.github.io/chrome-for-testing/last-known-good-versions.json -s | jq -r '.channels.Beta.version') + export DETECT_CHROMEDRIVER_VERSION=false + node node_modules/chromedriver/install.js --chromedriver-force-download + + # set annotation on the build + buildkite-agent annotate --style info --context chrome-beta "This build uses Google Chrome Beta @ ${CHROMEDRIVER_VERSION}" + fi + # prevent non-zero exit code from breaking the loop set +e; node ./scripts/functional_tests \