Files
networking-toolbox/.github/workflows/tests.yml
T

84 lines
2.2 KiB
YAML

name: 🧪 Run Tests
on:
pull_request:
push:
branches: [main]
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
kind: [unit, e2e]
env:
NODE_OPTIONS: "--max_old_space_size=8192"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22
cache: npm
- name: Install deps
run: npm ci
# --- Unit (Vitest) ---
- name: Run unit tests (Vitest + coverage)
if: matrix.kind == 'unit'
run: npm run test:coverage
- name: Upload unit coverage
if: matrix.kind == 'unit' && (success() || failure())
uses: actions/upload-artifact@v4
with:
name: coverage-unit
path: coverage
if-no-files-found: ignore
# --- E2E (Playwright) ---
- name: Install Playwright browsers
if: matrix.kind == 'e2e'
run: npx playwright install --with-deps
- name: Run e2e tests (Playwright)
if: matrix.kind == 'e2e'
run: npm run test:e2e -- --reporter=junit,html
- name: Upload e2e reports
if: matrix.kind == 'e2e' && (success() || failure())
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: |
playwright-report
test-results
if-no-files-found: ignore
summary:
name: Summary
runs-on: ubuntu-latest
if: always()
needs: [tests]
steps:
- name: Write summary
env:
TESTS: ${{ needs.tests.result }} # success | failure | cancelled
run: |
em() { case "$1" in success) echo "✅";; failure) echo "❌";; cancelled|skipped) echo "⏭️";; *) echo "❔";; esac; }
verb() { [ "$1" = "success" ] && echo "Passing" || { [ "$1" = "cancelled" ] && echo "Skipped" || echo "Failing"; }; }
{
echo "## Test Summary"
echo "- $(em "$TESTS") Tests - $(verb "$TESTS")"
echo ""
echo "_See job logs and artifacts for details (coverage & Playwright reports)._"
} >> "$GITHUB_STEP_SUMMARY"