Skip to content

Merge pull request #81 from MoDevIO/ref #315

Merge pull request #81 from MoDevIO/ref

Merge pull request #81 from MoDevIO/ref #315

Workflow file for this run

name: CI (Quality Gate & Coverage)
on:
push:
branches: [ '**' ]
pull_request:
branches: [ '**' ]
permissions:
contents: write
pages: write
id-token: write
jobs:
# JOB 1: Schnellläufer (Unit Tests, Linting, TypeCheck)
build-and-test:
name: Lint & Unit Tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
# Neu: Auch Unit-Tests brauchen die Toolchain zum Kompilieren
- name: Cache Arduino Toolchain (Unit)
uses: actions/cache@v4
with:
path: |
/usr/local/bin/arduino-cli
~/.arduino15
key: ${{ runner.os }}-arduino-unit-${{ hashFiles('package-lock.json') }}
- name: Install Arduino CLI & Core
run: |
if ! command -v arduino-cli &> /dev/null; then
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
fi
arduino-cli core list | grep "arduino:avr" || (arduino-cli core update-index && arduino-cli core install arduino:avr)
- name: Static Analysis & Unit Tests
env:
# Separater Pfad für Unit-Tests, um Seiteneffekte zu vermeiden
ARDUINO_CACHE_DIR: /tmp/arduino-unit-cache
run: |
npm run check
npm run lint
npm run test:coverage
- name: Copy Coverage Summary
run: |
# Sicherstellen, dass das Zielverzeichnis existiert
mkdir -p coverage/lcov-report
# Debugging: Zeige wo die Dateien wirklich liegen
echo "Searching for coverage files..."
find coverage -name "coverage-summary.json"
# Kopieren mit Pfad-Prüfung
if [ -f "coverage/coverage-summary.json" ]; then
cp coverage/coverage-summary.json coverage/lcov-report/coverage-summary.json
elif [ -f "server/coverage/coverage-summary.json" ]; then
cp server/coverage/coverage-summary.json coverage/lcov-report/coverage-summary.json
else
echo "Error: coverage-summary.json not found!"
exit 1
fi
- name: Deploy Coverage to GitHub Pages
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./coverage/lcov-report
publish_branch: gh-pages
# JOB 2: Schwergewicht (Docker & E2E)
e2e-tests:
name: Playwright E2E
needs: build-and-test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache E2E Assets (Arduino, Playwright, Sketches)
uses: actions/cache@v4
with:
path: |
/usr/local/bin/arduino-cli
~/.arduino15
~/.cache/ms-playwright
server/arduino-cache
storage/binaries
key: ${{ runner.os }}-e2e-turbo-${{ hashFiles('package-lock.json', 'server/services/arduino-compiler.ts') }}
restore-keys: |
${{ runner.os }}-e2e-turbo-
- name: Install Arduino CLI & Core
run: |
if ! command -v arduino-cli &> /dev/null; then
curl -fsSL https://raw.githubusercontent.com/arduino/arduino-cli/master/install.sh | BINDIR=/usr/local/bin sh
fi
arduino-cli core list | grep "arduino:avr" || (arduino-cli core update-index && arduino-cli core install arduino:avr)
- name: Install Playwright Browsers
run: npx playwright install --with-deps chromium
- name: Build Sandbox Image
uses: docker/build-push-action@v5
with:
context: .
load: true
tags: unosim-sandbox:latest
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Run E2E Tests
env:
ARDUINO_CACHE_DIR: ${{ github.workspace }}/server/arduino-cache
run: npx playwright test --workers=2
- name: Commit new Linux visual baselines
if: always()
run: |
git config user.email "github-actions[bot]@users.noreply.github.com"
git config user.name "github-actions[bot]"
git add 'e2e/visual-full-context.spec.ts-snapshots/*-linux.png'
git diff --staged --quiet || (git commit -m "chore(e2e): update linux visual baselines [skip ci]" && git push)
- name: Upload Playwright report artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: |
playwright-report/
if-no-files-found: ignore
retention-days: 1
- name: Upload failure artifacts
if: failure()
uses: actions/upload-artifact@v4
with:
name: failure-test-results
path: |
test-results/
if-no-files-found: ignore
retention-days: 1