Display bundle size changes in comments on opened PRs (#1205)

This commit is contained in:
Jed Fox
2023-06-27 12:46:27 -04:00
committed by GitHub
parent aa503d6a74
commit 081c9d068f
14 changed files with 220 additions and 31 deletions

View File

@@ -12,7 +12,6 @@ on:
branches:
- master
pull_request:
branches: '*'
jobs:
api:
@@ -60,27 +59,63 @@ jobs:
with:
name: actual-web
path: packages/desktop-client/build
electron:
# As electron builds take longer, we only run them in master.
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- name: Build Electron
run: ./bin/package-electron
- name: Upload Build
- name: Upload Build Stats
uses: actions/upload-artifact@v3
with:
name: actual-electron-${{ matrix.os }}
path: |
packages/desktop-electron/dist/*.dmg
packages/desktop-electron/dist/*.exe
packages/desktop-electron/dist/*.AppImage
name: build-stats
path: packages/desktop-client/build-stats
size-compare:
runs-on: ubuntu-latest
needs: [web]
if: github.event_name == 'pull_request'
permissions:
pull-requests: write
steps:
- name: Wait for ${{github.base_ref}} build to succeed
uses: fountainhead/action-wait-for-check@v1.1.0
id: master-build
with:
token: ${{ secrets.GITHUB_TOKEN }}
checkName: web
ref: ${{github.base_ref}}
- name: Report build failure
if: steps.master-build.outputs.conclusion == 'failure'
run: |
echo "Build failed on ${{github.base_ref}}"
exit 1
- name: Download build artifact from ${{github.base_ref}}
uses: dawidd6/action-download-artifact@v2
id: pr-build
with:
branch: ${{github.base_ref}}
workflow: build.yml
name: build-stats
path: base
- name: Download build artifact from PR
uses: actions/download-artifact@v2
with:
name: build-stats
path: head
- name: Strip content hashes from stats files
run: |
sed -i -E 's/\.[0-9a-f]{8,}\././g' ./head/*.json
sed -i -E 's/\.[0-9a-f]{8,}\././g' ./base/*.json
- uses: github/webpack-bundlesize-compare-action@v1.8.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
current-stats-json-path: ./head/desktop-client-stats.json
base-stats-json-path: ./base/desktop-client-stats.json
title: desktop-client
- uses: github/webpack-bundlesize-compare-action@v1.8.1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
current-stats-json-path: ./head/loot-core-stats.json
base-stats-json-path: ./base/loot-core-stats.json
title: loot-core

View File

@@ -5,7 +5,6 @@ on:
branches:
- master
pull_request:
branches: '*'
jobs:
lint:

View File

@@ -4,7 +4,6 @@ on:
push:
branches: [master]
pull_request:
branches: [master]
schedule:
- cron: '23 11 * * 6'

38
.github/workflows/electron.yml vendored Normal file
View File

@@ -0,0 +1,38 @@
name: Electron
defaults:
run:
shell: bash
env:
CI: true
on:
push:
branches:
- master
pull_request:
jobs:
build:
strategy:
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v3
- name: Set up environment
uses: ./.github/actions/setup
- name: Build Electron
run: ./bin/package-electron
- name: Upload Build
uses: actions/upload-artifact@v3
with:
name: actual-electron-${{ matrix.os }}
path: |
packages/desktop-electron/dist/*.dmg
packages/desktop-electron/dist/*.exe
packages/desktop-electron/dist/*.AppImage

View File

@@ -2,7 +2,6 @@ name: Release notes
on:
pull_request:
branches: '*'
jobs:
release-notes:

View File

@@ -9,6 +9,7 @@ test-results
# production
build
build-stats
# misc
.DS_Store

View File

@@ -15,3 +15,8 @@ export REACT_APP_BACKEND_WORKER_HASH=`ls "$ROOT"/../public/kcab/kcab.worker.*.js
export REACT_APP_ACTUAL_VERSION="$VERSION"
yarn build
rm -fr build-stats
mkdir build-stats
mv build/kcab/stats.json build-stats/loot-core-stats.json
mv build/stats.json build-stats/desktop-client-stats.json

View File

@@ -1,11 +1,13 @@
const path = require('path');
const {
addWebpackPlugin,
addWebpackResolve,
babelInclude,
override,
overrideDevServer,
babelInclude,
} = require('customize-cra');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
if (process.env.CI) {
process.env.DISABLE_ESLINT_PLUGIN = 'true';
@@ -27,6 +29,12 @@ module.exports = {
'.tsx',
],
}),
addWebpackPlugin(
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
}),
),
config => {
config.cache = false;
return config;

View File

@@ -21,6 +21,7 @@
"@types/react-dom": "^18.2.1",
"@types/react-modal": "^3.16.0",
"@types/react-router-dom": "^5.3.3",
"@types/webpack-bundle-analyzer": "^4.6.0",
"cross-env": "^7.0.3",
"customize-cra": "^1.0.0",
"date-fns": "^2.29.3",
@@ -49,7 +50,8 @@
"react-virtualized-auto-sizer": "^1.0.2",
"redux": "^4.0.5",
"redux-thunk": "^2.3.0",
"victory": "^36.6.8"
"victory": "^36.6.8",
"webpack-bundle-analyzer": "^4.9.0"
},
"scripts": {
"start": "cross-env PORT=3001 react-app-rewired start",

View File

@@ -51,6 +51,7 @@
"@types/jlongster__sql.js": "npm:@types/sql.js@latest",
"@types/pegjs": "^0.10.3",
"@types/webpack": "^5.28.0",
"@types/webpack-bundle-analyzer": "^4.6.0",
"adm-zip": "^0.5.9",
"babel-loader": "^9.1.2",
"buffer": "^6.0.3",
@@ -75,6 +76,7 @@
"typescript": "^4.6.4",
"uuid": "3.3.2",
"webpack": "^5.86.0",
"webpack-bundle-analyzer": "^4.9.0",
"webpack-cli": "^5.1.3",
"ws": "^4.1.0",
"yargs": "^9.0.1"

View File

@@ -1,6 +1,7 @@
let path = require('path');
let webpack = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
/** @type {webpack.Configuration} */
module.exports = {
@@ -85,5 +86,9 @@ module.exports = {
new webpack.IgnorePlugin({
resourceRegExp: /worker_threads|original-fs/,
}),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
}),
],
};

