Skip to content

Commit

Permalink
Merge branch 'main' into 168856-field-list-drag-handle
Browse files Browse the repository at this point in the history
  • Loading branch information
jughosta authored Dec 4, 2023
2 parents 4b31f91 + 142a34b commit c3724ae
Show file tree
Hide file tree
Showing 5,575 changed files with 189,330 additions and 65,523 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
36 changes: 30 additions & 6 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,9 @@ disabled:
- x-pack/test/api_integration/config.ts
- x-pack/test/fleet_api_integration/config.base.ts
- x-pack/test/security_solution_api_integration/config/ess/config.base.ts
- x-pack/test/security_solution_api_integration/config/ess/config.base.basic.ts
- x-pack/test/security_solution_api_integration/config/serverless/config.base.ts
- x-pack/test/security_solution_api_integration/config/serverless/config.base.essentials.ts
- x-pack/test/security_solution_endpoint/config.base.ts
- x-pack/test/security_solution_endpoint_api_int/config.base.ts

Expand Down Expand Up @@ -156,16 +158,20 @@ enabled:
- test/server_integration/http/ssl_with_p12/config.js
- test/server_integration/http/ssl/config.js
- test/ui_capabilities/newsfeed_err/config.ts
- x-pack/test/accessibility/config.ts
- x-pack/test/accessibility/apps/group1/config.ts
- x-pack/test/accessibility/apps/group2/config.ts
- x-pack/test/accessibility/apps/group3/config.ts
- x-pack/test/localization/config.ja_jp.ts
- x-pack/test/localization/config.fr_fr.ts
- x-pack/test/localization/config.zh_cn.ts
- x-pack/test/alerting_api_integration/basic/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group1/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group2/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group3/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group4/config.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group3/config_with_schedule_circuit_breaker.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group2/config_non_dedicated_task_runner.ts
- x-pack/test/alerting_api_integration/security_and_spaces/group4/config_non_dedicated_task_runner.ts
- x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group1/config.ts
- x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group2/config.ts
- x-pack/test/alerting_api_integration/spaces_only/tests/alerting/group3/config.ts
Expand All @@ -185,6 +191,7 @@ enabled:
- x-pack/test/api_integration/apis/es/config.ts
- x-pack/test/api_integration/apis/features/config.ts
- x-pack/test/api_integration/apis/file_upload/config.ts
- x-pack/test/api_integration/apis/grok_debugger/config.ts
- x-pack/test/api_integration/apis/kibana/config.ts
- x-pack/test/api_integration/apis/lists/config.ts
- x-pack/test/api_integration/apis/logs_ui/config.ts
Expand Down Expand Up @@ -222,12 +229,10 @@ enabled:
- x-pack/test/cases_api_integration/spaces_only/config.ts
- x-pack/test/cloud_security_posture_functional/config.ts
- x-pack/test/cloud_security_posture_api/config.ts
- x-pack/test/dataset_quality_api_integration/basic/config.ts
- x-pack/test/detection_engine_api_integration/basic/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group1/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group4/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group5/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/group10/config.ts
- x-pack/test/detection_engine_api_integration/security_and_spaces/rule_execution_logic/config.ts
- x-pack/test/disable_ems/config.ts
- x-pack/test/encrypted_saved_objects_api_integration/config.ts
- x-pack/test/examples/config.ts
Expand Down Expand Up @@ -318,6 +323,7 @@ enabled:
- x-pack/test/functional/apps/transform/feature_controls/config.ts
- x-pack/test/functional/apps/upgrade_assistant/config.ts
- x-pack/test/functional/apps/uptime/config.ts
- x-pack/test/functional/apps/user_profiles/config.ts
- x-pack/test/functional/apps/visualize/config.ts
- x-pack/test/functional/apps/watcher/config.ts
- x-pack/test/functional/config_security_basic.ts
Expand All @@ -328,7 +334,6 @@ enabled:
- x-pack/test/kubernetes_security/basic/config.ts
- x-pack/test/licensing_plugin/config.public.ts
- x-pack/test/licensing_plugin/config.ts
- x-pack/test/lists_api_integration/security_and_spaces/config.ts
- x-pack/test/monitoring_api_integration/config.ts
- x-pack/test/observability_api_integration/basic/config.ts
- x-pack/test/observability_api_integration/trial/config.ts
Expand Down Expand Up @@ -411,6 +416,8 @@ enabled:
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group2.ts
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group3.ts
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group4.ts
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group5.ts
- x-pack/test_serverless/functional/test_suites/observability/common_configs/config.group6.ts
- x-pack/test_serverless/functional/test_suites/observability/config.screenshots.ts
- x-pack/test_serverless/functional/test_suites/search/config.ts
- x-pack/test_serverless/functional/test_suites/search/config.examples.ts
Expand All @@ -419,13 +426,17 @@ enabled:
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group2.ts
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group3.ts
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group4.ts
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group5.ts
- x-pack/test_serverless/functional/test_suites/search/common_configs/config.group6.ts
- x-pack/test_serverless/functional/test_suites/security/config.ts
- x-pack/test_serverless/functional/test_suites/security/config.examples.ts
- x-pack/test_serverless/functional/test_suites/security/config.cloud_security_posture.ts
- x-pack/test_serverless/functional/test_suites/security/common_configs/config.group1.ts
- x-pack/test_serverless/functional/test_suites/security/common_configs/config.group2.ts
- x-pack/test_serverless/functional/test_suites/security/common_configs/config.group3.ts
- x-pack/test_serverless/functional/test_suites/security/common_configs/config.group4.ts
- x-pack/test_serverless/functional/test_suites/security/common_configs/config.group5.ts
- x-pack/test_serverless/functional/test_suites/security/common_configs/config.group6.ts
- x-pack/performance/journeys/ecommerce_dashboard.ts
- x-pack/performance/journeys/ecommerce_dashboard_map_only.ts
- x-pack/performance/journeys/flight_dashboard.ts
Expand All @@ -445,7 +456,6 @@ enabled:
- x-pack/performance/journeys/apm_service_inventory.ts
- x-pack/test/custom_branding/config.ts
- x-pack/test/profiling_api_integration/cloud/config.ts

- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/exceptions/workflows/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/exceptions/workflows/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/exceptions/operators_data_types/date_numeric_types/configs/serverless.config.ts
Expand Down Expand Up @@ -474,3 +484,17 @@ enabled:
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/large_prebuilt_rules_package/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/update_prebuilt_rules_package/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/prebuilt_rules/update_prebuilt_rules_package/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_execution_logic/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/rule_execution_logic/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/user_roles/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/user_roles/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/telemetry/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/default_license/telemetry/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/basic_essentials_license/detection_engine/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/detections_response/basic_essentials_license/detection_engine/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/exception_lists_items/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/exception_lists_items/configs/ess.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/lists_items/configs/serverless.config.ts
- x-pack/test/security_solution_api_integration/test_suites/lists_and_exception_lists/default_license/lists_items/configs/ess.config.ts


121 changes: 111 additions & 10 deletions .buildkite/pipeline-utils/buildkite/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,31 @@
*/

import axios, { AxiosInstance } from 'axios';
import { execSync } from 'child_process';
import { execSync, ExecSyncOptions } from 'child_process';
import { dump } from 'js-yaml';
import { parseLinkHeader } from './parse_link_header';
import { Artifact } from './types/artifact';
import { Build, BuildStatus } from './types/build';
import { Job, JobState } from './types/job';

type ExecType =
| ((command: string, execOpts: ExecSyncOptions) => Buffer | null)
| ((command: string, execOpts: ExecSyncOptions) => string | null);

export interface BuildkiteClientConfig {
baseUrl?: string;
token?: string;
exec?: ExecType;
}

export interface BuildkiteGroup {
group: string;
steps: BuildkiteStep[];
}

