-
Notifications
You must be signed in to change notification settings - Fork 512
103 lines (89 loc) · 2.95 KB
/
pr-bundlesize-compare.yml
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
name: Compare bundle size
on:
pull_request:
jobs:
# Build current and upload stats.json
build-head:
if: github.event.pull_request.head.repo.full_name == github.repository
name: "Build head"
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Cache @vscode/ripgrep bin
uses: actions/cache@v4
with:
key: vscode-ripgrep-bin-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock') }}
path: node_modules/@vscode/ripgrep/bin/
- name: Install all yarn packages
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: yarn build:client
env:
ANALYZE_BUNDLE_PR: true
- name: Upload stats.json
uses: actions/upload-artifact@v4
with:
name: head-stats
path: ./client/build/stats.json
# Build base for comparison and upload stats.json
build-base:
if: github.event.pull_request.head.repo.full_name == github.repository
name: "Build base"
permissions:
contents: read
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
ref: ${{ github.base_ref }}
- name: Setup Node.js environment
uses: actions/setup-node@v4
with:
node-version-file: ".nvmrc"
cache: yarn
- name: Cache @vscode/ripgrep bin
uses: actions/cache@v4
with:
key: vscode-ripgrep-bin-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('yarn.lock') }}
path: node_modules/@vscode/ripgrep/bin/
- name: Install all yarn packages
run: yarn --frozen-lockfile
env:
# https://github.com/microsoft/vscode-ripgrep#github-api-limit-note
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Build
run: yarn build:client
env:
ANALYZE_BUNDLE_PR: true
- name: Upload stats.json
uses: actions/upload-artifact@v4
with:
name: base-stats
path: ./client/build/stats.json
# run the action against the stats.json files
compare:
if: github.event.pull_request.head.repo.full_name == github.repository
name: "Compare base & head bundle sizes"
runs-on: ubuntu-latest
needs: [build-base, build-head]
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v4
- uses: github/webpack-bundlesize-compare-action@v1
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
current-stats-json-path: ./head-stats/stats.json
base-stats-json-path: ./base-stats/stats.json