mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
Collect code coverage for server side (#124277)
* [code coverage] collect coverage on server side * fix script * copy server coverage to functional * [code coverage] run all e2e and api tests * enable all configs for coverage, fix reportDir * [code coverage] use KIBANA_DIR var * create target/kibana-coverage/functional if not exist * remove empty lines and unused code * adjust include/exclude filters * exclude more test-related paths * Update functional nyc config * Update server nyc config * exclude more dirs * exclude stub/
This commit is contained in:
parent
004f9e2dde
commit
f121c545cf
8 changed files with 81 additions and 25 deletions
|
@ -20,10 +20,19 @@ export CODE_COVERAGE=1
|
|||
echo "--- OSS CI Group $CI_GROUP"
|
||||
echo " -> Running Functional tests with code coverage"
|
||||
|
||||
node scripts/functional_tests \
|
||||
NODE_OPTIONS=--max_old_space_size=14336 \
|
||||
./node_modules/.bin/nyc \
|
||||
--nycrc-path src/dev/code_coverage/nyc_config/nyc.server.config.js \
|
||||
node scripts/functional_tests \
|
||||
--include-tag "ciGroup$CI_GROUP" \
|
||||
--exclude-tag "skipCoverage" || true
|
||||
|
||||
if [[ -d "$KIBANA_DIR/target/kibana-coverage/server" ]]; then
|
||||
echo "--- Server side code coverage collected"
|
||||
mkdir -p target/kibana-coverage/functional
|
||||
mv target/kibana-coverage/server/coverage-final.json "target/kibana-coverage/functional/oss-${CI_GROUP}-server-coverage.json"
|
||||
fi
|
||||
|
||||
if [[ -d "$KIBANA_DIR/target/kibana-coverage/functional" ]]; then
|
||||
echo "--- Merging code coverage for CI Group $CI_GROUP"
|
||||
yarn nyc report --nycrc-path src/dev/code_coverage/nyc_config/nyc.functional.config.js --reporter json
|
||||
|
|
|
@ -22,12 +22,21 @@ echo " -> Running X-Pack functional tests with code coverage"
|
|||
|
||||
cd "$XPACK_DIR"
|
||||
|
||||
node scripts/functional_tests \
|
||||
NODE_OPTIONS=--max_old_space_size=14336 \
|
||||
./../node_modules/.bin/nyc \
|
||||
--nycrc-path ./../src/dev/code_coverage/nyc_config/nyc.server.config.js \
|
||||
node scripts/functional_tests \
|
||||
--include-tag "ciGroup$CI_GROUP" \
|
||||
--exclude-tag "skipCoverage" || true
|
||||
|
||||
cd "$KIBANA_DIR"
|
||||
|
||||
if [[ -d "$KIBANA_DIR/target/kibana-coverage/server" ]]; then
|
||||
echo "--- Server side code coverage collected"
|
||||
mkdir -p target/kibana-coverage/functional
|
||||
mv target/kibana-coverage/server/coverage-final.json "target/kibana-coverage/functional/xpack-${CI_GROUP}-server-coverage.json"
|
||||
fi
|
||||
|
||||
if [[ -d "$KIBANA_DIR/target/kibana-coverage/functional" ]]; then
|
||||
echo "--- Merging code coverage for CI Group $CI_GROUP"
|
||||
yarn nyc report --nycrc-path src/dev/code_coverage/nyc_config/nyc.functional.config.js --reporter json
|
||||
|
|
|
@ -455,6 +455,7 @@
|
|||
"@elastic/synthetics": "^1.0.0-beta.16",
|
||||
"@emotion/babel-preset-css-prop": "^11.2.0",
|
||||
"@emotion/jest": "^11.3.0",
|
||||
"@istanbuljs/nyc-config-typescript": "^1.0.2",
|
||||
"@istanbuljs/schema": "^0.1.2",
|
||||
"@jest/console": "^26.6.2",
|
||||
"@jest/reporters": "^26.6.2",
|
||||
|
|
|
@ -6,8 +6,8 @@
|
|||
* Side Public License, v 1.
|
||||
*/
|
||||
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
const alwaysImportedTests = [
|
||||
require('../src/setup_node_env');
|
||||
require('@kbn/test').runTestsCli([
|
||||
require.resolve('../test/functional/config.js'),
|
||||
require.resolve('../test/plugin_functional/config.ts'),
|
||||
require.resolve('../test/ui_capabilities/newsfeed_err/config.ts'),
|
||||
|
@ -25,18 +25,7 @@ const alwaysImportedTests = [
|
|||
require.resolve(
|
||||
'../test/interactive_setup_functional/manual_configuration_without_tls.config.ts'
|
||||
),
|
||||
];
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
const onlyNotInCoverageTests = [
|
||||
require.resolve('../test/api_integration/config.js'),
|
||||
require.resolve('../test/interpreter_functional/config.ts'),
|
||||
require.resolve('../test/examples/config.js'),
|
||||
];
|
||||
|
||||
require('../src/setup_node_env');
|
||||
require('@kbn/test').runTestsCli([
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
...alwaysImportedTests,
|
||||
// eslint-disable-next-line no-restricted-syntax
|
||||
...(!!process.env.CODE_COVERAGE ? [] : onlyNotInCoverageTests),
|
||||
]);
|
||||
|
|
|
@ -7,7 +7,18 @@
|
|||
*/
|
||||
|
||||
const defaultExclude = require('@istanbuljs/schema/default-exclude');
|
||||
const extraExclude = ['data/optimize/**', 'src/core/server/**', '**/{test, types}/**/*'];
|
||||
const extraExclude = [
|
||||
'data/optimize/**',
|
||||
'**/{__jest__,__test__,__examples__,__fixtures__,__snapshots__,__stories__,*mock*,*storybook,target,types}/**/*',
|
||||
'**/{integration_tests,test,tests,test_helpers,test_data,test_samples,test_utils,test_utilities,*scripts}/**/*',
|
||||
'**/{*e2e*,fixtures,manual_tests,stub*}/**',
|
||||
'**/*mock*.{ts,tsx}',
|
||||
'**/*.test.{ts,tsx}',
|
||||
'**/*.spec.{ts,tsx}',
|
||||
'**/types.ts',
|
||||
'**/*.d.ts',
|
||||
'**/index.{js,ts,tsx}',
|
||||
];
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
|
@ -16,5 +27,9 @@ module.exports = {
|
|||
: 'target/kibana-coverage/functional',
|
||||
'report-dir': 'target/kibana-coverage/functional-combined',
|
||||
reporter: ['html', 'json-summary'],
|
||||
include: [
|
||||
'src/{core,plugins}/**/*.{js,mjs,jsx,ts,tsx}',
|
||||
'x-pack/plugins/**/*.{js,mjs,jsx,ts,tsx}',
|
||||
],
|
||||
exclude: extraExclude.concat(defaultExclude),
|
||||
};
|
||||
|
|
33
src/dev/code_coverage/nyc_config/nyc.server.config.js
Normal file
33
src/dev/code_coverage/nyc_config/nyc.server.config.js
Normal file
|
@ -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 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.
|
||||
*/
|
||||
|
||||
const path = require('path');
|
||||
|
||||
module.exports = {
|
||||
extends: '@istanbuljs/nyc-config-typescript',
|
||||
'report-dir': process.env.KIBANA_DIR
|
||||
? path.resolve(process.env.KIBANA_DIR, 'target/kibana-coverage/server')
|
||||
: 'target/kibana-coverage/server',
|
||||
reporter: ['json'],
|
||||
all: true,
|
||||
include: [
|
||||
'src/{core,plugins}/**/*.{js,mjs,jsx,ts,tsx}',
|
||||
'x-pack/plugins/**/*.{js,mjs,jsx,ts,tsx}',
|
||||
],
|
||||
exclude: [
|
||||
'**/{__jest__,__test__,__examples__,__fixtures__,__snapshots__,__stories__,*mock*,*storybook,target,types}/**/*',
|
||||
'**/{integration_tests,test,tests,test_helpers,test_data,test_samples,test_utils,test_utilities,*scripts}/**/*',
|
||||
'**/{*e2e*,fixtures,manual_tests,stub*}/**',
|
||||
'**/*mock*.{ts,tsx}',
|
||||
'**/*.test.{ts,tsx}',
|
||||
'**/*.spec.{ts,tsx}',
|
||||
'**/types.ts',
|
||||
'**/*.d.ts',
|
||||
'**/index.{js,ts,tsx}',
|
||||
],
|
||||
};
|
|
@ -5,7 +5,8 @@
|
|||
* 2.0.
|
||||
*/
|
||||
|
||||
const alwaysImportedTests = [
|
||||
require('../../src/setup_node_env');
|
||||
require('@kbn/test').runTestsCli([
|
||||
require.resolve('../test/functional/config.js'),
|
||||
require.resolve('../test/functional_basic/config.ts'),
|
||||
require.resolve('../test/security_solution_endpoint/config.ts'),
|
||||
|
@ -25,8 +26,6 @@ const alwaysImportedTests = [
|
|||
require.resolve('../test/usage_collection/config.ts'),
|
||||
require.resolve('../test/fleet_functional/config.ts'),
|
||||
require.resolve('../test/functional_synthetics/config.js'),
|
||||
];
|
||||
const onlyNotInCoverageTests = [
|
||||
require.resolve('../test/api_integration/config_security_basic.ts'),
|
||||
require.resolve('../test/api_integration/config_security_trial.ts'),
|
||||
require.resolve('../test/api_integration/config.ts'),
|
||||
|
@ -93,10 +92,4 @@ const onlyNotInCoverageTests = [
|
|||
require.resolve('../test/saved_object_tagging/api_integration/tagging_api/config.ts'),
|
||||
require.resolve('../test/examples/config.ts'),
|
||||
require.resolve('../test/functional_execution_context/config.ts'),
|
||||
];
|
||||
|
||||
require('../../src/setup_node_env');
|
||||
require('@kbn/test').runTestsCli([
|
||||
...alwaysImportedTests,
|
||||
...(!!process.env.CODE_COVERAGE ? [] : onlyNotInCoverageTests),
|
||||
]);
|
||||
|
|
|
@ -3195,6 +3195,13 @@
|
|||
js-yaml "^3.13.1"
|
||||
resolve-from "^5.0.0"
|
||||
|
||||
"@istanbuljs/nyc-config-typescript@^1.0.2":
|
||||
version "1.0.2"
|
||||
resolved "https://registry.yarnpkg.com/@istanbuljs/nyc-config-typescript/-/nyc-config-typescript-1.0.2.tgz#1f5235b28540a07219ae0dd42014912a0b19cf89"
|
||||
integrity sha512-iKGIyMoyJuFnJRSVTZ78POIRvNnwZaWIf8vG4ZS3rQq58MMDrqEX2nnzx0R28V2X8JvmKYiqY9FP2hlJsm8A0w==
|
||||
dependencies:
|
||||
"@istanbuljs/schema" "^0.1.2"
|
||||
|
||||
"@istanbuljs/schema@^0.1.2":
|
||||
version "0.1.2"
|
||||
resolved "https://registry.yarnpkg.com/@istanbuljs/schema/-/schema-0.1.2.tgz#26520bf09abe4a5644cd5414e37125a8954241dd"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue