andresz1 / size-limit-action

Compare the real cost to run your JS app or lib to keep good performance in every pull request
ISC License
451 stars 84 forks source link

Fail gracefully on initial addition #33

Open Klemensas opened 4 years ago

Klemensas commented 4 years ago

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 ```sh /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

andresz1 commented 4 years ago

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.

mrlubos commented 4 years ago

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?

mrlubos commented 4 years ago

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

Klemensas commented 4 years ago

@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.

mrlubos commented 4 years ago

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!

misha-erm commented 3 months ago

merged size-limit config but still have this error ( are there any other steps except merging ".size-limit.json" to main branch? I'm using file preset

Also the strange part is that it tries to run install and build even with "script_step: build" arg

image

UPDATE: my problem was caused by monorepo setup. Forgot to pass "directory" arg