This repository has been archived by the owner on May 7, 2024. It is now read-only.
forked from transcom/mymove
-
Notifications
You must be signed in to change notification settings - Fork 0
128 lines (113 loc) · 3.63 KB
/
analyze-bundle.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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
name: F/E bundle diff
# For Truss and how we use this repo, pull_request and
# pull_request_target have no differences
#
# https://securitylab.github.com/research/github-actions-preventing-pwn-requests/
#
# Workflows triggered via pull_request_target have write permission
# to the target repository. They also have access to target
# repository secrets. The same is true for workflows triggered on
# pull_request from a branch in the same repository, but not from
# external forks.
#
# Truss always uses branches in the same repository
#
# Using pull_request means changes to the workflow file are used in
# the PR, which is incredibly helpful when testing out changes
on:
pull_request:
pull_request_target:
branches:
- main
jobs:
changes:
runs-on: ubuntu-latest
outputs:
frontend: ${{ steps.filter.outputs.frontend }}
steps:
- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
frontend:
- 'src/**'
- 'yarn.lock'
build-head:
concurrency:
group: bundle-build-head-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' }}
name: 'Build head'
runs-on: ubuntu-latest
steps:
- name: Check out branch
uses: actions/[email protected]
- name: Set up node
uses: actions/setup-node@v3
with:
node-version-file: '.tool-versions'
- name: Install dependencies
run: yarn install
- name: Build head with options
run: |
export NODE_OPTIONS="--max-old-space-size=4096"
echo "Using NODE_OPTIONS:${NODE_OPTIONS}"
yarn build --stats
- name: Upload stats.json
uses: actions/upload-artifact@v3
with:
name: head-stats
path: ./build/bundle-stats.json
build-base:
concurrency:
group: bundle-build-base-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
needs: changes
if: ${{ needs.changes.outputs.frontend == 'true' }}
name: 'Build base'
runs-on: ubuntu-latest
steps:
- name: Check out base branch
uses: actions/[email protected]
with:
ref: ${{ github.base_ref }}
- name: Set up node
uses: actions/setup-node@v3
with:
node-version-file: '.tool-versions'
- name: Install dependencies
run: yarn install
- name: Build base with options
run: |
export NODE_OPTIONS="--max-old-space-size=4096"
echo "Using NODE_OPTIONS:${NODE_OPTIONS}"
yarn build --stats
- name: Upload stats.json
uses: actions/upload-artifact@v3
with:
name: base-stats
path: ./build/bundle-stats.json
# run the action against the stats.json files
compare:
if: ${{ needs.changes.outputs.frontend == 'true' }}
concurrency:
group: bundle-compare-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
name: 'Compare base & head bundle sizes'
runs-on: ubuntu-latest
needs: [build-base, build-head]
permissions:
pull-requests: write
steps:
- uses: actions/download-artifact@v3
- uses: github/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
current-stats-json-path: ./head-stats/bundle-stats.json
base-stats-json-path: ./base-stats/bundle-stats.json
noop:
name: 'Noop job to prevent notification'
runs-on: ubuntu-latest
steps:
- run: 'echo "No build required" '