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

Add support for size file path #34

Closed Klemensas closed 3 years ago

Klemensas commented 4 years ago

I have a case where I need additional auth to install dependencies and my size-limit configuration is not in the root path.

So to support such a case I've added additional inputs for base_size_path and head_size_path. These paths should lead to an already generated size limit report. Providing a path tries to load the file directly and skips the install, build, exec steps.

To use this you should do your setup in the action and just pass the paths, my usage looks something like this:

      ...
      - name: authenticate
        uses: webfactory/ssh-agent@v0.2.0
        with:
          ssh-private-key: ${{ secrets.PRIVATE_KEY}}
      - uses: actions/checkout@v2
        with:
          path: head
      - uses: actions/checkout@v2
        with:
          ref: ${{ github.base_ref }}
          path: base
      - name: head setup
        working-directory: ./head/client
        run: yarn install && yarn build && yarn --silent size --json > size.json
      - name: base setup
        working-directory: ./base/client
        run: yarn install && yarn build && yarn --silent size --json > size.json
      - name: size limit
        uses: vinted/size-limit-action@master
        with:
          github_token: ${{ secrets.GITHUB_TOKEN }}
          base_size_path: ./base/client/size.json
          head_size_path: ./head/client/size.json
andresz1 commented 4 years ago

Hi @Klemensas!

Thank you so much for opening the PR ❤️ . The changes look good but I have a few questions:

Thank you again. Happy to help you!

Klemensas commented 4 years ago

Could this install problem be solved using a .npmrc file?. Something like this:

Supporting npmrc would potentially solve the majority of such cases. But my situation might be a bit of an edge case, I'm pulling dependencies directly from a private git repo. Doing that over ssh and adding a key beforehand. At least I'm not aware of a way to have it work via npmrc. It could be solved by adding support here for pulling via ssh. But I figured it's best to just support providing the files instead of trying to support all edge cases since it's likely there'll be more.

How do you generate base and head, base must be generated performing a checkout to the ref. Are you doing this ? or you want to do something different?

Oh, sorry, I omitted the checkout part in my example above. Edited with that part. Basically I'm doing the setup in my action flow with the needed credentials.

andresz1 commented 4 years ago

Hi @Klemensas, thank you for the clarification! I think that would be nice to add a brief explanation of the two new optional action inputs to the README.md. What do you think?

Regards

Klemensas commented 4 years ago

For sure. Added a note, tried following the current format you have