ci(type-checking): run type-checking-frontend hook sequentially #32323
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
ci(type-checking): run type-checking-frontend hook sequentially
SUMMARY
Run
type-checking-frontend
hook sequentially by settingrequire_serial: true
.By default, pre-commit runs each hook in parallel with different set of matched files:
pre-commit-config.yaml
check-type.js
git status On branch ci/type-checking Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: .pre-commit-config.yaml modified: scripts/check-type.js modified: superset-frontend/package-lock.json modified: superset-frontend/src/dashboard/actions/dashboardInfo.ts modified: superset-frontend/src/dashboard/actions/datasources.ts modified: superset-frontend/src/dashboard/actions/nativeFilters.ts modified: superset-frontend/src/dashboard/actions/sliceEntities.ts modified: superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.test.tsx modified: superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.tsx modified: superset-frontend/src/dashboard/components/AddSliceCard/index.ts modified: superset-frontend/src/dashboard/components/AnchorLink/AnchorLink.stories.tsx modified: superset-frontend/src/dashboard/components/AnchorLink/AnchorLink.test.tsx modified: superset-frontend/src/dashboard/components/AnchorLink/index.tsx modified: superset-frontend/src/dashboard/components/BuilderComponentPane/BuilderComponentPane.test.tsx modified: superset-frontend/src/dashboard/components/BuilderComponentPane/index.tsx modified: superset-frontend/src/dashboard/components/CssEditor/index.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardWrapper.test.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardWrapper.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/state.ts modified: superset-frontend/src/explore/actions/datasourcesActions.ts modified: superset-frontend/src/explore/components/controls/ViewQuery.tsx new file: superset-frontend/src/types/jest-styled-components.d.ts modified: superset-frontend/tsconfig.json
The script is run 6 times. Which means that
tsc
will be run 6 times.Potential issues:
tsc
incurs a startup overhead. Runningtsc
with different set of files multiple times in parallel may actually be slower than running it once with all the files.tsc
multiple times in parallel may show the same error multiple times in the console.pre-commit-config.yaml
git status On branch ci/type-checking Changes to be committed: (use "git restore --staged <file>..." to unstage) modified: superset-frontend/package-lock.json modified: superset-frontend/src/dashboard/actions/dashboardInfo.ts modified: superset-frontend/src/dashboard/actions/datasources.ts modified: superset-frontend/src/dashboard/actions/nativeFilters.ts modified: superset-frontend/src/dashboard/actions/sliceEntities.ts modified: superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.test.tsx modified: superset-frontend/src/dashboard/components/AddSliceCard/AddSliceCard.tsx modified: superset-frontend/src/dashboard/components/AddSliceCard/index.ts modified: superset-frontend/src/dashboard/components/AnchorLink/AnchorLink.stories.tsx modified: superset-frontend/src/dashboard/components/AnchorLink/AnchorLink.test.tsx modified: superset-frontend/src/dashboard/components/AnchorLink/index.tsx modified: superset-frontend/src/dashboard/components/BuilderComponentPane/BuilderComponentPane.test.tsx modified: superset-frontend/src/dashboard/components/BuilderComponentPane/index.tsx modified: superset-frontend/src/dashboard/components/CssEditor/index.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.test.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardBuilder.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardContainer.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardWrapper.test.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/DashboardWrapper.tsx modified: superset-frontend/src/dashboard/components/DashboardBuilder/state.ts modified: superset-frontend/src/explore/actions/datasourcesActions.ts modified: superset-frontend/src/explore/components/controls/ViewQuery.tsx new file: superset-frontend/src/types/jest-styled-components.d.ts modified: superset-frontend/tsconfig.json
In parallel:

Sequential:
add
require_serial: true
totype-checking-frontend
hookNOTES
pre-commit run type-checking-frontend --all-files
is slower than runningnpm run type
.This is expected, due to command line length limits, it's not feasible to pass all files to a single command invocation. Instead, pre-commit splits the files into manageable chunks and processes them. (mentioned in this issue)
And
superset-frontend
has over 2,000 files, running all files will cause the hook to split the files into two chunks(according to test), and run sequentially. This makes sense when you compare the execution time, which is around 1 minute and 30 seconds."Additionally, in the CI pipeline, type-checking is performed using
npm run type
, notpre-commit run --all-files
. (refer to.github/workflows/pre-commit.yml
and.github/workflows/superset-frontend.yml
)BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
TESTING INSTRUCTIONS
ADDITIONAL INFORMATION