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

feat: Migrate bundle analysis services to Query V5 #3430

Open
wants to merge 22 commits into
base: main
Choose a base branch
from

Conversation

nicholas-codecov
Copy link
Contributor

@nicholas-codecov nicholas-codecov commented Oct 23, 2024

Description

This PR updates the hooks/services in the services/bundleAnalysis directory to Query V5. Some of these updates include moving fully over to the queryOptions API format that we will be moving towards, I didn't do this for all of these, as the PR would have grown significantly, and can be accomplished in a follow up PR.

Another change I made in this PR was the removal of the index.ts file from the services/bundleAnalysis directory. Some of the benefits of this are:

  • Removing barrel files (not good for bundling)
    • They will typically include all of the functions being exported as it struggles to properly tree shaking, especially if you're using export * from './...'
  • Explicit imports, if you cmd + click on the import you're taken to the function declaration not the index.ts file
  • Removes potential conflicting type imports with similarly named types

Ticket: codecov/engineering-team#2128

Notable Changes

  • Update all services in services/bundleAnalysis to Query V5
  • Update components using these hooks to use the newer version or use the queryOption API format
  • Update tests
    • Some of these were just updating missed MSW mocks or incorrect MSW mocks

Copy link

codecov bot commented Oct 23, 2024

Bundle Report

