Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 18 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

A GitHub action that reports changes in compressed file sizes on your PRs.

- Automatically uses `yarn`, `pnpm`, `bun`, or `npm ci` when lockfiles are present
- Bring your own toolchain by using clean, install, and build scripts
Comment thread
unrevised6419 marked this conversation as resolved.
Outdated
- Builds your PR, then builds the target and compares between the two
- Doesn't upload anything or rely on centralized storage
- Supports [custom build scripts](#customizing-the-build) and [file patterns](#customizing-the-list-of-files)
Expand All @@ -26,9 +26,16 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
with:
install-script: npm ci
build-script: npm run build
clean-script: npm run clean
```

> [!IMPORTANT]
> When using custom `build-script`, `install-script`, or `clean-script` options, ensure that the specified scripts exist in both the current branch (PR) and the base branch (target). The action will fail if a script is missing from either branch.

Comment thread
unrevised6419 marked this conversation as resolved.
### Customizing the Installation

By default, `compressed-size-action` will install dependencies according to which lockfiles are present, if any. However, if you need to run a different installation command, you can pass a custom script to do so. For example, to use `npm ci` with the `--workspace` option:
Expand All @@ -44,7 +51,7 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
Comment thread
unrevised6419 marked this conversation as resolved.
Outdated
with:
+ install-script: "npm ci --workspace=packages/my-subpackage"
```
Expand Down Expand Up @@ -80,9 +87,9 @@ jobs:

steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
with:
+ build-script: "ci"
+ build-script: "npm run build"
```

#### Clean up state between builds
Expand All @@ -97,10 +104,10 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
+ clean-script: "clean"
+ clean-script: "npm run clean"
```

```jsonc
Expand All @@ -127,7 +134,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
with:
+ order-by: "Size:desc"
```
Expand All @@ -146,7 +153,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
with:
+ pattern: "./build-output/**/*.{js,css,html,json}"
+ exclude: "{./build-output/manifest.json,**/*.map,**/node_modules/**}"
Expand Down Expand Up @@ -211,7 +218,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
with:
build-script: "build:modern"
+ comment-key: modern
Expand All @@ -220,7 +227,7 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: preactjs/compressed-size-action@v2
- uses: preactjs/compressed-size-action@v3
with:
build-script: "build:legacy"
+ comment-key: legacy
Expand Down
7 changes: 3 additions & 4 deletions action.yml
Comment thread
unrevised6419 marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,12 @@ inputs:
required: false
default: ${{ github.token }}
clean-script:
description: 'An npm-script that cleans/resets state between branch builds'
description: 'A script that cleans/resets state between branch builds'
install-script:
required: false
Comment thread
rschristian marked this conversation as resolved.
description: 'Custom installation script to run to set up the dependencies in your project'
build-script:
description: 'The npm-script to run that builds your project'
default: 'build'
required: true
description: 'The script to run that builds your project'
compression:
description: 'The compression algorithm to use: "gzip" or "brotli"'
show-total:
Expand Down
2 changes: 1 addition & 1 deletion index.js

Large diffs are not rendered by default.

6 changes: 4 additions & 2 deletions jsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
{
"compilerOptions": {
"target": "ESNext",
"module": "ESNext",
"module": "nodenext",
Comment thread
unrevised6419 marked this conversation as resolved.
Outdated
"moduleResolution": "NodeNext",
"allowJs": true,
"checkJs": true,
"resolveJsonModule": true,
"noEmit": true
"noEmit": true,
"strict": true,
"useUnknownInCatchVariables": false
Comment thread
unrevised6419 marked this conversation as resolved.
Outdated
}
}
Loading