-
Notifications
You must be signed in to change notification settings - Fork 6
107 lines (92 loc) · 3.32 KB
/
size-limit.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
name: Measure size of the library
on:
pull_request:
push:
branches:
- main
concurrency:
group: ci-size-limit=${{github.ref}}-1
cancel-in-progress: true
permissions:
contents: read # Read-only access to repository contents
issues: write # Write access to issues
pull-requests: write # Write access to pull requests
statuses: write # Write access to commit statuses
jobs:
size-limit:
name: 'Measure size of the library'
runs-on: ubuntu-latest
env:
NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID_STATOSCOPE }}
NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }}
REPORT_FOLDER: './size-limit-report'
NODE_OPTIONS: --max-old-space-size=4096
steps:
- uses: actions/checkout@v3
- name: Install pnpm
uses: pnpm/action-setup@v2
with:
version: 8
- uses: actions/setup-node@v3
with:
node-version-file: '.nvmrc'
cache: 'pnpm'
- name: Install dependencies
run: pnpm install
- name: Build project
run: pnpm build
- name: Download baseline stats
uses: dawidd6/action-download-artifact@v4
if: github.event.number
with:
workflow: size-limit.yml
branch: ${{ github.event.pull_request.base.ref }}
path: ./__compare
- name: Measure size
id: measure_size
continue-on-error: true
run: BASELINE='./__compare/${{ env.REPORT_FOLDER }}/output.json' node ./scripts/ci/measure-size.mjs
- name: Save stats
run: echo '${{ steps.measure_size.outputs.result }}' > ./size-limit-report/output.json
- name: Upload stats
uses: actions/upload-artifact@v4
with:
name: size-limit-report
path: ${{ env.REPORT_FOLDER }}
- name: Build Statoscope Report
if: github.event.number
run: npx statoscope generate -i ${{ env.REPORT_FOLDER }}/stats.json -r ./__compare/${{ env.REPORT_FOLDER }}/stats.json --output ${{ env.REPORT_FOLDER }}/report.html
- name: Deploy Report
id: deploy_report
if: github.event.number
uses: South-Paw/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
netlify-auth-token: ${{ secrets.NETLIFY_AUTH_TOKEN }}
netlify-site-id: ${{ secrets.NETLIFY_SITE_ID }}
draft: true
build-dir: ${{ env.REPORT_FOLDER }}
comment-on-commit: false
- name: Comment PR
uses: actions/github-script@v6
if: github.event.number
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const setMessage = require('${{ github.workspace }}/scripts/ci/set-message')
await setMessage({
header: "## 🏋️ Size limit report",
body: `
${{ steps.measure_size.outputs.table }}
---
[Click here if you want to find out what is changed in this build](${{ steps.deploy_report.outputs.preview-url }}/report.html)
`,
github,
repo: context.repo,
prNumber: context.payload.pull_request.number
})
- name: Throw error
if: steps.measure_size.outcome != 'success'
run: |
echo "Size limit has been exceeded"
exit 1