Version Packages (#496) #1375
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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@v2 | |
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@v2 | |
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 |