-
Notifications
You must be signed in to change notification settings - Fork 4
85 lines (75 loc) · 3.01 KB
/
Copy pathapps-ui-bundle-diff.yml
File metadata and controls
85 lines (75 loc) · 3.01 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
73
74
75
76
77
78
79
80
81
82
83
84
85
name: bundle-diff
on:
# No top-level `paths:` filter — the `size-diff` check is in branch
# protection's required-checks list, so the workflow must report a
# status on every PR or branch protection sits in "Expected — Waiting"
# forever. The expensive build + size-limit steps are gated on the
# internal paths-filter below, so PRs that don't touch the UI bundle
# report green without doing real work.
pull_request:
branches: [main]
concurrency:
group: apps-ui-bundle-diff-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
pull-requests: write
jobs:
# Build apps/ui with bun (matching local dev), then enforce the
# `.size-limit.json` budgets with `bunx size-limit`. size-limit exits
# non-zero when any chunk exceeds its `limit:` value, so this job is a
# hard gate against bundle bloat. The full table prints in the job log
# so reviewers can scan deltas.
#
# Why a hand-rolled workflow instead of `andresz1/size-limit-action`:
# the action's npm-based install is incompatible with apps/ui's eslint
# peerDep tree (bun resolves leniently, npm 7+ does not), and patching
# around its install/exec quirks burned through three CI cycles. Going
# straight bun keeps the toolchain consistent with local dev.
size-diff:
if: github.actor != 'dependabot[bot]'
runs-on: ubuntu-24.04
timeout-minutes: 8
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
- name: Detect UI bundle changes
uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
id: filter
with:
filters: |
ui:
- 'apps/ui/src/**'
- 'apps/ui/package.json'
- 'apps/ui/bun.lock'
- 'apps/ui/vite.config.ts'
- 'apps/ui/.size-limit.json'
- '.github/workflows/apps-ui-bundle-diff.yml'
- name: No-op notice for non-UI PRs
if: steps.filter.outputs.ui != 'true'
run: echo "No UI bundle inputs changed in this PR — size check skipped."
- name: Set up Bun
if: steps.filter.outputs.ui == 'true'
uses: oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6 # v2.2.0
with:
bun-version: 1.3.14
- name: Cache bun install
if: steps.filter.outputs.ui == 'true'
uses: actions/cache@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.5
with:
path: ~/.bun/install/cache
key: bun-${{ runner.os }}-${{ hashFiles('apps/ui/bun.lock') }}
restore-keys: |
bun-${{ runner.os }}-
- name: Install
if: steps.filter.outputs.ui == 'true'
working-directory: apps/ui
run: bun install --frozen-lockfile
- name: Build
if: steps.filter.outputs.ui == 'true'
working-directory: apps/ui
run: bun run build
- name: Enforce bundle-size budgets
if: steps.filter.outputs.ui == 'true'
working-directory: apps/ui
run: bunx size-limit