mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
[ci] Flaky test runner respect labels (#215167)
## Summary Extracts `collectEnvFromLabels` to a separate module, so it can be used in the flaky test runner. With this, the label `ci:use-chrome-beta` will be passed along to the flaky test runner, allowing for flaky testing on chrome beta. Other labels we treat as modifiers for PR behavior through setting env variables should also be added to this set of mapping.
This commit is contained in:
parent
574e2580c6
commit
415d672d31
4 changed files with 43 additions and 28 deletions
|
@ -19,7 +19,7 @@ import { CiStatsClient, TestGroupRunOrderResponse } from './client';
|
|||
|
||||
import DISABLED_JEST_CONFIGS from '../../disabled_jest_configs.json';
|
||||
import { serverless, stateful } from '../../ftr_configs_manifests.json';
|
||||
import { expandAgentQueue } from '#pipeline-utils';
|
||||
import { collectEnvFromLabels, expandAgentQueue } from '#pipeline-utils';
|
||||
|
||||
const ALL_FTR_MANIFEST_REL_PATHS = serverless.concat(stateful);
|
||||
|
||||
|
@ -196,32 +196,6 @@ 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();
|
||||
|
|
|
@ -13,3 +13,4 @@ export * as CiStats from './ci-stats';
|
|||
export * from './github';
|
||||
export * as TestFailures from './test-failures';
|
||||
export * from './utils';
|
||||
export * from './pr_labels';
|
||||
|
|
38
.buildkite/pipeline-utils/pr_labels.ts
Normal file
38
.buildkite/pipeline-utils/pr_labels.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
/*
|
||||
* 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", the "GNU Affero General Public License v3.0 only", 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", the "GNU Affero General Public
|
||||
* License v3.0 only", or the "Server Side Public License, v 1".
|
||||
*/
|
||||
|
||||
/**
|
||||
* Available auto-mapped label options, respected by 'collectEnvFromLabels' function.
|
||||
*/
|
||||
export const LABEL_MAPPING: Record<string, Record<string, string>> = {
|
||||
'ci:use-chrome-beta': {
|
||||
USE_CHROME_BETA: 'true', // Use if you want to run tests with Chrome Beta
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* This function reads available GITHUB_LABELS and maps them to environment variables.
|
||||
*/
|
||||
export function collectEnvFromLabels(
|
||||
labels = process.env.GITHUB_PR_LABELS
|
||||
): Record<string, string> {
|
||||
const envFromlabels: Record<string, string> = {};
|
||||
|
||||
if (labels) {
|
||||
const labelArray = labels.split(',');
|
||||
labelArray.forEach((label) => {
|
||||
const env = LABEL_MAPPING[label];
|
||||
if (env) {
|
||||
Object.assign(envFromlabels, env);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return envFromlabels;
|
||||
}
|
|
@ -8,7 +8,7 @@
|
|||
*/
|
||||
|
||||
import { groups } from './groups.json';
|
||||
import { BuildkiteStep, expandAgentQueue } from '#pipeline-utils';
|
||||
import { BuildkiteStep, expandAgentQueue, collectEnvFromLabels } from '#pipeline-utils';
|
||||
|
||||
const configJson = process.env.KIBANA_FLAKY_TEST_RUNNER_CONFIG;
|
||||
if (!configJson) {
|
||||
|
@ -113,9 +113,11 @@ if (totalJobs > MAX_JOBS) {
|
|||
}
|
||||
|
||||
const steps: BuildkiteStep[] = [];
|
||||
const envFromLabels = collectEnvFromLabels(process.env.GITHUB_PR_LABELS);
|
||||
const pipeline = {
|
||||
env: {
|
||||
IGNORE_SHIP_CI_STATS_ERROR: 'true',
|
||||
...envFromLabels,
|
||||
},
|
||||
steps,
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue