preactjs / compressed-size-action

GitHub Action that adds compressed size changes to your PRs.
https://github.com/marketplace/actions/compressed-size-action
MIT License
602 stars 84 forks source link

Allow running with multiple configurations #81

Closed sarayourfriend closed 2 months ago

sarayourfriend commented 2 years ago

Our application (https://github.com/WordPress/openverse-frontend) generates two distinct bundle groups during the build process, a "modern" and "universal" bundle (this is a concept we inherit by using Nuxt). We'd like to have separate compressed size checks for each of the two build types, however, when you try to run the compressed-size-check action twice in one PR, it overwrites the comment.

You can observe the issue in this PR: https://github.com/WordPress/openverse-frontend/pull/1378

If you check the edit history of the bot's comment, you can see that it overwrote itself.

Would y'all accept a PR to add an optional "key"/"id"/"comment-key" (names are hard) input that could be used to specify the comment to update?

Essentially my idea would be to update this conditional to additionally check for the new input in the body: https://github.com/preactjs/compressed-size-action/blob/master/src/index.js#L202-L205

For example, instead of just compressed-size-check being in the body, it could be compressed-size-check::${key} or something along those lines.

Thanks!

developit commented 2 years ago

A comment key configuration would be great! Your proposed implementation sounds right to me.

sarayourfriend commented 2 years ago

Hi @developit, I'm going to take a try implementing this today.

slorber commented 2 months ago

+1 for this

Docusaurus is going to ship experimental Rspack support to replace Webpack as an opt-in feature flag. We now need to monitor the build output of 2 different bundlers, and looks like we can't unfortunately.

The closed PR looked fine to me

sarayourfriend commented 2 months ago

I've reopened the PR. If you can help wrangle a review @slorber I am happy to make changes or otherwise make it possible to get that change committed.

rschristian commented 2 months ago

Supported via #82

Thanks again for the patience!

slorber commented 2 months ago

Awesome thanks

Do you plan to do a release soon? Or is there a way to use a "canary" action until then or something? 😄

rschristian commented 2 months ago

Will release soon-ish, in the next few days

sarayourfriend commented 2 months ago

Or is there a way to use a "canary" action until then or something? 😄

@slorber you can pin actions to any valid git ref on the main branch of the action repository, not just tags/releases. HEAD is at 4a35a533ce71b6edb72f2049f4c13d0611d17607 as of writing, so something like this would do the trick:

name: Compressed Size
on: [pull_request]
jobs:
  modern-bundle-size-check:
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v2
    - uses: preactjs/compressed-size-action@4a35a533ce71b6edb72f2049f4c13d0611d17607
      with:
        build-script: "build:modern"
        comment-key: modern
slorber commented 2 months ago

Thanks! Will try that asap.

rschristian commented 1 month ago

Just released as 2.7.0/v2