mirror of
https://github.com/elastic/kibana.git
synced 2025-04-18 23:21:39 -04:00
[CI] Allow using elastic-images-qa
through PR label or env var (#216878)
## Summary Currently, if you'd like to test something on Kibana's VM image, you'd have to build a VM image to -qa, then rewrite all references to `elastic-images-qa` for the PR jobs; once done with testing, we'd undo the changes to `elastic-images-prod`. This is a helpful tool for us to test with WIP VM images, we'd be able to add a label to the PR, and it would automatically grab the QA images, without any temporary commits. Jobs in https://buildkite.com/elastic/kibana-pull-request/builds/289599 have ran with an elastic-qa image. ✅
This commit is contained in:
parent
2ac707ba12
commit
9f8503e0b3
2 changed files with 30 additions and 21 deletions
|
@ -8,31 +8,34 @@
|
|||
*/
|
||||
|
||||
import { dump } from 'js-yaml';
|
||||
import { BuildkiteClient, BuildkiteCommandStep } from './buildkite';
|
||||
import { BuildkiteClient, BuildkiteAgentTargetingRule } from './buildkite';
|
||||
|
||||
type AgentImageConfig = BuildkiteCommandStep['agents'];
|
||||
const ELASTIC_IMAGES_QA_PROJECT = 'elastic-images-qa';
|
||||
const ELASTIC_IMAGES_PROD_PROJECT = 'elastic-images-prod';
|
||||
|
||||
const DEFAULT_AGENT_IMAGE_CONFIG: AgentImageConfig = {
|
||||
// constrain AgentImageConfig to the type that doesn't have the `queue` property
|
||||
const DEFAULT_AGENT_IMAGE_CONFIG: BuildkiteAgentTargetingRule = {
|
||||
provider: 'gcp',
|
||||
image: 'family/kibana-ubuntu-2004',
|
||||
imageProject: 'elastic-images-prod',
|
||||
imageProject: ELASTIC_IMAGES_PROD_PROJECT,
|
||||
};
|
||||
|
||||
const FIPS_AGENT_IMAGE_CONFIG: AgentImageConfig = {
|
||||
const FIPS_AGENT_IMAGE_CONFIG: BuildkiteAgentTargetingRule = {
|
||||
provider: 'gcp',
|
||||
image: 'family/kibana-fips-ubuntu-2004',
|
||||
imageProject: 'elastic-images-prod',
|
||||
imageProject: ELASTIC_IMAGES_PROD_PROJECT,
|
||||
};
|
||||
|
||||
const GITHUB_PR_LABELS = process.env.GITHUB_PR_LABELS ?? '';
|
||||
const FTR_ENABLE_FIPS_AGENT = process.env.FTR_ENABLE_FIPS_AGENT?.toLowerCase() === 'true';
|
||||
const USE_QA_IMAGE_FOR_PR = process.env.USE_QA_IMAGE_FOR_PR?.match(/(1|true)/i);
|
||||
|
||||
// Narrow the return type with overloads
|
||||
function getAgentImageConfig(): AgentImageConfig;
|
||||
function getAgentImageConfig(): BuildkiteAgentTargetingRule;
|
||||
function getAgentImageConfig(options: { returnYaml: true }): string;
|
||||
function getAgentImageConfig({ returnYaml = false } = {}): string | AgentImageConfig {
|
||||
function getAgentImageConfig({ returnYaml = false } = {}): string | BuildkiteAgentTargetingRule {
|
||||
const bk = new BuildkiteClient();
|
||||
let config: AgentImageConfig;
|
||||
let config: BuildkiteAgentTargetingRule;
|
||||
|
||||
if (FTR_ENABLE_FIPS_AGENT || GITHUB_PR_LABELS.includes('ci:enable-fips-agent')) {
|
||||
config = FIPS_AGENT_IMAGE_CONFIG;
|
||||
|
@ -46,6 +49,10 @@ function getAgentImageConfig({ returnYaml = false } = {}): string | AgentImageCo
|
|||
config = DEFAULT_AGENT_IMAGE_CONFIG;
|
||||
}
|
||||
|
||||
if (USE_QA_IMAGE_FOR_PR || GITHUB_PR_LABELS.includes('ci:use-qa-image')) {
|
||||
config.imageProject = ELASTIC_IMAGES_QA_PROJECT;
|
||||
}
|
||||
|
||||
if (returnYaml) {
|
||||
return dump({ agents: config });
|
||||
}
|
||||
|
|
|
@ -38,6 +38,19 @@ export type BuildkiteStep =
|
|||
| BuildkiteTriggerStep
|
||||
| BuildkiteWaitStep;
|
||||
|
||||
export interface BuildkiteAgentQueue {
|
||||
queue: string;
|
||||
}
|
||||
|
||||
export interface BuildkiteAgentTargetingRule {
|
||||
provider?: string;
|
||||
image?: string;
|
||||
imageProject?: string;
|
||||
machineType?: string;
|
||||
minCpuPlatform?: string;
|
||||
preemptible?: boolean;
|
||||
}
|
||||
|
||||
export interface BuildkiteCommandStep {
|
||||
command: string;
|
||||
label: string;
|
||||
|
@ -45,18 +58,7 @@ export interface BuildkiteCommandStep {
|
|||
concurrency?: number;
|
||||
concurrency_group?: string;
|
||||
concurrency_method?: 'eager' | 'ordered';
|
||||
agents:
|
||||
| {
|
||||
queue: string;
|
||||
}
|
||||
| {
|
||||
provider?: string;
|
||||
image?: string;
|
||||
imageProject?: string;
|
||||
machineType?: string;
|
||||
minCpuPlatform?: string;
|
||||
preemptible?: boolean;
|
||||
};
|
||||
agents: BuildkiteAgentQueue | BuildkiteAgentTargetingRule;
|
||||
timeout_in_minutes?: number;
|
||||
key?: string;
|
||||
cancel_on_build_failing?: boolean;
|
||||
|
|
Loading…
Add table
Reference in a new issue