Skip to content

Commit

Permalink
Merge branch 'main' into security/tests/flaky-alert-assignments
Browse files Browse the repository at this point in the history
  • Loading branch information
kibanamachine authored Mar 5, 2024
2 parents c098902 + 64fa491 commit 915ea6f
Show file tree
Hide file tree
Showing 5,616 changed files with 15,666 additions and 11,430 deletions.
The diff you're trying to view is too large. We only load the first 3000 changed files.
6 changes: 3 additions & 3 deletions .buildkite/ftr_configs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,9 @@ disabled:
- x-pack/test/functional_enterprise_search/visual_config.ts
- x-pack/test/functional_enterprise_search/cli_config.ts
- x-pack/test_serverless/functional/test_suites/security/cypress/security_config.ts
- x-pack/plugins/apm/ftr_e2e/ftr_config_open.ts
- x-pack/plugins/apm/ftr_e2e/ftr_config_run.ts
- x-pack/plugins/apm/ftr_e2e/ftr_config.ts
- x-pack/plugins/observability_solution/apm/ftr_e2e/ftr_config_open.ts
- x-pack/plugins/observability_solution/apm/ftr_e2e/ftr_config_run.ts
- x-pack/plugins/observability_solution/apm/ftr_e2e/ftr_config.ts
- x-pack/test_serverless/functional/test_suites/observability/cypress/config_headless.ts
- x-pack/test_serverless/functional/test_suites/observability/cypress/config_runner.ts
- x-pack/test/security_solution_cypress/serverless_config.ts
Expand Down
21 changes: 20 additions & 1 deletion .buildkite/pipeline-utils/buildkite/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface BuildkiteGroup {
steps: BuildkiteStep[];
}

export type BuildkiteStep = BuildkiteCommandStep | BuildkiteInputStep;
export type BuildkiteStep = BuildkiteCommandStep | BuildkiteInputStep | BuildkiteTriggerStep;

