Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TS Incremental build exclude test files #95610

Merged
merged 23 commits into from
Apr 1, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
f7f6837
add base config for all the TS projects
mshustov Mar 26, 2021
c25a34c
all the project use new tsconfig.project.json
mshustov Mar 26, 2021
500bb42
compile test files in the high-level tsconfig.json
mshustov Mar 26, 2021
70f6c22
fix TS error in maps plugin
mshustov Mar 27, 2021
34ca2d6
fix TS error in infra plugin
mshustov Mar 27, 2021
e3764cf
exclude mote test and test until folders
mshustov Mar 27, 2021
7fdd474
uptime. do not import test code within prod code
mshustov Mar 27, 2021
9482cf4
expressions. do not import test code within prod code
mshustov Mar 27, 2021
c92c3ce
data: export mocks from high level folder
mshustov Mar 28, 2021
5e3d093
Merge branch 'master' into incremental-without-tests
mshustov Mar 28, 2021
a7ab3c5
task_manager: comply with es client typings
mshustov Mar 28, 2021
cec2e04
infra: remove unused enzyme_helpers
mshustov Mar 29, 2021
46aeb89
check_ts_project requires "include" key
mshustov Mar 29, 2021
4849b49
ts_check should handle parent configs
mshustov Mar 29, 2021
fc814d0
all ts configs should extend base one
mshustov Mar 29, 2021
dee62cc
exclude test folders from plugins
mshustov Mar 29, 2021
89912bf
update patterns to fix ts_check errors
mshustov Mar 29, 2021
d90fbe2
Apply suggestions from code review
mshustov Mar 30, 2021
04ca8da
uptime: MountWithReduxProvider to test helpers
mshustov Mar 30, 2021
6651b69
Merge branch 'master' into incremental-without-tests
kibanamachine Mar 30, 2021
e7a00fc
Merge branch 'master' into incremental-without-tests
kibanamachine Mar 31, 2021
d9fdd3f
Merge branch 'master' into incremental-without-tests
kibanamachine Mar 31, 2021
f26066a
Merge branch 'master' into incremental-without-tests
kibanamachine Apr 1, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/kbn-storybook/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.json",
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"incremental": false,
"outDir": "target",
Expand Down
2 changes: 1 addition & 1 deletion src/core/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../tsconfig.base.json",
"extends": "../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
37 changes: 32 additions & 5 deletions src/dev/typescript/project.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
*/

import { basename, dirname, relative, resolve } from 'path';

import { memoize } from 'lodash';
import { IMinimatch, Minimatch } from 'minimatch';
import { REPO_ROOT } from '@kbn/utils';

Expand All @@ -26,6 +26,10 @@ function testMatchers(matchers: IMinimatch[], path: string) {
return matchers.some((matcher) => matcher.match(path));
}

const parentProjectFactory = memoize(function (parentConfigPath: string) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

all the plugin config extend tsconfig.project.json, no need to recreate it 123 times.

return new Project(parentConfigPath);
});

export class Project {
public directory: string;
public name: string;
Expand All @@ -34,22 +38,24 @@ export class Project {

private readonly include: IMinimatch[];
private readonly exclude: IMinimatch[];
private readonly parent?: Project;

constructor(
public tsConfigPath: string,
options: { name?: string; disableTypeCheck?: boolean } = {}
) {
this.config = parseTsConfig(tsConfigPath);

const { files, include, exclude = [] } = this.config as {
const { files, include, exclude = [], extends: extendsPath } = this.config as {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

extends in a reserved word

files?: string[];
include?: string[];
exclude?: string[];
extends?: string;
};

if (files || !include) {
throw new Error(
'tsconfig.json files in the Kibana repo must use "include" keys and not "files"'
`[${tsConfigPath}]: tsconfig.json files in the Kibana repo must use "include" keys and not "files"`
);
}

Expand All @@ -58,9 +64,30 @@ export class Project {
this.name = options.name || relative(REPO_ROOT, this.directory) || basename(this.directory);
this.include = makeMatchers(this.directory, include);
this.exclude = makeMatchers(this.directory, exclude);

if (extendsPath !== undefined) {
const parentConfigPath = resolve(this.directory, extendsPath);
this.parent = parentProjectFactory(parentConfigPath);
}
}

public isAbsolutePathSelected(path: string): boolean {
return this.isExcluded(path) ? false : this.isIncluded(path);
}

public isAbsolutePathSelected(path: string) {
return testMatchers(this.exclude, path) ? false : testMatchers(this.include, path);
public isExcluded(path: string): boolean {
if (testMatchers(this.exclude, path)) return true;
if (this.parent) {
return this.parent.isExcluded(path);
}
return false;
}

public isIncluded(path: string): boolean {
if (testMatchers(this.include, path)) return true;
if (this.parent) {
return this.parent.isIncluded(path);
}
return false;
}
}
2 changes: 1 addition & 1 deletion src/plugins/advanced_settings/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/apm_oss/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/bfetch/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/charts/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/console/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dashboard/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { createMockContext } from '../../../../expressions/common';
import { createMockContext } from '../../../../expressions/common/mocks';
import { functionWrapper } from './utils';
import { existsFilterFunction } from './exists_filter';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { createMockContext } from '../../../../expressions/common';
import { createMockContext } from '../../../../expressions/common/mocks';
import { functionWrapper } from './utils';
import { kibanaFilterFunction } from './kibana_filter';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { createMockContext } from '../../../../expressions/common';
import { createMockContext } from '../../../../expressions/common/mocks';
import { functionWrapper } from './utils';
import { phraseFilterFunction } from './phrase_filter';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
* Side Public License, v 1.
*/

import { createMockContext } from '../../../../expressions/common';
import { createMockContext } from '../../../../expressions/common/mocks';
import { functionWrapper } from './utils';
import { rangeFilterFunction } from './range_filter';

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/dev_tools/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/discover/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/embeddable/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/es_ui_shared/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 2 additions & 0 deletions src/plugins/expressions/common/mocks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,5 @@ export const createMockExecutionContext = <ExtraContext extends object = object>
...extraContext,
};
};

export { createMockContext } from './util/test_utils';
1 change: 0 additions & 1 deletion src/plugins/expressions/common/util/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ export * from './create_error';
export * from './get_by_alias';
export * from './tables_adapter';
export * from './expressions_inspector_adapter';
export * from './test_utils';
2 changes: 1 addition & 1 deletion src/plugins/expressions/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/home/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/index_pattern_field_editor/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/index_pattern_management/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/input_control_vis/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/inspector/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana_legacy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana_overview/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana_react/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana_usage_collection/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/kibana_utils/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/legacy_export/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/management/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/maps_ems/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/maps_legacy/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/navigation/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/newsfeed/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/presentation_util/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/region_map/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/saved_objects/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/saved_objects_management/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/saved_objects_tagging_oss/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/security_oss/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/share/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/spaces_oss/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/telemetry/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"extends": "../../../tsconfig.base.json",
"extends": "../../../tsconfig.project.json",
"compilerOptions": {
"composite": true,
"outDir": "./target/types",
Expand Down
Loading