-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(ci): add bundle size comparison and setup pnpm action
- Loading branch information
Showing
3 changed files
with
108 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
name: "Setup pnpm" | ||
description: "Install Node.js and pnpm and set up caching" | ||
inputs: | ||
node-version: | ||
description: "Version of Node.js to use" | ||
required: false | ||
default: "22" | ||
pnpm-version: | ||
description: "Version of pnpm to install" | ||
required: false | ||
default: "9.1.0" | ||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Setup Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
cache: "pnpm" | ||
|
||
- name: Enable Corepack | ||
run: corepack enable | ||
|
||
- name: Install pnpm | ||
run: corepack prepare pnpm@${{ inputs.pnpm-version }} --activate |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
on: | ||
pull_request: | ||
pull_request_target: | ||
|
||
jobs: | ||
# Build and upload stats for `head` | ||
build: | ||
name: 'Build and upload for ${{ matrix.target }}' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
strategy: | ||
matrix: | ||
target: [browser, node] # Runs for both browser and node bundles | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.event.pull_request.head.ref }} | ||
- name: Setup pnpm | ||
uses: .github/actions/setup-pnpm | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
- name: Build | ||
run: pnpm build:clean | ||
env: | ||
NODE_ENV: production | ||
- name: Upload stats.json | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: head-stats-${{ matrix.target }} | ||
path: .stats/bundle.${{ matrix.target }}.json | ||
|
||
# Build base stats for comparison | ||
build-base: | ||
name: 'Build base and upload for ${{ matrix.target }}' | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
strategy: | ||
matrix: | ||
target: [browser, node] | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ github.base_ref }} | ||
- name: Setup pnpm | ||
uses: .github/actions/setup-pnpm | ||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
- name: Build | ||
run: pnpm build:clean | ||
env: | ||
NODE_ENV: production | ||
- name: Upload stats.json | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: base-stats-${{ matrix.target }} | ||
path: .stats/bundle.${{ matrix.target }}.json | ||
|
||
# Compare base and head stats.json files | ||
compare: | ||
name: 'Compare base & head bundle sizes for ${{ matrix.target }}' | ||
runs-on: ubuntu-latest | ||
needs: [build, build-base] | ||
permissions: | ||
pull-requests: write | ||
strategy: | ||
matrix: | ||
target: [browser, node] | ||
steps: | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: head-stats-${{ matrix.target }} | ||
- uses: actions/download-artifact@v4 | ||
with: | ||
name: base-stats-${{ matrix.target }} | ||
- uses: twk3/[email protected] | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
current-stats-json-path: ./head-stats-${{ matrix.target }}/bundle.${{ matrix.target }}.json | ||
base-stats-json-path: ./base-stats-${{ matrix.target }}/bundle.${{ matrix.target }}.json |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters