101 lines
3.3 KiB
YAML
101 lines
3.3 KiB
YAML
name: Bundle Budget
|
|
|
|
# Gitea variant of .github/workflows/bundle-budget.yml. Uses Gitea-API to
|
|
# post / upsert a sticky PR comment with per-route gzip sizes.
|
|
# Docs: docs/architecture/bundle-budgets.md
|
|
|
|
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"
|
|
- ".gitea/workflows/bundle-budget.yml"
|
|
|
|
env:
|
|
HIVEGRID_GITEA_HOST_IP: ${{ vars.HIVEGRID_GITEA_HOST_IP }}
|
|
|
|
jobs:
|
|
measure:
|
|
name: Measure & 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 PR head
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Enable Corepack
|
|
run: corepack enable
|
|
|
|
- name: Prepare pnpm 10.33.0
|
|
run: corepack prepare pnpm@10.33.0 --activate
|
|
|
|
- name: Configure pnpm store
|
|
run: pnpm config set store-dir .pnpm-store
|
|
|
|
- name: Cache pnpm store
|
|
uses: actions/cache@v4
|
|
with:
|
|
path: .pnpm-store
|
|
key: ${{ runner.os }}-pnpm-${{ hashFiles('pnpm-lock.yaml') }}
|
|
restore-keys: |
|
|
${{ runner.os }}-pnpm-
|
|
|
|
- name: Install dependencies
|
|
run: pnpm install --frozen-lockfile --prefer-offline
|
|
|
|
- name: Build web (PR head)
|
|
run: pnpm --filter @hivegrid/web build
|
|
|
|
- name: Verify aggregate bundle budgets
|
|
run: pnpm run verify:bundle-size
|
|
|
|
- name: Measure PR bundle sizes
|
|
run: node scripts/verify-bundle-size.mjs --json > pr-bundle-report.json
|
|
|
|
- name: Render PR comment markdown
|
|
# Baseline download from Gitea artifact storage is opt-in via
|
|
# BUNDLE_BASELINE_URL; falls back to no-diff mode otherwise.
|
|
run: |
|
|
if [ -n "${BUNDLE_BASELINE_URL:-}" ]; then
|
|
curl -sSfL "$BUNDLE_BASELINE_URL" -o main-bundle-report.json || true
|
|
fi
|
|
node scripts/render-bundle-budget-comment.mjs \
|
|
--current pr-bundle-report.json \
|
|
--baseline main-bundle-report.json \
|
|
--out bundle-comment.md
|
|
env:
|
|
BUNDLE_BASELINE_URL: ${{ vars.BUNDLE_BASELINE_URL }}
|
|
|
|
- name: Upsert Gitea PR comment
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
GITEA_HOST: ${{ vars.GITEA_HOST || 'git.tool-ctrl.de' }}
|
|
PR_NUMBER: ${{ github.event.pull_request.number }}
|
|
REPO: ${{ github.repository }}
|
|
run: node scripts/post-bundle-budget-gitea-comment.mjs
|