Skip to content

Commit b2e81e0

Browse files
committed
feat(ci): add bundle size comparison and setup pnpm action
1 parent 7949c46 commit b2e81e0

File tree

8 files changed

+155
-104
lines changed

8 files changed

+155
-104
lines changed

.github/actions/setup/action.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: "Setup"
2+
description: "Install Node.js and pnpm and set up caching"
3+
inputs:
4+
node-version:
5+
description: "Version of Node.js to use"
6+
required: false
7+
default: "22"
8+
pnpm-version:
9+
description: "Version of pnpm to install"
10+
required: false
11+
default: "9.1.0"
12+
env:
13+
description: "Build Environment"
14+
required: false
15+
default: "production"
16+
runs:
17+
using: "composite"
18+
steps:
19+
- uses: pnpm/action-setup@v4
20+
name: Install pnpm
21+
with:
22+
version: ${{ inputs.pnpm-version }}
23+
run_install: true
24+
25+
- name: Install Node.js
26+
uses: actions/setup-node@v4
27+
with:
28+
node-version: ${{ inputs.node-version }}
29+
cache: 'pnpm'
30+
31+
# Build the SDK
32+
- name: Project build
33+
shell: bash
34+
run: pnpm build:clean
35+
env:
36+
NODE_ENV: ${{ inputs.node_env }}
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
name: 'Bundle Sizes'
2+
3+
on:
4+
pull_request:
5+
pull_request_target:
6+
7+
jobs:
8+
# Build and upload stats for `head`
9+
build:
10+
name: 'Upload ${{ matrix.target }} stats for ${{ github.event.pull_request.head.ref }}'
11+
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read
14+
strategy:
15+
matrix:
16+
target: [browser, node] # Runs for both browser and node bundles
17+
steps:
18+
- uses: actions/checkout@v4
19+
with:
20+
ref: ${{ github.event.pull_request.head.ref }}
21+
22+
- name: Setup pnpm
23+
uses: ./.github/actions/setup
24+
25+
- name: Upload stats.json
26+
uses: actions/upload-artifact@v4
27+
with:
28+
name: head-stats-${{ matrix.target }}
29+
path: .stats/bundle.${{ matrix.target }}.json
30+
31+
# Build base stats for comparison
32+
build-base:
33+
name: 'Upload ${{ matrix.target }} stats for ${{ github.base_ref }}'
34+
runs-on: ubuntu-latest
35+
permissions:
36+
contents: read
37+
strategy:
38+
matrix:
39+
target: [browser, node]
40+
steps:
41+
- uses: actions/checkout@v4
42+
with:
43+
ref: ${{ github.base_ref }}
44+
45+
- name: Setup pnpm
46+
uses: ./.github/actions/setup
47+
48+
- name: Upload stats.json
49+
uses: actions/upload-artifact@v4
50+
with:
51+
name: base-stats-${{ matrix.target }}
52+
path: .stats/bundle.${{ matrix.target }}.json
53+
54+
# Compare base and head stats.json files
55+
compare:
56+
name: 'Bundle sizes comparison for ${{ matrix.target }}'
57+
runs-on: ubuntu-latest
58+
needs: [build, build-base]
59+
permissions:
60+
pull-requests: write
61+
strategy:
62+
matrix:
63+
target: [browser, node]
64+
steps:
65+
- uses: actions/download-artifact@v4
66+
with:
67+
name: head-stats-${{ matrix.target }}
68+
69+
- uses: actions/download-artifact@v4
70+
with:
71+
name: base-stats-${{ matrix.target }}
72+
73+
- uses: twk3/rollup-size-compare-action@v1.0.0
74+
with:
75+
github-token: ${{ secrets.GITHUB_TOKEN }}
76+
current-stats-json-path: ./head-stats-${{ matrix.target }}/bundle.${{ matrix.target }}.json
77+
base-stats-json-path: ./base-stats-${{ matrix.target }}/bundle.${{ matrix.target }}.json

