175 lines
5.3 KiB
YAML
175 lines
5.3 KiB
YAML
name: Automated Tests
|
|
|
|
on:
|
|
pull_request:
|
|
push:
|
|
workflow_dispatch:
|
|
schedule:
|
|
- cron: "0 2 * * *"
|
|
|
|
permissions:
|
|
contents: read
|
|
|
|
concurrency:
|
|
group: frontend-tests-${{ github.workflow }}-${{ github.ref }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
format-tests:
|
|
# Match the labels exposed by the Coolify-managed GitHub runner.
|
|
runs-on: [self-hosted, Linux, X64, default]
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Check AI workflow sync
|
|
run: node scripts/sync-ai-workflow.mjs --check
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --legacy-peer-deps
|
|
|
|
- name: Check frontend test formatting
|
|
run: npm run format:tests:check
|
|
|
|
build-and-unit:
|
|
needs: format-tests
|
|
runs-on: [self-hosted, Linux, X64, default]
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --legacy-peer-deps
|
|
|
|
- name: Build sanity check
|
|
run: npm run build
|
|
|
|
- name: Unit tests
|
|
run: npm run test:unit
|
|
env:
|
|
VITEST_BATCH_SIZE: 5
|
|
|
|
e2e-pr:
|
|
if: github.event_name != 'schedule'
|
|
needs: build-and-unit
|
|
runs-on: [self-hosted, Linux, X64, default]
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
with:
|
|
fetch-depth: 0
|
|
|
|
- name: Resolve Playwright diff refs
|
|
id: playwright-diff
|
|
shell: bash
|
|
env:
|
|
DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
|
|
EVENT_NAME: ${{ github.event_name }}
|
|
HEAD_SHA: ${{ github.sha }}
|
|
PR_BASE_SHA: ${{ github.event.pull_request.base.sha }}
|
|
PUSH_BEFORE_SHA: ${{ github.event.before }}
|
|
run: |
|
|
set -euo pipefail
|
|
zero_sha="0000000000000000000000000000000000000000"
|
|
if [[ "$EVENT_NAME" == "pull_request" && -n "$PR_BASE_SHA" ]]; then
|
|
base_ref="$PR_BASE_SHA"
|
|
elif [[ -z "$PUSH_BEFORE_SHA" || "$PUSH_BEFORE_SHA" == "$zero_sha" ]]; then
|
|
git fetch --no-tags --prune origin "$DEFAULT_BRANCH"
|
|
base_ref="origin/$DEFAULT_BRANCH"
|
|
else
|
|
base_ref="$PUSH_BEFORE_SHA"
|
|
fi
|
|
echo "base=$base_ref" >> "$GITHUB_OUTPUT"
|
|
echo "head=$HEAD_SHA" >> "$GITHUB_OUTPUT"
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --legacy-peer-deps
|
|
|
|
- name: Install Playwright browsers
|
|
run: npx playwright install --with-deps chromium
|
|
|
|
- name: Run Playwright PR tests
|
|
run: npm run test:e2e:pr -- --base="${{ steps.playwright-diff.outputs.base }}" --head="${{ steps.playwright-diff.outputs.head }}"
|
|
|
|
- name: Upload Playwright report
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report-pr
|
|
path: output/playwright
|
|
if-no-files-found: ignore
|
|
retention-days: 7
|
|
|
|
e2e-full:
|
|
if: github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' || github.ref_name == github.event.repository.default_branch
|
|
needs: build-and-unit
|
|
name: E2E-full-${{ matrix.role }}-${{ matrix.browser_label }}-${{ matrix.device }}
|
|
runs-on: [self-hosted, Linux, X64, default]
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
role: [customer, subuser, admin, superuser]
|
|
browser: [chromium, firefox, webkit]
|
|
device: [mobile, tablet, desktop]
|
|
include:
|
|
- browser: chromium
|
|
browser_label: Chromium
|
|
browser_install: chromium
|
|
- browser: firefox
|
|
browser_label: Firefox
|
|
browser_install: firefox
|
|
- browser: webkit
|
|
browser_label: WebKit
|
|
browser_install: webkit
|
|
env:
|
|
PLAYWRIGHT_ARTIFACT_NAMESPACE: e2e-full-${{ matrix.role }}-${{ matrix.browser }}-${{ matrix.device }}
|
|
PLAYWRIGHT_REPORTER_MODE: line-html
|
|
steps:
|
|
- name: Checkout repository
|
|
uses: actions/checkout@v5
|
|
|
|
- name: Setup Node.js
|
|
uses: actions/setup-node@v5
|
|
with:
|
|
node-version: 22
|
|
cache: npm
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --legacy-peer-deps
|
|
|
|
- name: Install Playwright browsers
|
|
run: npx playwright install --with-deps ${{ matrix.browser_install }}
|
|
|
|
- name: Run full Playwright slice
|
|
run: npm run test:e2e:full:slice -- --role="${{ matrix.role }}" --project="${{ matrix.browser }}-${{ matrix.device }}"
|
|
|
|
- name: Upload Playwright report
|
|
if: failure()
|
|
uses: actions/upload-artifact@v4
|
|
with:
|
|
name: playwright-report-full-${{ matrix.role }}-${{ matrix.browser }}-${{ matrix.device }}
|
|
path: |
|
|
output/playwright/${{ env.PLAYWRIGHT_ARTIFACT_NAMESPACE }}/report
|
|
output/playwright/${{ env.PLAYWRIGHT_ARTIFACT_NAMESPACE }}/test-results
|
|
output/playwright/test-lists/${{ matrix.role }}-${{ matrix.browser }}-${{ matrix.device }}.txt
|
|
if-no-files-found: ignore
|
|
retention-days: 14
|