export interface BuildkiteStep {
export type BuildkiteStep = BuildkiteCommandStep | BuildkiteInputStep;

export interface BuildkiteCommandStep {
command: string;
label: string;
parallelism?: number;
Expand All @@ -43,6 +50,50 @@ export interface BuildkiteStep {
env?: { [key: string]: string };
}

interface BuildkiteInputTextField {
text: string;
key: string;
hint?: string;
required?: boolean;
default?: string;
}

interface BuildkiteInputSelectField {
select: string;
key: string;
hint?: string;
required?: boolean;
default?: string;
multiple?: boolean;
options: Array<{
label: string;
value: string;
}>;
}

export interface BuildkiteInputStep {
input: string;
prompt?: string;
fields: Array<BuildkiteInputTextField | BuildkiteInputSelectField>;
if?: string;
allow_dependency_failure?: boolean;
branches?: string;
parallelism?: number;
agents?: {
queue: string;
};
timeout_in_minutes?: number;
key?: string;
depends_on?: string | string[];
retry?: {
automatic: Array<{
exit_status: string;
limit: number;
}>;
};
env?: { [key: string]: string };
}

export interface BuildkiteTriggerBuildParams {
commit: string;
branch: string;
Expand All @@ -61,6 +112,7 @@ export interface BuildkiteTriggerBuildParams {

export class BuildkiteClient {
http: AxiosInstance;
exec: ExecType;

constructor(config: BuildkiteClientConfig = {}) {
const BUILDKITE_BASE_URL =
Expand All @@ -78,6 +130,8 @@ export class BuildkiteClient {
},
});

this.exec = config.exec ?? execSync;

// this.agentHttp = axios.create({
// baseURL: BUILDKITE_AGENT_BASE_URL,
// headers: {
Expand All @@ -97,6 +151,32 @@ export class BuildkiteClient {
return resp.data as Build;
};

getBuildsAfterDate = async (
pipelineSlug: string,
date: string,
numberOfBuilds: number
): Promise<Build[]> => {
const response = await this.http.get(
`v2/organizations/elastic/pipelines/${pipelineSlug}/builds?created_from=${date}&per_page=${numberOfBuilds}`
);
return response.data as Build[];
};

getBuildForCommit = async (pipelineSlug: string, commit: string): Promise<Build | null> => {
if (commit.length !== 40) {
throw new Error(`Invalid commit hash: ${commit}, this endpoint works with full SHAs only`);
}

const response = await this.http.get(
`v2/organizations/elastic/pipelines/${pipelineSlug}/builds?commit=${commit}`
);
const builds = response.data as Build[];
if (builds.length === 0) {
return null;
}
return builds[0];
};

getCurrentBuild = (includeRetriedJobs = false) => {
if (!process.env.BUILDKITE_PIPELINE_SLUG || !process.env.BUILDKITE_BUILD_NUMBER) {
throw new Error(
Expand Down Expand Up @@ -235,31 +315,52 @@ export class BuildkiteClient {
};

setMetadata = (key: string, value: string) => {
execSync(`buildkite-agent meta-data set '${key}'`, {
this.exec(`buildkite-agent meta-data set '${key}'`, {
input: value,
stdio: ['pipe', 'inherit', 'inherit'],
});
};

getMetadata(key: string, defaultValue: string | null = null): string | null {
try {
const stdout = this.exec(`buildkite-agent meta-data get '${key}'`, {
stdio: ['pipe'],
});
return stdout?.toString().trim() || defaultValue;
} catch (e) {
if (e.message.includes('404 Not Found')) {
return defaultValue;
} else {
throw e;
}
}
}

setAnnotation = (
context: string,
style: 'info' | 'success' | 'warning' | 'error',
value: string
value: string,
append: boolean = false
) => {
execSync(`buildkite-agent annotate --context '${context}' --style '${style}'`, {
input: value,
stdio: ['pipe', 'inherit', 'inherit'],
});
this.exec(
`buildkite-agent annotate --context '${context}' --style '${style}' ${
append ? '--append' : ''
}`,
{
input: value,
stdio: ['pipe', 'inherit', 'inherit'],
}
);
};

uploadArtifacts = (pattern: string) => {
execSync(`buildkite-agent artifact upload '${pattern}'`, {
this.exec(`buildkite-agent artifact upload '${pattern}'`, {
stdio: ['ignore', 'inherit', 'inherit'],
});
};

uploadSteps = (steps: Array<BuildkiteStep | BuildkiteGroup>) => {
execSync(`buildkite-agent pipeline upload`, {
this.exec(`buildkite-agent pipeline upload`, {
input: dump({ steps }),
stdio: ['pipe', 'inherit', 'inherit'],
});
Expand Down
4 changes: 2 additions & 2 deletions .buildkite/pipeline-utils/ci-stats/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ export class CiStatsClient {
headers: this.defaultHeaders,
});
} catch (error) {
console.error('CI Stats request error:', error);
console.error('CI Stats request error:', error?.response?.data?.message);

if (attempt < maxAttempts) {
const sec = attempt * 3;
Expand All @@ -210,7 +210,7 @@ export class CiStatsClient {
continue;
}

throw error;
throw new Error('Failed to connect to CI Stats.');
}
}
}
Expand Down
10 changes: 9 additions & 1 deletion .buildkite/pipeline-utils/ci-stats/on_complete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,15 @@ export async function onComplete() {

const report = await ciStats.getPrReport(process.env.CI_STATS_BUILD_ID);
if (report?.md) {
buildkite.setMetadata('pr_comment:ci_stats_report:body', report.md);
// buildkite has a metadata size limit of 100kb, so we only add this, if it's small enough
if (new Blob([report.md]).size < 100000) {
buildkite.setMetadata('pr_comment:ci_stats_report:body', report.md);
} else {
buildkite.setMetadata(
'pr_comment:ci_stats_report:body',
'The CI Stats report is too large to be displayed here, check out the CI build annotation for this information.'
);
}

const annotationType = report?.success ? 'info' : 'error';
buildkite.setAnnotation('ci-stats-report', annotationType, report.md);
Expand Down
4 changes: 4 additions & 0 deletions .buildkite/pipeline-utils/github/github.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,3 +91,7 @@ export const doAnyChangesMatch = async (

return anyFilesMatchRequired;
};

export function getGithubClient() {
return github;
}
1 change: 1 addition & 0 deletions .buildkite/pipeline-utils/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@ export * from './buildkite';
export * as CiStats from './ci-stats';
export * from './github';
export * as TestFailures from './test-failures';
export * from './utils';
24 changes: 24 additions & 0 deletions .buildkite/pipeline-utils/utils.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
/*
* 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 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 or the Server
* Side Public License, v 1.
*/

import { execSync } from 'child_process';

const getKibanaDir = (() => {
let kibanaDir: string | undefined;
return () => {
if (!kibanaDir) {
kibanaDir = execSync('git rev-parse --show-toplevel', { encoding: 'utf-8' })
.toString()
.trim();
}

return kibanaDir;
};
})();

export { getKibanaDir };
Loading

0 comments on commit c3724ae

Please sign in to comment.