Skip to content

Commit

Permalink
[8.15] [CI] Run PR against chrome-beta (#192257) (#193141)
Browse files Browse the repository at this point in the history
# Backport

This will backport the following commits from `main` to `8.15`:
- [[CI] Run PR against chrome-beta
(#192257)](#192257)

<!--- Backport version: 9.4.3 -->

### Questions ?
Please refer to the [Backport tool
documentation](https://github.com/sqren/backport)

<!--BACKPORT [{"author":{"name":"Alex
Szabo","email":"[email protected]"},"sourceCommit":{"committedDate":"2024-09-17T10:41:33Z","message":"[CI]
Run PR against chrome-beta (#192257)\n\n## Summary\r\nThis PR's goal is
to enable developers (or automation) to test against\r\nchrome-beta with
a PR label - to adjust sensitive tests, or to foresee\r\ntest
breakages.\r\n\r\n⚠️ Risk: a PR verified/built with the chrome beta
setting, would pass\r\nthe PR tests, but might not pass the on-merge
suite in the end.\r\n\r\nAddresses:
https://github.com/elastic/kibana-operations/issues/199\r\nDepends on:
https://github.com/elastic/ci-agent-images/pull/907\r\n\r\nIt highlights
the errors visible only on the next
versions:\r\nhttps://buildkite.com/elastic/kibana-pull-request/builds/233373\r\nAnd
it doesn't break with non-beta
run:\r\nhttps://buildkite.com/elastic/kibana-pull-request/builds/233716","sha":"e66450ea4c75365463698a16f23849bae7c9a0c0","branchLabelMapping":{"^v9.0.0$":"main","^v8.16.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["Team:Operations","release_note:skip","v9.0.0","backport:prev-major"],"title":"[CI]
Run PR against
chrome-beta","number":192257,"url":"https://github.com/elastic/kibana/pull/192257","mergeCommit":{"message":"[CI]
Run PR against chrome-beta (#192257)\n\n## Summary\r\nThis PR's goal is
to enable developers (or automation) to test against\r\nchrome-beta with
a PR label - to adjust sensitive tests, or to foresee\r\ntest
breakages.\r\n\r\n⚠️ Risk: a PR verified/built with the chrome beta
setting, would pass\r\nthe PR tests, but might not pass the on-merge
suite in the end.\r\n\r\nAddresses:
https://github.com/elastic/kibana-operations/issues/199\r\nDepends on:
https://github.com/elastic/ci-agent-images/pull/907\r\n\r\nIt highlights
the errors visible only on the next
versions:\r\nhttps://buildkite.com/elastic/kibana-pull-request/builds/233373\r\nAnd
it doesn't break with non-beta
run:\r\nhttps://buildkite.com/elastic/kibana-pull-request/builds/233716","sha":"e66450ea4c75365463698a16f23849bae7c9a0c0"}},"sourceBranch":"main","suggestedTargetBranches":[],"targetPullRequestStates":[{"branch":"main","label":"v9.0.0","branchLabelMappingKey":"^v9.0.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/192257","number":192257,"mergeCommit":{"message":"[CI]
Run PR against chrome-beta (#192257)\n\n## Summary\r\nThis PR's goal is
to enable developers (or automation) to test against\r\nchrome-beta with
a PR label - to adjust sensitive tests, or to foresee\r\ntest
breakages.\r\n\r\n⚠️ Risk: a PR verified/built with the chrome beta
setting, would pass\r\nthe PR tests, but might not pass the on-merge
suite in the end.\r\n\r\nAddresses:
https://github.com/elastic/kibana-operations/issues/199\r\nDepends on:
https://github.com/elastic/ci-agent-images/pull/907\r\n\r\nIt highlights
the errors visible only on the next
versions:\r\nhttps://buildkite.com/elastic/kibana-pull-request/builds/233373\r\nAnd
it doesn't break with non-beta
run:\r\nhttps://buildkite.com/elastic/kibana-pull-request/builds/233716","sha":"e66450ea4c75365463698a16f23849bae7c9a0c0"}}]}]
BACKPORT-->

Co-authored-by: Alex Szabo <[email protected]>
  • Loading branch information
kibanamachine and delanni authored Sep 17, 2024
1 parent 62da3b6 commit 47f8303
Show file tree
Hide file tree
Showing 2 changed files with 43 additions and 2 deletions.
32 changes: 30 additions & 2 deletions .buildkite/pipeline-utils/ci-stats/pick_test_group_run_order.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,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<string, Record<string, string>> = {
'ci:use-chrome-beta': {
USE_CHROME_BETA: 'true',
},
};

const envFromlabels: Record<string, string> = {};
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();
Expand Down Expand Up @@ -252,9 +278,10 @@ export async function pickTestGroupRunOrder() {
.filter(Boolean)
: ['build'];

const FTR_EXTRA_ARGS: Record<string, string> = process.env.FTR_EXTRA_ARGS
const ftrExtraArgs: Record<string, string> = process.env.FTR_EXTRA_ARGS
? { FTR_EXTRA_ARGS: process.env.FTR_EXTRA_ARGS }
: {};
const envFromlabels: Record<string, string> = collectEnvFromLabels();

const { defaultQueue, ftrConfigsByQueue } = getEnabledFtrConfigs(FTR_CONFIG_PATTERNS);

Expand Down Expand Up @@ -493,7 +520,8 @@ export async function pickTestGroupRunOrder() {
agents: getAgentRule(queue),
env: {
FTR_CONFIG_GROUP_KEY: key,
...FTR_EXTRA_ARGS,
...ftrExtraArgs,
...envFromlabels,
},
retry: {
automatic: [
Expand Down
13 changes: 13 additions & 0 deletions .buildkite/scripts/steps/test/ftr_configs.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down

0 comments on commit 47f8303

Please sign in to comment.