Changes will increase total bundle size by 24.36kB (0.14%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-production-system 5.76MB 11.09kB (0.19%) ⬆️
gazebo-production-system-esm 5.81MB 13.27kB (0.23%) ⬆️

@codecov-staging
Copy link

codecov-staging bot commented Oct 23, 2024

Bundle Report

Changes will increase total bundle size by 24.36kB (0.14%) ⬆️. This is within the configured threshold ✅

Detailed changes
Bundle name Size Change
gazebo-staging-system-esm 5.81MB 13.27kB (0.23%) ⬆️
gazebo-staging-system 5.76MB 11.09kB (0.19%) ⬆️

Copy link

codecov bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.08%. Comparing base (525e497) to head (6e8aa8a).

✅ All tests successful. No failed tests found.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3430      +/-   ##
==========================================
- Coverage   99.09%   99.08%   -0.01%     
==========================================
  Files         804      804              
  Lines       14187    14184       -3     
  Branches     4017     4009       -8     
==========================================
- Hits        14058    14054       -4     
- Misses        120      121       +1     
  Partials        9        9              
Files with missing lines Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <ø> (ø)
...dlesTab/BundleContent/AssetsTable/ModulesTable.tsx 100.00% <ø> (ø)
...ab/BundleContent/BundleChart/useBundleChartData.ts 100.00% <100.00%> (ø)
...epoPage/BundlesTab/BundleContent/BundleContent.tsx 100.00% <ø> (ø)
...sTab/BundleContent/BundleDetails/BundleDetails.tsx 100.00% <ø> (ø)
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/LoadSelector.tsx 100.00% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/TypeSelector.tsx 100.00% <100.00%> (ø)
...ces/bundleAnalysis/BranchBundlesNamesQueryOpts.tsx 100.00% <100.00%> (ø)
...rvices/bundleAnalysis/BundleTrendDataQueryOpts.tsx 100.00% <100.00%> (ø)
... and 4 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <100.00%> (ø)
Services 99.33% <100.00%> (-0.04%) ⬇️
Shared 99.74% <ø> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 525e497...6e8aa8a. Read the comment docs.

@codecov-qa
Copy link

codecov-qa bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.08%. Comparing base (525e497) to head (6e8aa8a).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3430      +/-   ##
==========================================
- Coverage   99.09%   99.08%   -0.01%     
==========================================
  Files         804      804              
  Lines       14187    14184       -3     
  Branches     4024     4016       -8     
==========================================
- Hits        14058    14054       -4     
- Misses        120      121       +1     
  Partials        9        9              
Files with missing lines Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <ø> (ø)
...dlesTab/BundleContent/AssetsTable/ModulesTable.tsx 100.00% <ø> (ø)
...ab/BundleContent/BundleChart/useBundleChartData.ts 100.00% <100.00%> (ø)
...epoPage/BundlesTab/BundleContent/BundleContent.tsx 100.00% <ø> (ø)
...sTab/BundleContent/BundleDetails/BundleDetails.tsx 100.00% <ø> (ø)
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/LoadSelector.tsx 100.00% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/TypeSelector.tsx 100.00% <100.00%> (ø)
...ces/bundleAnalysis/BranchBundlesNamesQueryOpts.tsx 100.00% <100.00%> (ø)
...rvices/bundleAnalysis/BundleTrendDataQueryOpts.tsx 100.00% <100.00%> (ø)
... and 4 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <100.00%> (ø)
Services 99.33% <100.00%> (-0.04%) ⬇️
Shared 99.74% <ø> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 525e497...6e8aa8a. Read the comment docs.

@codecov-notifications
Copy link

codecov-notifications bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3430      +/-   ##
==========================================
- Coverage   99.09%   99.08%   -0.01%     
==========================================
  Files         804      804              
  Lines       14187    14184       -3     
  Branches     4024     4016       -8     
==========================================
- Hits        14058    14054       -4     
- Misses        120      121       +1     
  Partials        9        9              
Files with missing lines Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <ø> (ø)
...dlesTab/BundleContent/AssetsTable/ModulesTable.tsx 100.00% <ø> (ø)
...ab/BundleContent/BundleChart/useBundleChartData.ts 100.00% <100.00%> (ø)
...epoPage/BundlesTab/BundleContent/BundleContent.tsx 100.00% <ø> (ø)
...sTab/BundleContent/BundleDetails/BundleDetails.tsx 100.00% <ø> (ø)
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/LoadSelector.tsx 100.00% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/TypeSelector.tsx 100.00% <100.00%> (ø)
...ces/bundleAnalysis/BranchBundlesNamesQueryOpts.tsx 100.00% <100.00%> (ø)
...rvices/bundleAnalysis/BundleTrendDataQueryOpts.tsx 100.00% <100.00%> (ø)
... and 4 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <100.00%> (ø)
Services 99.33% <100.00%> (-0.04%) ⬇️
Shared 99.74% <ø> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 525e497...6e8aa8a. Read the comment docs.

Copy link

codecov-public-qa bot commented Oct 23, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 99.08%. Comparing base (525e497) to head (6e8aa8a).

✅ All tests successful. No failed tests found.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #3430      +/-   ##
==========================================
- Coverage   99.09%   99.08%   -0.01%     
==========================================
  Files         804      804              
  Lines       14187    14184       -3     
  Branches     4017     4009       -8     
==========================================
- Hits        14058    14054       -4     
- Misses        120      121       +1     
  Partials        9        9              
Files Coverage Δ
...ndlesTab/BundleContent/AssetsTable/AssetsTable.tsx 100.00% <ø> (ø)
...dlesTab/BundleContent/AssetsTable/ModulesTable.tsx 100.00% <ø> (ø)
...ab/BundleContent/BundleChart/useBundleChartData.ts 100.00% <100.00%> (ø)
...epoPage/BundlesTab/BundleContent/BundleContent.tsx 100.00% <ø> (ø)
...sTab/BundleContent/BundleDetails/BundleDetails.tsx 100.00% <ø> (ø)
...b/BundleContent/BundleSelection/BundleSelector.tsx 93.93% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/LoadSelector.tsx 100.00% <100.00%> (ø)
...Tab/BundleContent/BundleSelection/TypeSelector.tsx 100.00% <100.00%> (ø)
...ces/bundleAnalysis/BranchBundlesNamesQueryOpts.tsx 100.00% <100.00%> (ø)
...rvices/bundleAnalysis/BundleTrendDataQueryOpts.tsx 100.00% <100.00%> (ø)
... and 4 more
Components Coverage Δ
Assets 100.00% <ø> (ø)
Layouts 100.00% <ø> (ø)
Pages 98.80% <100.00%> (ø)
Services 99.33% <100.00%> (-0.04%) ⬇️
Shared 99.74% <ø> (ø)
UI 99.15% <ø> (ø)

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 525e497...6e8aa8a. Read the comment docs.

@codecov-releaser
Copy link
Contributor

codecov-releaser commented Oct 23, 2024

✅ Deploy preview for gazebo ready!

Previews expire after 1 month automatically.

Storybook

Commit Created Cloud Enterprise
e987f6a Wed, 23 Oct 2024 18:32:16 GMT Expired Expired
3e11000 Wed, 30 Oct 2024 12:23:46 GMT Expired Expired
9db3a96 Wed, 30 Oct 2024 12:43:44 GMT Expired Expired
8c56994 Fri, 01 Nov 2024 13:28:51 GMT Expired Expired
142724e Fri, 01 Nov 2024 15:30:51 GMT Expired Expired
fce8138 Fri, 01 Nov 2024 15:50:52 GMT Expired Expired
6e8aa8a Fri, 08 Nov 2024 13:47:43 GMT Cloud Enterprise

@nicholas-codecov nicholas-codecov force-pushed the gh-eng-2128-migrate-bundle-analysis-services-to-V5 branch from a3af02a to 3e11000 Compare October 30, 2024 12:17
@nicholas-codecov nicholas-codecov changed the title feat: Migrate bundle analysis services to v5 feat: Migrate bundle analysis services to Query V5 Nov 1, 2024
@@ -161,7 +161,7 @@ const createColumns = (totalBundleSize: number | null) => [
/>{' '}
<ChangeOverTime
change={value?.change?.size.uncompress}
hasMeasurements={value.measurements.length > 0 ?? false}
hasMeasurements={value.measurements.length > 0}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was something that Vite kept bringing up as an optimization so finally threw it in.

@nicholas-codecov nicholas-codecov force-pushed the gh-eng-2128-migrate-bundle-analysis-services-to-V5 branch from 833a3d0 to d36c7dc Compare November 1, 2024 12:55
@nicholas-codecov nicholas-codecov marked this pull request as ready for review November 1, 2024 13:02
provider: string
owner: string
repo: string
branch?: string
branch: string | null | undefined
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this instead of branch?: string | null?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is an attempt to be a bit more explicit with function args and their types. ? represents an optional argument so TS doesn't complain if you never provide it. However, if you type it as above, TS will complain if you don't provide the value:

Screenshot 2024-11-01 at 12 17 48

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh so you just want this to always be called with a branch param?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I would like all the arguments provided, this still makes allowances however if branch is undefined.

Copy link
Contributor

Choose a reason for hiding this comment

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

Ok cool beans

@@ -266,32 +271,34 @@ export const useBundleAssets = ({
dateBefore,
dateAfter,
filters,
assetsAfter: pageParam,
assetsAfter,
Copy link
Contributor

Choose a reason for hiding this comment

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

Does this mean that assetsAfter=null doesn't get along well with the query? I'd think it might be worthwhile updating this API side if not. Would rather do that than do the few lines above on every infinite query.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sorry, null works fine, and I'm updating things rn to be set to null instead of undefined. The type for pageParam is inferred through the initialPageParam so we have to assign it to a string for the remaining cursors to keep the types happy.

Copy link
Contributor

Choose a reason for hiding this comment

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

If null is fine, doesn't the old code work? assetsAfter: pageParam

Copy link
Contributor

Choose a reason for hiding this comment

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

I may be misunderstanding though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Soooo just did some testing, and the API is okay if just an empty string is provided ... so I'll get rid of all of this.

Copy link
Contributor

Choose a reason for hiding this comment

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

NICE

Copy link
Contributor

@spalmurray-codecov spalmurray-codecov left a comment

Choose a reason for hiding this comment

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

Looks good. Honestly thought the transition would require more changes, glad to see it's not so bad. Requesting changes bc I want to talk through my comments and make sure we're aligned 🫡

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants