-
-
Notifications
You must be signed in to change notification settings - Fork 56
84 lines (79 loc) · 2.45 KB
/
bundle-size.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
name: Bundle size
on:
pull_request:
paths-ignore:
- ".vscode/**"
- "docs/**"
- "env/**"
- "**/*.md"
- ".gitpod.yml"
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
pull-requests: write
jobs:
bundle-size:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
ref:
- ${{ github.event.pull_request.base.ref }}
- ${{ github.event.pull_request.head.ref }}
fail-fast: true
steps:
- uses: actions/checkout@v4
with:
ref: ${{ matrix.ref }}
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
check-latest: true
cache: "yarn"
cache-dependency-path: "./yarn.lock"
- uses: actions/cache@v4
with:
path: node_modules
key: node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-${{ hashFiles('yarn.lock') }}
restore-keys: |
node_modules-${{ runner.os }}-node-${{ matrix.node-version }}-
- run: corepack enable
- run: yarn install --immutable
- run: |
yarn workspace ott-client run build | sed -r 's/([a-zA-Z]+-)[^ .]+(\.[^ ]+)/\1hash\2/' | tee /tmp/bundle-size.txt
- name: Upload bundle size
uses: actions/upload-artifact@v4
with:
name: bundle-size-${{ matrix.ref }}
path: /tmp/bundle-size.txt
bundle-size-compare:
runs-on: ubuntu-latest
needs: bundle-size
strategy:
matrix:
node-version: [18.x]
steps:
- name: Download bundle size (base ref)
uses: actions/download-artifact@v4
with:
name: bundle-size-${{ github.event.pull_request.base.ref }}
path: /tmp/bundle-size-base.txt
- name: Download bundle size (head ref)
uses: actions/download-artifact@v4
with:
name: bundle-size-${{ github.event.pull_request.head.ref }}
path: /tmp/bundle-size-head.txt
- name: Compare bundle sizes
run: |
cat <<EOF > diff.txt
# Bundle size diff
\`\`\`diff
$(diff -u /tmp/bundle-size-base.txt /tmp/bundle-size-head.txt)
\`\`\`
EOF
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: Bundle size diff
path: diff.txt