.github/workflows/commitlint.yml

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,14 @@ jobs:
1414
commitlint:
1515
runs-on: ubuntu-22.04
1616
steps:
17-
- uses: actions/checkout@v4
18-
with:
19-
fetch-depth: 0
20-
- uses: actions/setup-node@v4
21-
with:
22-
node-version: 20
23-
- uses: pnpm/action-setup@v4
24-
name: Install pnpm
17+
- name: Checkout
18+
uses: actions/checkout@v4
19+
20+
- uses: ./.github/actions/setup
21+
name: Setup
2522
with:
26-
version: 9.1.0
27-
run_install: true
23+
node-version: ${{ matrix.node }}
24+
2825
- name: Validate PR commits with commitlint
2926
if: github.event_name == 'pull_request'
3027
run: pnpx commitlint --from ${{ github.event.pull_request.base.sha }} --to ${{ github.event.pull_request.head.sha }} --verbose
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ jobs:
1212
cron-tasks:
1313
runs-on: ubuntu-latest
1414
steps:
15-
- name: check for inactive issues that can't be reproduced
15+
- name: Check for inactive issues that can't be reproduced
1616
uses: actions-cool/issues-helper@v3
1717
with:
1818
actions: 'close-issues'
@@ -25,6 +25,6 @@ jobs:
2525
2626
As we have not received any new or updated information to reproduce this issue in the last 14 days we are marking this issue as closed. Should you have new information please feel free to respond and we will consider reopening it.
2727
28-
If anyone else has updated information for this issue, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have. If you have questions please refer to the [contributor's guide](https://github.com/strapi/strapi/blob/main/CONTRIBUTING.md#reporting-an-issue) on opening issues.
28+
If anyone else has updated information for this issue, please open up a new bug report and simply reference this closed bug report so that we can get any new information you may have.
2929
3030
Thank you and have a great day!

.github/workflows/issues_handleLabel.yml

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ jobs:
5050
5151
Hello @${{ github.event.issue.user.login }},
5252
53-
We ask that you please follow the [issue template](https://raw.githubusercontent.com/strapi/strapi/master/.github/ISSUE_TEMPLATE/BUG_REPORT.md).
53+
We ask that you please follow the [issue template](https://github.com/strapi/sdk-js/issues/new/choose).
5454
A proper issue submission let's us better understand the origin of your bug and therefore help you. We will reopen your issue when we receive the issue following the template guidelines and properly fill out the template. You can see the template guidelines for bug reports [here](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue).
5555
5656
Please update the issue with the template and we can reopen this report.
@@ -83,8 +83,6 @@ jobs:
8383
- questions should be directed to [our forum](https://forum.strapi.io) or our [Discord](https://discord.strapi.io)
8484
- feature requests should be directed to our [feedback and feature request database](https://feedback.strapi.io)
8585
86-
Please see the following contributing guidelines for asking a question [here](https://github.com/strapi/strapi/blob/master/CONTRIBUTING.md#reporting-an-issue).
87-
8886
Thank you.
8987
- name: 'Close: redirect question to community'
9088
if: "${{ github.event.label.name == 'flag: question' }}"

.github/workflows/tests.yml

Lines changed: 0 additions & 87 deletions
This file was deleted.

.github/workflows/unit_tests.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Unit Tests'
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
permissions:
10+
contents: read # to fetch code (actions/checkout)
11+
actions: read
12+
13+
jobs:
14+
unit_tests:
15+
name: 'Unit Tests (node: ${{ matrix.node }})'
16+
runs-on: ubuntu-latest
17+
strategy:
18+
matrix:
19+
node: [20, 22]
20+
steps:
21+
- name: Checkout
22+
uses: actions/checkout@v4
23+
24+
- uses: ./.github/actions/setup
25+
name: Setup
26+
with:
27+
node-version: ${{ matrix.node }}
28+
29+
- name: Run tests
30+
run: pnpm run test

rollup.config.mjs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ const node_build = {
6767
// Only minify in production
6868
isProduction && terser(),
6969
// Analysis and visualization artifacts
70-
visualizer({ filename: '.stats/bundle.node.html', template: 'raw-data' }),
70+
visualizer({ filename: '.stats/bundle.node.json', template: 'raw-data' }),
7171
],
7272
};
7373

@@ -126,7 +126,7 @@ const browser_build = {
126126
// Minify the code
127127
terser(),
128128
// Analysis and visualization artifacts
129-
visualizer({ filename: '.stats/bundle.browser.html', template: 'raw-data' }),
129+
visualizer({ filename: '.stats/bundle.browser.json', template: 'raw-data' }),
130130
],
131131
};
132132

0 commit comments

Comments
 (0)