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

[build_ts_refs] improve caches, allow building a subset of projects #107981

Merged

Conversation

spalger
Copy link
Contributor

@spalger spalger commented Aug 9, 2021

node scripts/build_ts_refs has a major flaw in the way it handles caches: we extract caches to the output directory whenever we're building on a new mergeBase and in doing so set the modified times of the output files to the moment the cache is extracted, but tsc will only build types for a project if the output files are older than the input files.

To fix this we need to make sure that the output files do not have newer timestamps than the input files, as long as the input files have changes since the cache was created. To accomplish this we use git diff --name-only {sha-cache-was-made-on} to get the list of files which have updated, map those to TS projects, and then set the modified time of the files from those caches to new Date(0). Doing this forces TS to use the .tsbuildinfo file to determine which files have changed and how to update the types, which is a little more than twice as fast as running a fresh build without caches in my limited testing.

This PR also migrates all TS projects to be "composite" and "incremental", which means that all references outside of the project are pointing to another composite project, which builds its own types, and build info is written to a .tsbuildinfo file to support incrementally updating types based on specific file changes. This structure was implemented in most of the TS projects in the repo but not completed until this PR. Now any project that isn't built by bazel extends tsconfig.base.json and is composite+incremental. Any project that is built in bazel uses the tsconfig.bazel.json base (or the tsconfig.browser_bazel.json variant) and is not composite or incremental.

This PR integrates #107804 without requiring users to commit the updated file, and instead allows users to put // SELF MANAGED at the top of the file to control which projects we build types for with scripts/build_ts_refs. Some teams have had success limiting the project scope, and it seems like we should be able to support that usage pattern better this way.

Finally, this PR reworks scripts/type_check to only check non-composite projects as build_ts_refs is executed before it runs and validates the types of all composite projects, so type_check only needs to check the non-composite projects. Also updated the script to not use listr so that it renders better.

@spalger spalger added release_note:skip Skip the PR/issue when compiling release notes Team:Operations Team label for Operations Team v7.14.0 v7.15.0 v8.0.0 labels Aug 11, 2021
@spalger spalger marked this pull request as ready for review August 11, 2021 00:49
@spalger spalger requested review from vigneshshanmugam and a team as code owners August 11, 2021 00:49
@spalger spalger requested a review from a team August 11, 2021 00:49
@spalger spalger requested review from a team as code owners August 11, 2021 00:49
@spalger spalger requested a review from a team August 11, 2021 00:49
@spalger spalger requested review from a team as code owners August 11, 2021 00:49
@spalger spalger requested a review from a team August 11, 2021 00:49
@spalger spalger requested review from a team as code owners August 11, 2021 00:49
@spalger spalger requested a review from a team August 11, 2021 00:49
@spalger spalger requested a review from a team as a code owner August 11, 2021 00:49
@elasticmachine
Copy link
Contributor

Pinging @elastic/kibana-operations (Team:Operations)

@spalger
Copy link
Contributor Author

spalger commented Aug 11, 2021

Sorry for the massive number of teams pinged, this PR edits a ton of TS config files so I'm not going to wait for all reviewers as we know these updates are going to work.

@kibanamachine
Copy link
Contributor

💚 Build Succeeded

Metrics [docs]

Async chunks

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

id before after diff
inputControlVis 83.3KB 83.2KB -125.0B

Page load bundle

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

id before after diff
inputControlVis 9.8KB 9.7KB -27.0B

History

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

Copy link
Member

@ppisljar ppisljar left a comment

Choose a reason for hiding this comment

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

appservices changes lgtm

@botelastic botelastic bot added Feature:Drilldowns Embeddable panel Drilldowns Feature:Embedding Embedding content via iFrame Feature:ExpressionLanguage Interpreter expression language (aka canvas pipeline) Team:APM All issues that need APM UI Team support Team:Fleet Team label for Observability Data Collection Fleet team labels Aug 11, 2021
@elasticmachine
Copy link
Contributor

