forked from aws-amplify/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (72 loc) · 2.94 KB
/
check_bundle_size.yml
File metadata and controls
72 lines (72 loc) · 2.94 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
name: Check Bundle Size
on:
pull_request:
branches: [main]
jobs:
checkBundleSizeChange:
permissions:
pull-requests: read
name: Check whether PR increases bundle size more than 5%
runs-on: ubuntu-latest
steps:
- name: Checkout main branch
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: main
- name: Setup Node.js 20
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20.x
- name: Install dependencies
run: yarn
- name: Run build and analyze base bundle sizes
env:
CURRENT_BRANCH: ${{ github.base_ref }}
CURRENT_REPO: ${{ github.repository }}
NODE_OPTIONS: --max_old_space_size=4096
run: ANALYZE=true yarn next-build
- name: Check base bundle size of select pages
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: base-bundle-sizes
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { checkBundleSize } = require('./.github/workflows/scripts/check_bundle_size.js');
return checkBundleSize();
- name: Checkout PR branch
uses: actions/checkout@a5ac7e51b41094c92402da3b24376905380afc29 # v4.1.6
with:
ref: ${{ github.head_ref }}
- name: Setup Node.js 20
uses: actions/setup-node@39370e3970a6d050c480ffad4ff0ed4d3fdee5af # v4.1.0
with:
node-version: 20.x
- name: Install dependencies
run: yarn
- name: Run build and analyze head bundle sizes
env:
CURRENT_BRANCH: ${{ github.head_ref }}
CURRENT_REPO: ${{ github.repository }}
NODE_OPTIONS: --max_old_space_size=4096
run: ANALYZE=true yarn next-build
- name: Check head bundle size of select pages
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: head-bundle-sizes
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { checkBundleSize } = require('./.github/workflows/scripts/check_bundle_size.js');
return checkBundleSize();
- name: Compare bundle page bundle sizes
uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1
id: compare-bundles
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { compareBundles } = require('./.github/workflows/scripts/check_bundle_size.js');
const baseBundles = ${{ steps.base-bundle-sizes.outputs.result }}
const headBundles = ${{ steps.head-bundle-sizes.outputs.result }}
return await compareBundles(baseBundles, headBundles)
- name: Fail if bundle size growth exceeds 5% on any of the selected pages
if: ${{ steps.compare-bundles.outputs.result > 0 }}
run: exit 1