Replace the previous frontend workflow with an expanded Build, Test & Push workflow. Adds a quality-check job (runs on push and PRs to main) that sets up Node.js, installs deps, runs lint/type checks, unit tests (ChromeHeadless), production build and runs LHCI. The docker job now depends on the quality-check job and only runs on pushes to main. Added lighthouserc.json and ignored .lighthouseci, relaxed two ESLint rules (@typescript-eslint/no-inferrable-types and no-explicit-any), and updated package.json (and lock) to include LHCI tooling.
92 lines
2.7 KiB
YAML
92 lines
2.7 KiB
YAML
name: Build, Test & Push Frontend
|
|
run-name: ${{ gitea.actor }} build and test Angular 🚀
|
|
|
|
on:
|
|
push:
|
|
branches:
|
|
- main
|
|
pull_request:
|
|
branches:
|
|
- main
|
|
|
|
jobs:
|
|
# ------------------------------------------------------------------
|
|
# JOB 1: Code integrity and quality gates (CI)
|
|
# ------------------------------------------------------------------
|
|
quality-check:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- name: Checkout Code
|
|
uses: actions/checkout@v4
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v4
|
|
with:
|
|
node-version: '22'
|
|
cache: 'npm'
|
|
|
|
- name: Install Dependencies
|
|
run: npm ci
|
|
|
|
# 1. Linting (Code-Style)
|
|
- name: Lint & Type Check
|
|
run: npm run lint --if-present
|
|
|
|
# 2. Unit Tests (Logik)
|
|
- name: Unit Tests
|
|
run: npx ng test --watch=false --browsers=ChromeHeadless
|
|
|
|
# 3. Build Production (für Lighthouse notwendig)
|
|
- name: Build Production
|
|
run: npx ng build --configuration production
|
|
|
|
# 4. Lighthouse Audit (Performance & SEO)
|
|
- name: Lighthouse CI
|
|
run: npx lhci autorun
|
|
|
|
# ------------------------------------------------------------------
|
|
# JOB 2: Docker Build & Push (CD)
|
|
# Runs only if 'quality-check' are successfully and we are on branch main.
|
|
# ------------------------------------------------------------------
|
|
docker:
|
|
needs: quality-check
|
|
runs-on: ubuntu-latest
|
|
if: github.event_name == 'push' && github.ref == 'refs/heads/main'
|
|
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
|
|
- name: Prepare tag (sanitize branch)
|
|
id: prep
|
|
shell: bash
|
|
run: |
|
|
BRANCH="${GITHUB_REF_NAME}"
|
|
BRANCH="${BRANCH//\//-}"
|
|
BRANCH="$(echo "$BRANCH" | tr '[:upper:]' '[:lower:]')"
|
|
echo "branch=$BRANCH" >> "$GITHUB_OUTPUT"
|
|
echo "sha=${GITHUB_SHA::12}" >> "$GITHUB_OUTPUT"
|
|
|
|
- uses: docker/setup-buildx-action@v3
|
|
|
|
- uses: docker/login-action@v3
|
|
with:
|
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
|
|
|
- name: Build & Push (branch + sha tags)
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
docker.io/${{ secrets.DOCKERHUB_USERNAME }}/playground:frontend-a-${{ steps.prep.outputs.branch }}
|
|
docker.io/${{ secrets.DOCKERHUB_USERNAME }}/playground:frontend-a-${{ steps.prep.outputs.branch }}-${{ steps.prep.outputs.sha }}
|
|
|
|
- name: Also push moving main tag
|
|
uses: docker/build-push-action@v6
|
|
with:
|
|
context: .
|
|
push: true
|
|
tags: |
|
|
docker.io/${{ secrets.DOCKERHUB_USERNAME }}/playground:frontend-a-main
|