Pinging @elastic/apm-ui (Team:apm)

@elasticmachine
Copy link
Contributor

Pinging @elastic/fleet (Team:Fleet)

@spalger spalger merged commit c0395c9 into elastic:master Aug 11, 2021
spalger pushed a commit to spalger/kibana that referenced this pull request Aug 11, 2021
…lastic#107981)

* [build_ts_refs] improve caches, allow building a subset of projects

* cleanup project def script and update refs in type check script

* rename browser_bazel config to avoid kebab-case

* remove execInProjects() helper

* list references for tsconfig.types.json for api-extractor workload

* disable composite features of tsconfig.types.json for api-extractor

* set declaration: true to avoid weird debug error

* fix jest tests

Co-authored-by: spalger <[email protected]>
# Conflicts:
#	.gitignore
#	examples/hello_world/tsconfig.json
#	tsconfig.json
#	tsconfig.refs.json
@spalger spalger removed the v7.14.0 label Aug 11, 2021
@spalger spalger deleted the implement/intentionally-expire-extracted-caches branch August 11, 2021 05:26
spalger pushed a commit that referenced this pull request Aug 11, 2021
…107981) (#108139)

* [build_ts_refs] improve caches, allow building a subset of projects

* cleanup project def script and update refs in type check script

* rename browser_bazel config to avoid kebab-case

* remove execInProjects() helper

* list references for tsconfig.types.json for api-extractor workload

* disable composite features of tsconfig.types.json for api-extractor

* set declaration: true to avoid weird debug error

* fix jest tests

Co-authored-by: spalger <[email protected]>
# Conflicts:
#	.gitignore
#	examples/hello_world/tsconfig.json
#	tsconfig.json
#	tsconfig.refs.json

Co-authored-by: Kibana Machine <[email protected]>
jloleysens added a commit to jloleysens/kibana that referenced this pull request Aug 11, 2021
…-png-pdf-report-type

* 'master' of github.com:elastic/kibana: (101 commits)
  [ML] APM Latency Correlations: Field/value candidates prioritization (elastic#107370)
  [Reporting] Add lenience to a test on the order of asserted logs (elastic#108135)
  [Lens] fix do not submit invalid query in filtered metric (elastic#107542)
  skip flaky test (elastic#108043)
  fix newly introduced type error (elastic#107593)
  [Reporting] server side code clean up (elastic#106940)
  [build_ts_refs] improve caches, allow building a subset of projects (elastic#107981)
  [APM] Add new ftr_e2e to kibana CI and remove current e2e tests. (elastic#107593)
  add manage rules link to alerts dropdown (elastic#107950)
  [ML] Enable Index data visualizer document count chart to update time range query (elastic#106438)
  [Security Solutions][Detection Engine] Fixes "undefined" crash for author field by adding a migration for it (elastic#107230)
  [Actions UI] Fixed Jira Api token label. (elastic#107776)
  [Alerting UI] Fixed display permissions for edit/delete buttons when user has read only access. (elastic#107996)
  [Maps] fix code owners (elastic#108106)
  Update EMS landing page url (elastic#108102)
  Do not render page header for loading domains (elastic#108078)
  Update dependency @elastic/charts to v33.2.2 (elastic#107939)
  [APM] Display throughput as tps (instead of tpm) when bucket size < 60 seconds (elastic#107850)
  [Fleet] Fix all category count (elastic#108089)
  [Security Solution][Bug] - Disable alert table RBAC until fields sorted (elastic#108034)
  ...

# Conflicts:
#	x-pack/plugins/reporting/server/export_types/common/generate_png.ts
#	x-pack/plugins/reporting/server/lib/screenshots/index.ts
#	x-pack/plugins/reporting/server/lib/screenshots/observable.test.ts
#	x-pack/plugins/reporting/server/lib/screenshots/observable.ts
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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 Team:APM All issues that need APM UI Team support Team:Fleet Team label for Observability Data Collection Fleet team Team:Operations Team label for Operations Team v7.15.0 v8.0.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants