All Projects → chronotruck → webpack-stats-diff-action

chronotruck / webpack-stats-diff-action

Licence: other
Github action to print Webpack stat diffs in your pull-requests.

Programming Languages

javascript
184084 projects - #8 most used programming language
Dockerfile
14818 projects

Projects that are alternatives of or similar to webpack-stats-diff-action

qodana-action
⚙️ Scan your Java, Kotlin, PHP, Python, JavaScript, TypeScript projects at GitHub with Qodana
Stars: ✭ 112 (+286.21%)
Mutual labels:  actions
github-security-jira
Github Action for integrating Security Alerts with JIRA
Stars: ✭ 22 (-24.14%)
Mutual labels:  actions
deno-action
Github action for setup Deno
Stars: ✭ 24 (-17.24%)
Mutual labels:  actions
docker
Scripts to build and use docker images including GHDL
Stars: ✭ 27 (-6.9%)
Mutual labels:  actions
memer-action
A GitHub Action for Programmer Memes xD
Stars: ✭ 21 (-27.59%)
Mutual labels:  actions
build-godot-action
GitHub action that builds a Godot project for multiple platforms
Stars: ✭ 62 (+113.79%)
Mutual labels:  actions
denoflow
Configuration as Code, use YAML to write automated workflows that run on Deno, with any Deno modules, Typescript/Javascript codes
Stars: ✭ 143 (+393.1%)
Mutual labels:  actions
github-run-tests-action
mabl Github Actions implementation
Stars: ✭ 39 (+34.48%)
Mutual labels:  actions
bridgecrew-action
This Github Action runs Bridgecrew against an Infrastructure-as-Code repository. Bridgecrew performs static security analysis of Terraform & CloudFormation Infrastructure code.
Stars: ✭ 52 (+79.31%)
Mutual labels:  actions
Actions-OP
Autobuild openwrt using github actions | 自动编译你的专属openwrt固件
Stars: ✭ 19 (-34.48%)
Mutual labels:  actions
action-sync-node-meta
GitHub Action that syncs package.json with the repository metadata.
Stars: ✭ 25 (-13.79%)
Mutual labels:  actions
setup-ionic
Set up your GitHub Actions workflow with Cordova/Ionic environment
Stars: ✭ 23 (-20.69%)
Mutual labels:  actions
k-redux-factory
Factory of Redux reducers and their associated actions and selectors.
Stars: ✭ 18 (-37.93%)
Mutual labels:  actions
supply-chain-goat
Hands-on tutorials to learn about software supply chain security
Stars: ✭ 39 (+34.48%)
Mutual labels:  actions
npm-update-check-action
npm new package version check action for GitHub Actions.
Stars: ✭ 17 (-41.38%)
Mutual labels:  actions
setup-jfrog-cli
Set up JFrog CLI in your GitHub Actions workflow
Stars: ✭ 63 (+117.24%)
Mutual labels:  actions
github-act-runner
act as self-hosted runner
Stars: ✭ 68 (+134.48%)
Mutual labels:  actions
upx-action
Strips and runs upx on binaries
Stars: ✭ 17 (-41.38%)
Mutual labels:  actions
action
📦📊 GitHub Action to reports on the size of your npm package
Stars: ✭ 36 (+24.14%)
Mutual labels:  actions
Android-CICD
This repo demonstrates how to work on CI/CD for Mobile Apps 📱 using Github Actions 💊 + Firebase Distribution 🎉
Stars: ✭ 37 (+27.59%)
Mutual labels:  actions

Webpack Stats Diff

Creates a comment inside your Pull-Request with the difference between two Webpack stats files.

Comment demo

Usage

To use this Github action, in your steps you may have:

uses: chronotruck/[email protected]
with:
  base_stats_path: '/path/to/my/stats.json'
  head_stats_path: '/path/to/my/stats.json'
  token: ${{ secrets.GITHUB_TOKEN }}
  comment_title: 'Custom title'
  announcement_percentage_threshold_increase: 0
  announcement_percentage_threshold_decrease: -1.0

Inputs

Inputs Required Default Description
base_stats_path true Path to the Webpack generated "stats.json" file from the base branch.
head_stats_path true Path to the Webpack generated "stats.json" file from the head branch.
token true Github token so the package can publish a comment in the pull-request when the diff is ready.
comment_title false 'Bundle difference' Customized GitHub comment title.
announcement_percentage_threshold_increase false undefined Only announces bundle difference when the diff percentage increase exceeds this value. The value should be a positive numeric value (integer or floating point) or zero.
announcement_percentage_threshold_decrease false undefined Only announces bundle difference when the diff percentage decrease exceeds this value. The value should be a negative numeric value (integer or floating point) or zero.

Usage example

If you want to compare the bundle size difference between your base branch and your pull-request head branch.

We suppose that when you build your webpack app, a stats.json file is created. See https://github.com/webpack-contrib/webpack-bundle-analyzer for usage examples.

You'll need to build your Webpack bundle for the head branch:

on:
  pull_request:

jobs:
  build-head:
    name: 'Build head'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
    - name: Install dependencies
      run: npm ci
    - name: Build
      run: npm run build

Then we will use the Github Actions feature called "artifacts" to store that stats.json file.

    - name: Upload stats.json
      uses: actions/upload-artifact@v1
      with:
        name: head-stats
        path: ./dist/stats.json

Now you can do the exact same thing, but for the base branch. Note the checkout step!

  build-base:
    name: 'Build base'
    runs-on: ubuntu-latest
    steps:
    - uses: actions/checkout@v1
      with:
        ## Here we do not checkout the current branch, but we checkout the base branch.
        ref: ${{ github.base_ref }}
    - name: Install dependencies
      run: npm ci
    - name: Build
      run: npm run build
    - name: Upload stats.json
      uses: actions/upload-artifact@v1
      with:
        name: base-stats
        path: ./dist/stats.json

Now, in a new job we can retrieve both of our saved stats from the artifacts and use this action to compare them.

  compare:
    name: 'Compare base & head bundle sizes'
    runs-on: ubuntu-latest
    needs: [build-base, build-head]
    steps:
    - uses: actions/checkout@v1
    - name: Download base artifact
      uses: actions/download-artifact@v1
      with:
        name: base-stats
    - name: Download head artifact
      uses: actions/download-artifact@v1
      with:
        name: head-stats
    - name: Diff between base & head
      uses: chronotruck/[email protected]
      with:
        token: ${{ secrets.GITHUB_TOKEN }}
        base_stats_path: ./base-stats/stats.json
        head_stats_path: ./head-stats/stats.json

That's it! When the compare job will be executed, it will post a comment in the current pull-request with the difference between the two stats.json files.

License

This project is licensed under MIT License. Open source time proudly sponsored by Chronotruck.

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