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

81 lines
3.0 KiB
YAML

name: Lighthouse CI
# Audits the deployed staging site (https://app.hivegrid.de). A
# meaningful Lighthouse audit needs a live server, a database and seeded
# content; reproducing that whole stack inside a CI job is brittle, so the
# audit targets the deployed environment instead.
#
# This is therefore a post-deploy / monitoring audit, NOT a per-commit merge
# gate — staging always lags the commit under review. It runs nightly and on
# manual dispatch.
#
# Docs: docs/architecture/lighthouse.md
on:
workflow_dispatch:
schedule:
# 03:00 UTC nightly — after the day's deploys have settled.
- cron: "0 3 * * *"
env:
HIVEGRID_GITEA_HOST_IP: ${{ vars.HIVEGRID_GITEA_HOST_IP }}
jobs:
lighthouse:
name: Run Lighthouse audits
runs-on: toolctrl-ci
timeout-minutes: 30
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
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: Mint Lighthouse session cookie
run: node scripts/rotate-lighthouse-session-cookie.mjs
env:
LIGHTHOUSE_LOGIN_URL: https://app.hivegrid.de/login
LIGHTHOUSE_LOGIN_EMAIL: ${{ secrets.LIGHTHOUSE_LOGIN_EMAIL }}
LIGHTHOUSE_LOGIN_PASSWORD: ${{ secrets.LIGHTHOUSE_LOGIN_PASSWORD }}
LIGHTHOUSE_SESSION_COOKIE: ${{ secrets.LIGHTHOUSE_SESSION_COOKIE }}
LIGHTHOUSE_SESSION_COOKIE_NAME: __Host-hivegrid_app_session
LIGHTHOUSE_COOKIE_DOMAIN: app.hivegrid.de
- name: Install Chromium
# The Gitea runner base image ships no browser; LHCI's
# healthcheck otherwise fails with "Chrome installation not found".
run: |
apt-get update
apt-get install -y --no-install-recommends chromium fonts-liberation
rm -rf /var/lib/apt/lists/*
- name: Run Lighthouse-CI against staging
run: npx --yes @lhci/cli@0.13.0 autorun --config=./.lighthouserc.staging.json
env:
# chromium installs to /usr/bin/chromium on Debian bookworm.
CHROME_PATH: /usr/bin/chromium
- name: Upload Lighthouse artifacts
if: always()
uses: actions/upload-artifact@ff15f0306b3f739f7b6fd43fb5d26cd321bd4de5 # v3
with:
name: lighthouse-ci-results
path: .lighthouseci/
retention-days: 14