View File

@@ -1,6 +1,7 @@
let path = require('path');
let webpack = require('webpack');
const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer');
let browser = require('./webpack.browser.config');
@@ -39,6 +40,10 @@ module.exports = {
new webpack.IgnorePlugin({
resourceRegExp: /original-fs/,
}),
new BundleAnalyzerPlugin({
analyzerMode: 'disabled',
generateStatsFile: true,
}),
],
node: {
__dirname: false,

View File

@@ -0,0 +1,6 @@
---
category: Maintenance
authors: [j-f1]
---
Display bundle size changes in comments on opened PRs

View File

@@ -84,6 +84,7 @@ __metadata:
"@types/react-dom": ^18.2.1
"@types/react-modal": ^3.16.0
"@types/react-router-dom": ^5.3.3
"@types/webpack-bundle-analyzer": ^4.6.0
cross-env: ^7.0.3
customize-cra: ^1.0.0
date-fns: ^2.29.3
@@ -113,6 +114,7 @@ __metadata:
redux: ^4.0.5
redux-thunk: ^2.3.0
victory: ^36.6.8
webpack-bundle-analyzer: ^4.9.0
languageName: unknown
linkType: soft
@@ -1964,7 +1966,7 @@ __metadata:
languageName: node
linkType: hard
"@discoveryjs/json-ext@npm:^0.5.0":
"@discoveryjs/json-ext@npm:0.5.7, @discoveryjs/json-ext@npm:^0.5.0":
version: 0.5.7
resolution: "@discoveryjs/json-ext@npm:0.5.7"
checksum: 2176d301cc258ea5c2324402997cf8134ebb212469c0d397591636cea8d3c02f2b3cf9fd58dcb748c7a0dade77ebdc1b10284fa63e608c033a1db52fddc69918
@@ -2801,6 +2803,13 @@ __metadata:
languageName: node
linkType: hard
"@polka/url@npm:^1.0.0-next.20":
version: 1.0.0-next.21
resolution: "@polka/url@npm:1.0.0-next.21"
checksum: c7654046d38984257dd639eab3dc770d1b0340916097b2fac03ce5d23506ada684e05574a69b255c32ea6a144a957c8cd84264159b545fca031c772289d88788
languageName: node
linkType: hard
"@reach/auto-id@npm:0.18.0":
version: 0.18.0
resolution: "@reach/auto-id@npm:0.18.0"
@@ -4467,6 +4476,17 @@ __metadata:
languageName: node
linkType: hard
"@types/webpack-bundle-analyzer@npm:^4.6.0":
version: 4.6.0
resolution: "@types/webpack-bundle-analyzer@npm:4.6.0"
dependencies:
"@types/node": "*"
tapable: ^2.2.0
webpack: ^5
checksum: 1cd5baa621a1dbe820bacf981d6e48f3423b733fb5e33c1356347e73d5e3e880ae6ebacf8f43d9e47e135d3ed2653ec5e40e12c6ce187f2eb3f548d9c949f6aa
languageName: node
linkType: hard
"@types/webpack@npm:^5.28.0":
version: 5.28.1
resolution: "@types/webpack@npm:5.28.1"
@@ -4940,7 +4960,7 @@ __metadata:
languageName: node
linkType: hard
"acorn-walk@npm:^8.1.1":
"acorn-walk@npm:^8.0.0, acorn-walk@npm:^8.1.1":
version: 8.2.0
resolution: "acorn-walk@npm:8.2.0"
checksum: 1715e76c01dd7b2d4ca472f9c58968516a4899378a63ad5b6c2d668bba8da21a71976c14ec5f5b75f887b6317c4ae0b897ab141c831d741dc76024d8745f1ad1
@@ -4956,6 +4976,15 @@ __metadata:
languageName: node
linkType: hard
"acorn@npm:^8.0.4":
version: 8.9.0
resolution: "acorn@npm:8.9.0"
bin:
acorn: bin/acorn
checksum: 25dfb94952386ecfb847e61934de04a4e7c2dc21c2e700fc4e2ef27ce78cb717700c4c4f279cd630bb4774948633c3859fc16063ec8573bda4568e0a312e6744
languageName: node
linkType: hard
"acorn@npm:^8.2.4, acorn@npm:^8.4.1, acorn@npm:^8.5.0, acorn@npm:^8.7.1, acorn@npm:^8.8.0":
version: 8.8.2
resolution: "acorn@npm:8.8.2"
@@ -12307,6 +12336,7 @@ __metadata:
"@types/jlongster__sql.js": "npm:@types/sql.js@latest"
"@types/pegjs": ^0.10.3
"@types/webpack": ^5.28.0
"@types/webpack-bundle-analyzer": ^4.6.0
absurd-sql: 0.0.53
adm-zip: ^0.5.9
assert: ^2.0.0
@@ -12346,6 +12376,7 @@ __metadata:
typescript: ^4.6.4
uuid: 3.3.2
webpack: ^5.86.0
webpack-bundle-analyzer: ^4.9.0
webpack-cli: ^5.1.3
ws: ^4.1.0
yargs: ^9.0.1
@@ -12839,6 +12870,13 @@ __metadata:
languageName: node
linkType: hard
"mrmime@npm:^1.0.0":
version: 1.0.1
resolution: "mrmime@npm:1.0.1"
checksum: cc979da44bbbffebaa8eaf7a45117e851f2d4cb46a3ada6ceb78130466a04c15a0de9a9ce1c8b8ba6f6e1b8618866b1352992bf1757d241c0ddca558b9f28a77
languageName: node
linkType: hard
"ms@npm:2.0.0":
version: 2.0.0
resolution: "ms@npm:2.0.0"
@@ -13374,6 +13412,15 @@ __metadata:
languageName: node
linkType: hard
"opener@npm:^1.5.2":
version: 1.5.2
resolution: "opener@npm:1.5.2"
bin:
opener: bin/opener-bin.js
checksum: 33b620c0d53d5b883f2abc6687dd1c5fd394d270dbe33a6356f2d71e0a2ec85b100d5bac94694198ccf5c30d592da863b2292c5539009c715a9c80c697b4f6cc
languageName: node
linkType: hard
"optionator@npm:^0.8.1":
version: 0.8.3
resolution: "optionator@npm:0.8.3"
@@ -16308,6 +16355,17 @@ __metadata:
languageName: node
linkType: hard
"sirv@npm:^1.0.7":
version: 1.0.19
resolution: "sirv@npm:1.0.19"
dependencies:
"@polka/url": ^1.0.0-next.20
mrmime: ^1.0.0
totalist: ^1.0.0
checksum: c943cfc61baf85f05f125451796212ec35d4377af4da90ae8ec1fa23e6d7b0b4d9c74a8fbf65af83c94e669e88a09dc6451ba99154235eead4393c10dda5b07c
languageName: node
linkType: hard
"sisteransi@npm:^1.0.5":
version: 1.0.5
resolution: "sisteransi@npm:1.0.5"
@@ -17327,6 +17385,13 @@ __metadata:
languageName: node
linkType: hard
"totalist@npm:^1.0.0":
version: 1.1.0
resolution: "totalist@npm:1.1.0"
checksum: dfab80c7104a1d170adc8c18782d6c04b7df08352dec452191208c66395f7ef2af7537ddfa2cf1decbdcfab1a47afbbf0dec6543ea191da98c1c6e1599f86adc
languageName: node
linkType: hard
"tough-cookie@npm:^4.0.0":
version: 4.1.2
resolution: "tough-cookie@npm:4.1.2"
@@ -18503,6 +18568,26 @@ __metadata:
languageName: node
linkType: hard
"webpack-bundle-analyzer@npm:^4.9.0":
version: 4.9.0
resolution: "webpack-bundle-analyzer@npm:4.9.0"
dependencies:
"@discoveryjs/json-ext": 0.5.7
acorn: ^8.0.4
acorn-walk: ^8.0.0
chalk: ^4.1.0
commander: ^7.2.0
gzip-size: ^6.0.0
lodash: ^4.17.20
opener: ^1.5.2
sirv: ^1.0.7
ws: ^7.3.1
bin:
webpack-bundle-analyzer: lib/bin/analyzer.js
checksum: e439aea4e88e18bfdc16eb69782c1bb17b2e581905a5cfa8d34058dc6677f6e202f896189268e58b49fa14ae12f5ef4c25cdca9f98f3de7e6699ac62def2f0af
languageName: node
linkType: hard
"webpack-cli@npm:^5.1.3":
version: 5.1.3
resolution: "webpack-cli@npm:5.1.3"
@@ -19164,7 +19249,7 @@ __metadata:
languageName: node
linkType: hard
"ws@npm:^7.4.6":
"ws@npm:^7.3.1, ws@npm:^7.4.6":
version: 7.5.9
resolution: "ws@npm:7.5.9"
peerDependencies: