pkg-size-action is a GitHub Action for getting automated size reports on your PRs.
This action is a fork of pkg-size-action by Hiroki Osame and is used in the AWS Lambda Powertools for TypeScript repo.
- Create the following file in your repo:
.github/workflows/measure-packages-size.yml
:
name: Measure packages size
on:
workflow_dispatch:
inputs:
prNumber:
description: "PR Number"
required: true
jobs:
measure-utils-sizes:
runs-on: ubuntu-latest
env:
NODE_ENV: dev
PR_NUMBER: ${{ inputs.prNumber }}
steps:
- name: Checkout Repo
uses: actions/checkout@v3
- name: Packages size report
uses: flochaz/pkg-size-action@v1.2.15
with:
build-command: mkdir dist && npm run package -w packages/logger -w packages/tracer -w packages/metrics && npm run package-bundle -w packages/logger -w packages/tracer -w packages/metrics && bash -c "mv ./packages/*/dist/* dist/" && ls dist
dist-directory: /dist
pr-number: ${{ inputs.prNumber }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Default: npm run build
if it exists in package.json
, otherwise false
.
Command to build the package and produce distribution files with. Pass in false
to disable attempting to produce a build.
Default: true
Possible values: true
, false
Whether to comment the build size report on the PR or not.
Default: regression
Possible values: regression
, head-only
Sets the size report mode:
regression
: Builds bothhead
andbase
branch and compares difference.head-only
: Only builds and reports onhead
branch.
Default: uncompressed
Possible values: uncompressed
, gzip
, brotli
Which size to show. Pass in a comma-separated list for multiple.
Default: collapse
Possible values: show
, collapse
, hide
Whether to show unchanged files.
Default: delta
Possible values: delta
, headSize
, baseSize
, path
Which property to sort the files list by. delta
is the size difference.
Default: desc
Possible values: desc
, asc
Files list sort order.
Glob pattern to hide files. For example, if you want to hide source-maps:
hide-files: "*.{js,css}.map"
Credits for the original action to Hiroki Osame.
This library is licensed under the MIT-0 License. See the LICENSE file.