Files
HiveGrid-Wireframes/03 Quellen und Referenzen/hivegrid-cloud/.gitea/workflows/bundle-budget.yml
T

115 lines
3.8 KiB
YAML

name: Bundle Budget
# Enforces aggregate bundle budgets for pull requests. The current report and
# its comparison with the latest cached main baseline are attached to the run.
on:
pull_request:
paths:
- "apps/web/**"
- "packages/brand/**"
- "packages/config/**"
- "packages/entitlements/**"
- "packages/form-widget/**"
- "packages/foundation/**"
- "packages/i18n/**"
- "packages/plugin-runtime/**"
- "packages/ui*/**"
- "packages/url/**"
- "packages/view-models/**"
- "package.json"
- "pnpm-lock.yaml"
- "scripts/bundle-budgets.json"
- "scripts/verify-bundle-size.mjs"
- "scripts/render-bundle-budget-comment.mjs"
- ".gitea/workflows/bundle-budget.yml"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
env:
HIVEGRID_GITEA_HOST_IP: ${{ vars.HIVEGRID_GITEA_HOST_IP }}
jobs:
measure:
name: Measure and report bundle sizes
runs-on: toolctrl-ci
timeout-minutes: 30
env:
DATABASE_URL: postgresql://hivegrid:hivegrid@localhost:5432/hivegrid?schema=public
steps:
- name: Resolve internal Gitea host
run: |
if [ -n "${HIVEGRID_GITEA_HOST_IP:-}" ]; then
if ! HIVEGRID_GITEA_HOST_IP="$HIVEGRID_GITEA_HOST_IP" node -e 'process.exit(require("node:net").isIP(process.env.HIVEGRID_GITEA_HOST_IP || "") ? 0 : 1)'; then
echo "HIVEGRID_GITEA_HOST_IP must be a single IPv4 or IPv6 token"
exit 1
fi
printf '%s git.tool-ctrl.de\n' "$HIVEGRID_GITEA_HOST_IP" >> /etc/hosts
fi
- name: Checkout pull request
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Node.js
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4
with:
node-version-file: .nvmrc
- name: Persist Node.js toolchain
run: bash scripts/ci/persist-node-toolchain.sh
- name: Enable Corepack
run: corepack enable --install-directory /usr/local/bin
- name: Prepare pnpm 11.12.0
run: corepack prepare pnpm@11.12.0 --activate
- name: Configure pnpm store
run: pnpm config set store-dir .pnpm-store
- name: Cache pnpm store
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: .pnpm-store
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Restore latest main bundle baseline
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: baseline/main-bundle-report.json
key: bundle-baseline-pr-${{ gitea.sha }}
restore-keys: |
bundle-baseline-main-
- name: Install dependencies
run: pnpm install --frozen-lockfile --prefer-offline
- name: Build web
run: pnpm --filter @hivegrid/web build
- name: Verify aggregate bundle budgets
run: pnpm run verify:bundle-size
- name: Measure bundle sizes
if: always()
run: node scripts/verify-bundle-size.mjs --json > pr-bundle-report.json
- name: Render bundle report
if: always()
run: node scripts/render-bundle-budget-comment.mjs --current pr-bundle-report.json --baseline baseline/main-bundle-report.json --out bundle-report.md
- name: Upload bundle report
if: always()
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3
with:
name: bundle-report-pr-${{ gitea.run_id }}
path: |
pr-bundle-report.json
bundle-report.md
retention-days: 14