export interface BuildkiteCommandStep {
command: string;
Expand Down Expand Up @@ -94,6 +94,25 @@ export interface BuildkiteInputStep {
env?: { [key: string]: string };
}

export interface BuildkiteTriggerStep {
trigger: string;
label?: string;
build?: {
message?: string; // The message for the build. Supports emoji.
commit?: string; // The commit hash for the build.
branch?: string; // The branch for the build.
meta_data?: string; // A map of meta-data for the build.
env?: Record<string, string>; // A map of environment variables for the build.
};
async?: boolean;
branches?: string;
if?: string;
allow_dependency_failure?: boolean;
soft_fail?: boolean;
depends_on?: string | string[];
skip?: string;
}

export interface BuildkiteTriggerBuildParams {
commit: string;
branch: string;
Expand Down
12 changes: 0 additions & 12 deletions .buildkite/pipelines/pipeline.kibana-serverless-release.yaml

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,9 @@ steps:
- ts-node .buildkite/scripts/serverless/create_deploy_tag/release_wizard_messaging.ts --state create_deploy_tag
- bash .buildkite/scripts/serverless/create_deploy_tag/create_deploy_tag.sh
- ts-node .buildkite/scripts/serverless/create_deploy_tag/release_wizard_messaging.ts --state tag_created
- ts-node .buildkite/scripts/serverless/create_deploy_tag/generate_gpctl_trigger.ts
- ts-node .buildkite/scripts/serverless/create_deploy_tag/release_wizard_messaging.ts --state trigger_gpctl
env:
DRY_RUN: $DRY_RUN

- wait: ~
Original file line number Diff line number Diff line change
Expand Up @@ -33,4 +33,4 @@ else
echo "Skipping tag push to GitHub due to DRY_RUN=$DRY_RUN"
fi

echo "Created deploy tag: $DEPLOY_TAG - your QA release should start @ https://buildkite.com/elastic/kibana-serverless-release/builds?branch=$DEPLOY_TAG"
echo "Created deploy tag: $DEPLOY_TAG"
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
/*
* 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 { buildkite } from './shared';
import { getSelectedCommitHash } from './info_sections/commit_info';
import { BuildkiteTriggerStep } from '#pipeline-utils';

const IS_DRY_RUN = process.env.DRY_RUN?.match(/(1|true)/i);
const REMOTE_SERVICE_CONFIG = `https://raw.githubusercontent.com/elastic/serverless-gitops/main/gen/gpctl/kibana/config.yaml`;

async function main() {
const selectedSha = getSelectedCommitHash();
uploadTriggerStep(selectedSha);
}

function uploadTriggerStep(commitSha: string) {
const triggerStep: BuildkiteTriggerStep = {
label: ':releasethekaken: Trigger GPCTL / Release Kibana',
trigger: 'gpctl-promote',
async: true,
build: {
message: 'Triggered by Kibana serverless release pipeline',
env: {
SERVICE_COMMIT_HASH: commitSha.slice(0, 12),
REMOTE_SERVICE_CONFIG,
},
},
};

if (IS_DRY_RUN) {
console.log('Dry run: skipping upload of GPCTL trigger step. Step definition:', triggerStep);
} else {
buildkite.uploadSteps([triggerStep]);
}
}

main()
.then(() => {
console.log('GPCTL Trigger step uploaded.');
})
.catch((error) => {
console.error(error);
process.exit(1);
});
Original file line number Diff line number Diff line change
Expand Up @@ -34,9 +34,9 @@ type StateNames =
| 'wait_for_confirmation'
| 'create_deploy_tag'
| 'tag_created'
| 'trigger_gpctl'
| 'end'
| 'error_generic'
| string;
| 'error_generic';

interface StateShape {
name: string;
Expand Down Expand Up @@ -117,7 +117,20 @@ const states: Record<StateNames, StateShape> = {
name: 'Release tag created',
description: 'The initial step release is completed, follow up jobs will be triggered soon.',
instruction: `<h3>Deploy tag successfully created!</h3>`,
post: async () => {
instructionStyle: 'success',
display: true,
},
trigger_gpctl: {
name: 'Triggering GPCTL deployment',
description: 'Triggering the GPCTL deployment for the release - sit back and relax.',
instruction: `GPCTL deployment triggered, follow the trigger step for more info.`,
instructionStyle: 'info',
display: true,
},
end: {
name: 'End of the release process',
description: 'The release process has ended.',
pre: async () => {
// The deployTag here is only for communication, if it's missing, it's not a big deal, but it's an error
const deployTag =
buildkite.getMetadata(DEPLOY_TAG_META_KEY) ||
Expand All @@ -128,8 +141,7 @@ const states: Record<StateNames, StateShape> = {
buildkite.setAnnotation(
WIZARD_CTX_INSTRUCTION,
'success',
`<h3>Deploy tag successfully created!</h3><br/>
Your deployment will appear <a href='https://buildkite.com/elastic/kibana-serverless-release/builds?branch=${deployTag}'>here on buildkite.</a>`
`<h3>Release successfully initiated!</h3>`
);

if (!selectedCommit) {
Expand All @@ -153,12 +165,6 @@ Your deployment will appear <a href='https://buildkite.com/elastic/kibana-server
deployTag,
});
},
instructionStyle: 'success',
display: true,
},
end: {
name: 'End of the release process',
description: 'The release process has ended.',
display: false,
},
error_generic: {
Expand All @@ -179,15 +185,15 @@ export async function main(args: string[]) {
if (!args.includes('--state')) {
throw new Error('Missing --state argument');
}
const targetState = args.slice(args.indexOf('--state') + 1)[0];
const targetState = args.slice(args.indexOf('--state') + 1)[0] as StateNames;

let data: any;
if (args.includes('--data')) {
data = args.slice(args.indexOf('--data') + 1)[0];
}

const resultingTargetState = await transition(targetState, data);
if (resultingTargetState === 'tag_created') {
if (resultingTargetState === 'trigger_gpctl') {
return await transition('end');
} else {
return resultingTargetState;
Expand All @@ -196,7 +202,7 @@ export async function main(args: string[]) {

export async function transition(targetStateName: StateNames, data?: any) {
// use the buildkite agent to find what state we are in:
const currentStateName = buildkite.getMetadata('release_state') || 'start';
const currentStateName = (buildkite.getMetadata('release_state') || 'start') as StateNames;
const stateData = JSON.parse(buildkite.getMetadata('state_data') || '{}');

if (!currentStateName) {
Expand Down Expand Up @@ -243,10 +249,10 @@ function updateWizardState(stateData: Record<string, 'ok' | 'nok' | 'pending' |
: `<h3>:kibana: Kibana Serverless deployment wizard :mage:</h3>`;

const wizardSteps = Object.keys(states)
.filter((stateName) => states[stateName].display)
.filter((stateName) => !(IS_AUTOMATED_RUN && states[stateName].skipWhenAutomated))
.filter((stateName) => states[stateName as StateNames].display)
.filter((stateName) => !(IS_AUTOMATED_RUN && states[stateName as StateNames].skipWhenAutomated))
.map((stateName) => {
const stateInfo = states[stateName];
const stateInfo = states[stateName as StateNames];
const stateStatus = stateData[stateName];
const stateEmoji = {
ok: ':white_check_mark:',
Expand All @@ -271,7 +277,7 @@ ${wizardSteps.join('\n')}
}

function updateWizardInstruction(targetState: string, stateData: any) {
const { instructionStyle, instruction } = states[targetState];
const { instructionStyle, instruction } = states[targetState as StateNames];

if (IS_AUTOMATED_RUN) {
buildkite.setAnnotation(
Expand Down
29 changes: 15 additions & 14 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -591,7 +591,7 @@ module.exports = {
'**/*.test.js',
'x-pack/test/apm_api_integration/**/*.ts',
'x-pack/test/functional/apps/**/*.js',
'x-pack/plugins/apm/**/*.js',
'x-pack/plugins/observability_solution/apm/**/*.js',
'test/*/config.ts',
'test/*/config_open.ts',
'test/*/*.config.ts',
Expand Down Expand Up @@ -871,8 +871,8 @@ module.exports = {
*/
{
files: [
'x-pack/plugins/apm/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability_solution/apm/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability_solution/observability/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability_solution/exploratory_view/**/*.{js,mjs,ts,tsx}',
'x-pack/plugins/observability_solution/ux/**/*.{js,mjs,ts,tsx}',
],
Expand All @@ -894,8 +894,8 @@ module.exports = {
},
{
files: [
'x-pack/plugins/apm/**/*.stories.*',
'x-pack/plugins/observability/**/*.stories.*',
'x-pack/plugins/observability_solution/apm/**/*.stories.*',
'x-pack/plugins/observability_solution/observability/**/*.stories.*',
'x-pack/plugins/observability_solution/exploratory_view/**/*.stories.*',
],
rules: {
Expand All @@ -911,16 +911,18 @@ module.exports = {
{
files: [
'x-pack/plugins/aiops/**/*.tsx',
'x-pack/plugins/apm/**/*.tsx',
'x-pack/plugins/observability_solution/exploratory_view/**/*.tsx',
'x-pack/plugins/infra/**/*.tsx',
'x-pack/plugins/observability/**/*.tsx',
'x-pack/plugins/observability_solution/observability_onboarding/**/*.tsx',
'x-pack/plugins/observability_solution/apm/**/*.tsx',
'x-pack/plugins/observability_solution/dataset_quality/**/*.tsx',
'x-pack/plugins/observability_solution/exploratory_view/**/*.tsx',
'x-pack/plugins/observability_solution/infra/**/*.tsx',
'x-pack/plugins/observability_solution/observability/**/*.tsx',
'x-pack/plugins/observability_solution/observability_ai_assistant/**/*.tsx',
'x-pack/plugins/observability_solution/observability_onboarding/**/*.tsx',
'x-pack/plugins/observability_solution/observability_shared/**/*.tsx',
'x-pack/plugins/observability_solution/profiling/**/*.tsx',
'x-pack/plugins/observability_solution/synthetics/**/*.tsx',
'x-pack/plugins/observability_solution/uptime/**/*.tsx',
'x-pack/plugins/observability_solution/ux/**/*.tsx',
'src/plugins/ai_assistant_management/**/*.tsx',
],
Expand All @@ -930,11 +932,10 @@ module.exports = {
},
{
files: [
'x-pack/plugins/apm/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/apm/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/exploratory_view/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/infra/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/observability_onboarding/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/infra/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/observability/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/observability_ai_assistant/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/observability_onboarding/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
'x-pack/plugins/observability_solution/observability_shared/**/!(*.stories.tsx|*.test.tsx|*.storybook_decorator.tsx|*.mock.tsx)',
Expand All @@ -950,7 +951,7 @@ module.exports = {
},
{
// require explicit return types in route handlers for performance reasons
files: ['x-pack/plugins/apm/server/**/route.ts'],
files: ['x-pack/plugins/observability_solution/apm/server/**/route.ts'],
rules: {
'@typescript-eslint/explicit-function-return-type': [
'error',
Expand Down
Loading

0 comments on commit 915ea6f

Please sign in to comment.