diff --git a/.buildkite/scripts/pipelines/pull_request/pipeline.ts b/.buildkite/scripts/pipelines/pull_request/pipeline.ts index f1ffb60fee94d..3669b966f634f 100644 --- a/.buildkite/scripts/pipelines/pull_request/pipeline.ts +++ b/.buildkite/scripts/pipelines/pull_request/pipeline.ts @@ -516,16 +516,9 @@ const SKIPPABLE_PR_MATCHERS = prConfig.skip_ci_on_only_changed!.map((r) => new R pipeline.push(getPipeline('.buildkite/pipelines/pull_request/prompt_changes.yml')); } - // Run Saved Objects checks conditionally - if ( - await doAnyChangesMatch([ - /^packages\/kbn-check-saved-objects-cli\/current_fields.json/, - /^packages\/kbn-check-saved-objects-cli\/current_mappings.json/, - /^src\/core\/server\/integration_tests\/ci_checks\/saved_objects\/check_registered_types.test.ts/, - ]) - ) { - pipeline.push(getPipeline('.buildkite/pipelines/pull_request/check_saved_objects.yml')); - } + // Always run Saved Objects checks. + // If there aren't any SO types modified, the check will run with test data as a smoke test for migration logic + pipeline.push(getPipeline('.buildkite/pipelines/pull_request/check_saved_objects.yml')); if ( (await doAnyChangesMatch([ diff --git a/packages/kbn-check-saved-objects-cli/src/commands/run_check_saved_objects_cli.ts b/packages/kbn-check-saved-objects-cli/src/commands/run_check_saved_objects_cli.ts index 0f92028cd121a..926292133f32d 100644 --- a/packages/kbn-check-saved-objects-cli/src/commands/run_check_saved_objects_cli.ts +++ b/packages/kbn-check-saved-objects-cli/src/commands/run_check_saved_objects_cli.ts @@ -11,14 +11,7 @@ import { Listr, PRESET_TIMER } from 'listr2'; import { run } from '@kbn/dev-cli-runner'; import { setupKibana, startElasticsearch, stopElasticsearch, stopKibana } from '../util'; import type { TaskContext } from './types'; -import { - automatedRollbackTests, - checkRemovedTypes, - getSnapshots, - validateNewTypes, - validateUpdatedTypes, -} from './tasks'; -import { getTestSnapshots, TEST_TYPES } from './test'; +import { automatedRollbackTests, getSnapshots, validateSOChanges, validateTestFlow } from './tasks'; export function runCheckSavedObjectsCli() { let globalTask: Listr; @@ -90,41 +83,38 @@ export function runCheckSavedObjectsCli() { }, /** * ================================================================== - * The following tasks only run in "--test mode". + * Validate SO changes. * - * Instead of starting Kibana and getting the actual typeRegistry - * we use a test registry with a bunch of fake SO types. + * Checks for removed types, new types, and updated types. * ================================================================== */ { - title: 'Obtain type registry (test mode)', - task: async (ctx) => (ctx.registeredTypes = TEST_TYPES), - enabled: !server && test, + title: 'Validate SO changes', + task: validateSOChanges, + enabled: !server && !test, + skip: test, }, { - title: 'Get type registry snapshots (test mode)', - task: getTestSnapshots, - enabled: !server && test, + title: 'Fallback to test mode (no updated types detected)', + task: (ctx) => { + ctx.test = true; + }, + enabled: !server && !test, + skip: (ctx) => ctx.updatedTypes.length > 0, }, /** * ================================================================== - * The following tasks run systematically + * Validate test flow (runs in test mode or after fallback). + * + * Sets up a test type registry and test snapshots, then runs + * the same validation pipeline with test data. * ================================================================== */ { - title: 'Check removed SO types', - task: checkRemovedTypes, - enabled: !server, - }, - { - title: 'Validate new SO types', - task: validateNewTypes, - enabled: !server, - }, - { - title: 'Validate existing SO types', - task: validateUpdatedTypes, + title: 'Validate test flow', + task: validateTestFlow, enabled: !server, + skip: (ctx) => !ctx.test, }, { title: 'Automated rollback tests', diff --git a/packages/kbn-check-saved-objects-cli/src/commands/tasks/index.ts b/packages/kbn-check-saved-objects-cli/src/commands/tasks/index.ts index 813bf94f7be37..2409b9d2662df 100644 --- a/packages/kbn-check-saved-objects-cli/src/commands/tasks/index.ts +++ b/packages/kbn-check-saved-objects-cli/src/commands/tasks/index.ts @@ -8,7 +8,6 @@ */ export { getSnapshots } from './get_snapshots'; -export { validateNewTypes } from './validate_new_types'; -export { validateUpdatedTypes } from './validate_updated_types'; export { automatedRollbackTests } from './automated_rollback_tests'; -export { checkRemovedTypes } from './check_removed_types'; +export { validateSOChanges } from './validate_so_changes'; +export { validateTestFlow } from './validate_test_flow'; diff --git a/packages/kbn-check-saved-objects-cli/src/commands/tasks/validate_so_changes.ts b/packages/kbn-check-saved-objects-cli/src/commands/tasks/validate_so_changes.ts new file mode 100644 index 0000000000000..3fb0d19ef0b7c --- /dev/null +++ b/packages/kbn-check-saved-objects-cli/src/commands/tasks/validate_so_changes.ts @@ -0,0 +1,33 @@ +/* + * 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". + */ + +import type { ListrTask } from 'listr2'; +import type { Task, TaskContext } from '../types'; +import { checkRemovedTypes } from './check_removed_types'; +import { validateNewTypes } from './validate_new_types'; +import { validateUpdatedTypes } from './validate_updated_types'; + +export const validateSOChanges: Task = (ctx, task) => { + const subtasks: ListrTask[] = [ + { + title: 'Check removed SO types', + task: checkRemovedTypes, + }, + { + title: 'Validate new SO types', + task: validateNewTypes, + }, + { + title: 'Validate existing SO types', + task: validateUpdatedTypes, + }, + ]; + + return task.newListr(subtasks); +}; diff --git a/packages/kbn-check-saved-objects-cli/src/commands/tasks/validate_test_flow.ts b/packages/kbn-check-saved-objects-cli/src/commands/tasks/validate_test_flow.ts new file mode 100644 index 0000000000000..d336605a6c896 --- /dev/null +++ b/packages/kbn-check-saved-objects-cli/src/commands/tasks/validate_test_flow.ts @@ -0,0 +1,34 @@ +/* + * 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". + */ + +import type { ListrTask } from 'listr2'; +import type { Task, TaskContext } from '../types'; +import { TEST_TYPES, getTestSnapshots } from '../test'; +import { validateSOChanges } from './validate_so_changes'; + +export const validateTestFlow: Task = (ctx, task) => { + const subtasks: ListrTask[] = [ + { + title: 'Obtain type registry (test mode)', + task: async () => { + ctx.registeredTypes = TEST_TYPES; + }, + }, + { + title: 'Get type registry snapshots (test mode)', + task: getTestSnapshots, + }, + { + title: 'Validate SO changes', + task: validateSOChanges, + }, + ]; + + return task.newListr(subtasks); +};