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

test: introduce build tests #2975

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

Conversation

usualoma
Copy link
Member

We should test for the following aspects.

  • The product of the build does not contain unintended files (as a result of tree shaking).
  • The file size has not increased unintentionally.

As for the file size check, information could be added as a comment to each pull request (like coverage) in the future, but this pull request does not go that far.

This pull request will enable the following outputs to be obtained.

vitest -c .vitest.config/build.ts --run

 ✓ build_tests/build.test.ts (5)
   ✓ app-jsx (1)
     ✓ should not be included /jsx/dom/ in sources
   ✓ app-simple (2)
     ✓ should not be included http-exception in sources
     ✓ should not be included /jsx/ in sources
   ✓ jsx-dom-all (1)
     ✓ should not be included /helper/html in sources
   ✓ jsx-dom-simple (1)
     ✓ should not be included /jsx/base in sources

tsx ./build_tests/report.ts

app-jsx: 8.9 KiB
app-simple: 7.5 KiB
jsx-dom-all: 5.2 KiB
jsx-dom-simple: 3.5 KiB

The author should do the following, if applicable

  • Add tests
  • Run tests
  • bun run format:fix && bun run lint:fix to format the code
  • Add TSDoc/JSDoc to document the code

Copy link

codecov bot commented Jun 15, 2024

Codecov Report

Attention: Patch coverage is 0% with 118 lines in your changes missing coverage. Please review.

Project coverage is 93.90%. Comparing base (614dff0) to head (9483d22).

Files Patch % Lines
build_tests/src/jsx-dom-all.tsx 0.00% 32 Missing ⚠️
build_tests/src/jsx-dom-simple.tsx 0.00% 27 Missing ⚠️
build_tests/build.ts 0.00% 24 Missing ⚠️
build_tests/src/app-jsx.tsx 0.00% 15 Missing ⚠️
build_tests/report.ts 0.00% 12 Missing ⚠️
build_tests/src/app-simple.ts 0.00% 8 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #2975       /-   ##
==========================================
- Coverage   94.73%   93.90%   -0.84%     
==========================================
  Files         136      142        6     
  Lines       13335    13453      118     
  Branches     2251     2284       33     
==========================================
  Hits        12633    12633              
- Misses        702      820      118     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@usualoma
Copy link
Member Author

Errors in the test have been fixed. The content added by this pull request is excluded from the coverage measurement.

@yusukebe
Copy link
Member

Hi @usualoma

I also thought we had to have a measuring bundle/file size like yours. This seems great, but I have another idea. Please wait a bit until I show you it. Thanks!

@yusukebe
Copy link
Member

yusukebe commented Jun 21, 2024

Hey @usualoma

Regarding this matter, I think we should first monitor bundle sizes. Ideally, the CI will tell us the current bundle sizes and how they have increased from the main branch.

To do it, I found 3rd party library instead of implementing it by myself. There are several libraries, but the Size Limit seems to be best:

https://github.com/ai/size-limit

I've tried a little with CLI in my machine:

CleanShot 2024-06-21 at 23 47 57@2x

At first glance, I couldn't find a good way to integrate with GitHub Actions, though it has integrations with CircleCI, TravisCI, etc (perhaps we may have to use them to store the results?).

Anyway, we can use it or refer to it.

@Jayllyz
Copy link
Contributor

Jayllyz commented Jun 21, 2024

@yusukebe Regarding github action, I think this is what you are looking for : https://github.com/andresz1/size-limit-action

@yusukebe
Copy link
Member

@Jayllyz

Ohh, thanks. Can this compare the result of PR with the main's?

@Jayllyz
Copy link
Contributor

Jayllyz commented Jun 21, 2024

I don't think so.
A workaround would be to update the size limit during the release workflow. (I don't know if this is the best solution).

EDIT :
This one compare with the base branch.
https://github.com/preactjs/compressed-size-action

@usualoma
Copy link
Member Author

@yusukebe Thank you!
I too think "ai/size-limit" is cool.

Bundle size is certainly the most important.

I was hoping in addition to that to be able to check that 'certain modules are not included', as achieved in the pull request #2885. I think "a module is included that shouldn't be included" could be considered an obvious "bug".

However, it is expensive to keep track of 'modules that should not be included' in detail, and at the moment it would be fine to just use 'ai/size-limit'.

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.

None yet

3 participants