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

Conversation

mshustov
Copy link
Contributor

@mshustov mshustov commented Mar 27, 2021

Summary

part of #90281
Cold run before: 7m 25sec
Cold run after: 5m 20sec

This PR adds a centralized tsconfig.projects.json for all the plugins and excludes all the test files from being compiled when building TS project references. Because of this, bootstrap does less work: test and test utils aren't imported outside of your plugin code, so no need to calculate their public interfaces. Mocks are the only exception to this rule. We can add them back to the incremental builds as soon as we unify the naming schema for mock files.
As a by-product of this work, we created a list of patterns for test file names. Establishing a repo-wide convention for test file names will allow us to have control over them (remove test files from the distributable version, for example) and understand whether changes in files might trigger downstream plugin rebuild (will be used by Bazel build toolchain).

Known problems:

  • you have to run script/type_check --project tsconfig.json to initiate type check for plugin tests.
  • scripts/check_ts_projects slowed down on my laptop from 20sec. to 3min.5sec due to a huge number of include and exclude patterns added in this PR. We're going to address the problem when we establish a convention for test-related files in order to reduce the number of pattern names.

@mshustov mshustov added chore v8.0.0 release_note:skip Skip the PR/issue when compiling release notes v7.13.0 labels Mar 27, 2021
@@ -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.


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

// @ts-expect-error
import { EuiFieldNumber, EuiFormRow, EuiFormRowDisplayKeys } from '@elastic/eui';
import { EuiFieldNumber, EuiFormRow } from '@elastic/eui';
import type { EuiFormRowDisplayKeys } from '@elastic/eui/src/components/form/form_row/form_row';
Copy link
Contributor Author

@mshustov mshustov Mar 29, 2021

Choose a reason for hiding this comment

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

EuiFormRowDisplayKeys used to be inferred as any, fixed

@@ -6,7 +6,7 @@
*/

import React from 'react';
import { renderWithRouter, shallowWithRouter } from '../../lib';
import { renderWithRouter, shallowWithRouter } from '../../lib/helper/enzyme_helpers';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm surprised the exclusion of test utils didn't affect the dist size.

@mshustov mshustov marked this pull request as ready for review March 29, 2021 17:01
@mshustov mshustov requested a review from a team as a code owner March 29, 2021 17:01
@mshustov mshustov requested a review from a team March 29, 2021 17:01
@mshustov mshustov requested a review from a team as a code owner March 29, 2021 17:01
Copy link
Member

@spong spong left a comment

Choose a reason for hiding this comment

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

Security Solution changes LGTM! Thanks! 🙂

Copy link
Contributor

@patrykkopycinski patrykkopycinski left a comment

Choose a reason for hiding this comment

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

Asset management LGTM

@mshustov
Copy link
Contributor Author

@elasticmachine merge upstream

@kibanamachine kibanamachine requested a review from a team March 30, 2021 19:07
Copy link
Contributor

@chrisronline chrisronline left a comment

Choose a reason for hiding this comment

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

LGTM!

@mshustov
Copy link
Contributor Author

@elasticmachine merge upstream

@mshustov
Copy link
Contributor Author

@elasticmachine merge upstream

Copy link
Contributor

@poffdeluxe poffdeluxe left a comment

Choose a reason for hiding this comment

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

Presentation team changes lgtm

@mshustov
Copy link
Contributor Author

mshustov commented Apr 1, 2021

@elasticmachine merge upstream

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Module Count

Fewer modules leads to a faster build time

id before after diff
expressions 151 150 -1
uptime 607 606 -1
total -2

Async chunks

Total size of all lazy-loaded chunks that will be downloaded as the user navigates the app

id before after diff
uptime 880.2KB 880.2KB -47.0B

Page load bundle

Size of the bundles that are downloaded on every page load. Target size is below 100kb

id before after diff
expressions 193.0KB 192.7KB -349.0B

History

To update your PR or re-run it, just comment with:
@elasticmachine merge upstream

@mshustov mshustov merged commit b6e582c into elastic:master Apr 1, 2021
@mshustov mshustov deleted the incremental-without-tests branch April 1, 2021 12:40
mshustov added a commit to mshustov/kibana that referenced this pull request Apr 1, 2021
* add base config for all the TS projects

* all the project use new tsconfig.project.json

* compile test files in the high-level tsconfig.json

* fix TS error in maps plugin

* fix TS error in infra plugin

* exclude mote test and test until folders

* uptime. do not import test code within prod code

* expressions. do not import test code within prod code

* data: export mocks from high level folder

* task_manager: comply with es client typings

* infra: remove unused enzyme_helpers

* check_ts_project requires "include" key

* ts_check should handle parent configs

* all ts configs should extend base one

* exclude test folders from plugins

* update patterns to fix ts_check errors

* Apply suggestions from code review

Co-authored-by: Constance <[email protected]>

* uptime: MountWithReduxProvider to test helpers

Co-authored-by: Constance <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
mshustov added a commit that referenced this pull request Apr 2, 2021
* TS Incremental build exclude test files (#95610)

* add base config for all the TS projects

* all the project use new tsconfig.project.json

* compile test files in the high-level tsconfig.json

* fix TS error in maps plugin

* fix TS error in infra plugin

* exclude mote test and test until folders

* uptime. do not import test code within prod code

* expressions. do not import test code within prod code

* data: export mocks from high level folder

* task_manager: comply with es client typings

* infra: remove unused enzyme_helpers

* check_ts_project requires "include" key

* ts_check should handle parent configs

* all ts configs should extend base one

* exclude test folders from plugins

* update patterns to fix ts_check errors

* Apply suggestions from code review

Co-authored-by: Constance <[email protected]>

* uptime: MountWithReduxProvider to test helpers

Co-authored-by: Constance <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>

* fix code plugin tsconfig

Co-authored-by: Constance <[email protected]>
Co-authored-by: Kibana Machine <[email protected]>
mshustov added a commit to mshustov/kibana that referenced this pull request Apr 5, 2021
spalger pushed a commit that referenced this pull request Apr 5, 2021
kibanamachine pushed a commit to kibanamachine/kibana that referenced this pull request Apr 5, 2021
mshustov added a commit to mshustov/kibana that referenced this pull request Apr 6, 2021
jloleysens added a commit to jloleysens/kibana that referenced this pull request Apr 6, 2021
…-nav

* 'master' of github.com:elastic/kibana: (106 commits)
  [Lens] don't use eui variables for zindex (elastic#96117)
  Remove /src/legacy (elastic#95510)
  skip flaky suite (elastic#95899)
  [Dashboard] Fix Lens and TSVB chart tooltip positioning relative to global headers (elastic#94247)
  fixes a skipped management x-pack test (elastic#96178)
  [App Search] API logs: Add log detail flyout (elastic#96162)
  [tech-debt] Remove defunct opacity parameters from EUI shadow functions (elastic#96191)
  Add Input Controls project configuration (elastic#96238)
  [file upload] document file upload privileges and provide actionable UI when failures occur (elastic#95883)
  Revert "TS Incremental build exclude test files (elastic#95610)" (elastic#96223)
  [App Search] Added Sample Response section to Result Settings (elastic#95971)
  [Maps] Safe-erase text-field (elastic#94873)
  [RAC][Alert Triage][TGrid] Update the Alerts Table (TGrid) API to implement `renderCellValue` (elastic#96098)
  [Maps] Enable all zoom levels for all users (elastic#96093)
  Use plugin version in its publicPath (elastic#95945)
  [Enterprise Search] Expose core.chrome.setIsVisible for use in Workplace Search (elastic#95984)
  [Workplace Search] Add sub nav and fix rendering bugs in Personal dashboard (elastic#96100)
  [OBS]home page is showing incorrect value of APM throughput (tpm) (elastic#95991)
  [Observability] Exploratory View initial skeleton (elastic#94426)
  [KQL] Fixed styles of KQL textarea for the K8 theme (elastic#96190)
  ...

# Conflicts:
#	x-pack/plugins/snapshot_restore/__jest__/client_integration/helpers/restore_snapshot.helpers.ts
mshustov added a commit that referenced this pull request Apr 6, 2021
…) (#96281)

* Revert "TS Incremental build exclude test files (#95610)" (#96223)

This reverts commit b6e582c.

* code: use base tsconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Feature:Drilldowns Embeddable panel Drilldowns Feature:Embedding Embedding content via iFrame Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) release_note:skip Skip the PR/issue when compiling release notes reverted Team:APM All issues that need APM UI Team support Team:Fleet Team label for Observability Data Collection Fleet team Team:Uptime - DEPRECATED Synthetics & RUM sub-team of Application Observability v7.13.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.