All Projects → pkg-size → action

pkg-size / action

Licence: MIT License
📦📊 GitHub Action to reports on the size of your npm package

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to action

action-autotag
Automatically generate a new tag when the manifest file (package.json, Dockerfile, custom file, etc) version changes.
Stars: ✭ 45 (+25%)
Mutual labels:  package, actions, github-actions
jacoco-report
Github action that publishes the JaCoCo report as a comment in the Pull Request
Stars: ✭ 31 (-13.89%)
Mutual labels:  actions, report, github-actions
version-check
An action that allows you to check whether your npm package version has been updated
Stars: ✭ 65 (+80.56%)
Mutual labels:  package, actions
autoupdate
A GitHub Action that auto-updates pull requests branches, whenever changes are pushed to their destination branch.
Stars: ✭ 70 (+94.44%)
Mutual labels:  pull-requests, github-actions
npm-update-check-action
npm new package version check action for GitHub Actions.
Stars: ✭ 17 (-52.78%)
Mutual labels:  actions, github-actions
deno-action
Github action for setup Deno
Stars: ✭ 24 (-33.33%)
Mutual labels:  actions, github-actions
overview
Automate your workflows with GitHub actions for MATLAB.
Stars: ✭ 40 (+11.11%)
Mutual labels:  actions, github-actions
ghaction-import-gpg
GitHub Action to easily import a GPG key
Stars: ✭ 161 (+347.22%)
Mutual labels:  actions, github-actions
qodana-action
⚙️ Scan your Java, Kotlin, PHP, Python, JavaScript, TypeScript projects at GitHub with Qodana
Stars: ✭ 112 (+211.11%)
Mutual labels:  actions, github-actions
action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
Stars: ✭ 25 (-30.56%)
Mutual labels:  actions, github-actions
memer-action
A GitHub Action for Programmer Memes xD
Stars: ✭ 21 (-41.67%)
Mutual labels:  actions, pull-requests
Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps 📱 using Github Actions 💊 + Firebase Distribution 🎉
Stars: ✭ 37 (+2.78%)
Mutual labels:  actions, github-actions
pscale-workflow-helper-scripts
Workflows and helper scripts around the PlanetScale DB workflow to automate database branch creation, association, update and merge directly out of your pull/merge request or favourite CI/CD.
Stars: ✭ 42 (+16.67%)
Mutual labels:  actions, pull-requests
pull-request-comment-branch
A GitHub Action to get the head ref and sha of a pull request comment
Stars: ✭ 21 (-41.67%)
Mutual labels:  pull-requests, github-actions
gha
🔧 Test your GitHub Actions workflow locally.
Stars: ✭ 53 (+47.22%)
Mutual labels:  actions, github-actions
actions-pixela
GitHub Actions for Pixela (a-know/pi) - a-know/pi Setup Action. Linux (Ubuntu), macOS, and Windows are supported.
Stars: ✭ 12 (-66.67%)
Mutual labels:  actions, github-actions
github-act-runner
act as self-hosted runner
Stars: ✭ 68 (+88.89%)
Mutual labels:  actions, github-actions
actions-sms
Send an SMS through GitHub Actions
Stars: ✭ 108 (+200%)
Mutual labels:  actions, github-actions
action-label-syncer
GitHub Action to sync GitHub labels in the declarative way
Stars: ✭ 138 (+283.33%)
Mutual labels:  actions, github-actions
ghaction-upx
GitHub Action for UPX, the Ultimate Packer for eXecutables
Stars: ✭ 27 (-25%)
Mutual labels:  actions, github-actions

pkg-size action

pkg-size-action is a GitHub Action for getting automated size reports on your pull-requests.

If you like this project, please star it & follow me to see what other cool projects I'm working on! ❤️

⭐️ Features

  • 📦 Auto-detects npm distribution assets using pkg-size
  • 🔥 Node.js package installer agnostic Supports auto lock-file installs from npm, yarn, pnpm
  • 🗜 See compression sizes Option to show uncompressed, Gzip, and Brotli size
  • ⚙️ Configurable Change the build command. Customize reports formats. Filter out unwanted files.

🚦 3-step setup

  1. Create the following file in your repo: .github/workflows/package-size-report.yml:

    name: Package Size Report
    
    on:
      pull_request:
        branches: [ master, develop ] # ⬅ Add other branches you want size checks on
    
    jobs:
      pkg-size-report:
        name: Package Size Report
        runs-on: ubuntu-latest
    
        steps:
          - name: Checkout
            uses: actions/checkout@v2
    
          - name: Setup Node.js
            uses: actions/setup-node@v2
            with:
              node-version: '14' # ⬅ Specify a version of Node.js to build your app
    
          - name: Package size report
            uses: pkg-size/action@v1
            env:
              GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
  2. Try making a PR against one of the designated branches.

  3. 📊 Get the pkg-size report as a comment on the PR!

    You'll see a comment on your PR reporting the package size regression. This comment will be automatically updated as you push changes to your PR.

👨🏻‍🏫 Examples

Set a custom command to build

The default behavior detects whether npm run build exists. If not, it assumes your repo doesn't have a build step and won't try to install dependencies.

If your repo has a different build script, specify one with build-command. Disable building by passing in false.

name: Package Size Report

on:
  pull_request:
    branches: [ master, develop ]

jobs:
  pkg-size-report:
    name: Package Size Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          build-command: npm run prod-build # ⬅ Set a different build script here
Specify node version

By default, ubuntu-latest has the latest version of node available. If your repo needs to specify an exact version of node, you can use the actions/setup-node action.

name: Package Size Report

on:
  pull_request:
    branches: [ master, develop ]

jobs:
  pkg-size-report:
    name: Package Size Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Use Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14.4.0'

      - name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Hiding source-map changes from report

Source-maps might add unnecessary noise to your report. Hide them using a glob.

name: Package Size Report

on:
  pull_request:
    branches: [ master, develop ]

jobs:
  pkg-size-report:
    name: Package Size Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          hide-files: '*.{js,css}.map' # Set a glob to filter out irrelevant files
Show unchanged & changed files in the same table

The default behavior hides unchanged files in a collapsible. To include unchanged files in the visible table, set unchanged-files to show.

name: Package Size Report

on:
  pull_request:
    branches: [ master, develop ]

jobs:
  pkg-size-report:
    name: Package Size Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          unchanged-files: show # ⬅ Make unchanged files appear in the same table
Use Brotli size

Use display-size: brotli to only show Brotli compression size. Use a comma separated list to show multiple sizes.

name: Package Size Report

on:
  pull_request:
    branches: [ master, develop ]

jobs:
  pkg-size-report:
    name: Package Size Report
    runs-on: ubuntu-latest

    steps:
      - name: Checkout
        uses: actions/checkout@v2

      - name: Setup Node.js
        uses: actions/setup-node@v2
        with:
          node-version: '14'

      - name: Package size report
        uses: pkg-size/action@v1
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
        with:
          display-size: uncompressed, brotli # ⬅ Comma separated list of sizes to show

⚙️ Options

build-command

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.

comment-report

Default: true

Possible values: true, false

Whether to comment the build size report on the PR or not.

mode

Default: regression

Possible values: regression, head-only

Sets the size report mode:

  • regression: Builds both head and base branch and compares difference.
  • head-only: Only builds and reports on head branch.

display-size

Default: uncompressed

Possible values: uncompressed, gzip, brotli

Which size to show. Pass in a comma-separated list for multiple.

unchanged-files

Default: collapse

Possible values: show, collapse, hide

Whether to show unchanged files.

sort-by

Default: delta

Possible values: delta, headSize, baseSize, path

Which property to sort the files list by. delta is the size difference.

sort-order

Default: desc

Possible values: desc, asc

Files list sort order.

hide-files

Glob pattern to hide files. For example, if you want to hide source-maps:

hide-files: '*.{js,css}.map'

💁‍♀️ FAQ

Can I use this for non-published projects?

Yes. All you need to do is specify distribution files in the files array in package.json.

How is this different from size-limit-action?

size-limit-action approaches size monitoring from a budgeting standpoint, and has features such as rejecting PRs if the proposed changes are too large. It requires specifying each distribution file and doesn't show compression sizes.

pkg-size-action accepts that size increases can be often warranted if the feature/bug-fix is important, and approaches monitoring from a purely informational standpoint. It encourages being size conscious without blocking your changes. pkg-size-action can also automatically detect distribution files based on your package.json configuration.

💼 License

MIT © Hiroki Osame

Logo made by Freepik

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].