From c303263344e5b28ce8f3da4ecdcdb2f5d2fcad82 Mon Sep 17 00:00:00 2001 From: Pierre Gayvallet Date: Wed, 25 Oct 2023 10:09:28 +0200 Subject: [PATCH] [CI] automatically commit SO def change snapshot (#169610) Fix https://github.com/elastic/kibana/issues/147935 Automatically run the SO def integration test, and commit the changes if any, as a new CI check script. As explained in the issue, this is just some DX improvement, avoiding for the developer the inconvenience of doing it manually every time they change or add a SO in any PR. --- .buildkite/scripts/steps/checks.sh | 1 + .../checks/saved_objects_definition_change.sh | 11 ++++++++++ .../ci_checks/jest.integration.config.js | 20 +++++++++++++++++++ .../check_registered_types.test.ts | 0 4 files changed, 32 insertions(+) create mode 100755 .buildkite/scripts/steps/checks/saved_objects_definition_change.sh create mode 100644 src/core/server/integration_tests/ci_checks/jest.integration.config.js rename src/core/server/integration_tests/{saved_objects/migrations/group2 => ci_checks/saved_objects}/check_registered_types.test.ts (100%) diff --git a/.buildkite/scripts/steps/checks.sh b/.buildkite/scripts/steps/checks.sh index 92ae1f5eadca3..639e3f02ef1df 100755 --- a/.buildkite/scripts/steps/checks.sh +++ b/.buildkite/scripts/steps/checks.sh @@ -22,5 +22,6 @@ export DISABLE_BOOTSTRAP_VALIDATION=false .buildkite/scripts/steps/checks/test_hardening.sh .buildkite/scripts/steps/checks/ftr_configs.sh .buildkite/scripts/steps/checks/saved_objects_compat_changes.sh +.buildkite/scripts/steps/checks/saved_objects_definition_change.sh .buildkite/scripts/steps/code_generation/security_solution_codegen.sh .buildkite/scripts/steps/checks/yarn_deduplicate.sh diff --git a/.buildkite/scripts/steps/checks/saved_objects_definition_change.sh b/.buildkite/scripts/steps/checks/saved_objects_definition_change.sh new file mode 100755 index 0000000000000..175128d536fd5 --- /dev/null +++ b/.buildkite/scripts/steps/checks/saved_objects_definition_change.sh @@ -0,0 +1,11 @@ +#!/usr/bin/env bash + +set -euo pipefail + +source .buildkite/scripts/common/util.sh + +echo --- Check SO definition changes +cmd="node scripts/jest_integration -u src/core/server/integration_tests/ci_checks" + +eval "$cmd" +check_for_changed_files "$cmd" true diff --git a/src/core/server/integration_tests/ci_checks/jest.integration.config.js b/src/core/server/integration_tests/ci_checks/jest.integration.config.js new file mode 100644 index 0000000000000..cca8ea704bb8d --- /dev/null +++ b/src/core/server/integration_tests/ci_checks/jest.integration.config.js @@ -0,0 +1,20 @@ +/* + * 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. + */ + +module.exports = { + bail: true, // only report 1 issue + // TODO replace the line below with + // preset: '@kbn/test/jest_integration_node + // to do so, we must fix all integration tests first + // see https://github.com/elastic/kibana/pull/130255/ + preset: '@kbn/test/jest_integration', + rootDir: '../../../../..', + roots: ['/src/core/server/integration_tests/ci_checks'], + // must override to match all test given there is no `integration_tests` subfolder + testMatch: ['**/*.test.{js,mjs,ts,tsx}'], +}; diff --git a/src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts b/src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts similarity index 100% rename from src/core/server/integration_tests/saved_objects/migrations/group2/check_registered_types.test.ts rename to src/core/server/integration_tests/ci_checks/saved_objects/check_registered_types.test.ts