andresz1 / size-limit-action

Compare the real cost to run your JS app or lib to keep good performance in every pull request

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Fail gracefully on initial addition

Klemensas opened this issue · comments

When creating a PR that adds the size-limit dependency and action initially the action will always fail due to it trying to compare with the base branch that hasn't size-limit added yet.

Failure log
/usr/local/bin/npx size-limit --json
npx: installed 99 in 5.742s
Install Size Limit preset depends on type of the project

For application, where you send JS bundle directly to users
  yarn add --dev @size-limit/preset-app

For frameworks, components and big libraries
  yarn add --dev @size-limit/preset-big-lib

For small (< 10 KB) libraries
  yarn add --dev @size-limit/preset-small-lib

Check out docs for more complicated cases
  https://github.com/ai/size-limit/

You need to add size-limit dependency: yarn add --dev size-limit
Error parsing size-limit output. The output should be a json.
##[error]Unexpected end of JSON input

Instead of failing it could just give a warning about not being setup yet and pass

Hi @Klemensas, you are right, cool idea! Thank you so much for opening this issue. I'll label this as good first issue in case someone wants to contribute if not I'll try to fix it myself.

commented

I managed to figure out what's going on in the initial error (You need to add size-limit dependency) and merged size-limit first. I added the size-limit Github Action in a separate pull request and it fails with the second error (Error parsing size-limit output). It's not obvious to me how I can bypass this error, can you advise please @andresz1?

commented

@Klemensas How did you manage to get past this error?

@mrlubos maybe you're basing your PR on a branch that doesn't have size-limit?

Once I've merged the size-limit stuff to my base branch everything worked fine.

commented

Ahhh, I think I've got it. Not only do I need size-limit dependency, I also need to merge the config first. This is currently in my pull request, will split it into another one. That should do it, thanks for pointing it out!