Files
community-rule/.gitea/workflows/ci.yaml
T
adilallo 1253779c00
CI Pipeline / test (20) (pull_request) Successful in 5m17s
CI Pipeline / test (18) (pull_request) Successful in 6m36s
CI Pipeline / e2e (chromium) (pull_request) Failing after 4m48s
CI Pipeline / e2e (firefox) (pull_request) Failing after 3m40s
CI Pipeline / performance (pull_request) Has been cancelled
CI Pipeline / storybook (pull_request) Has been cancelled
CI Pipeline / lint (pull_request) Has been cancelled
CI Pipeline / build (pull_request) Has been cancelled
CI Pipeline / e2e (webkit) (pull_request) Has been cancelled
CI Pipeline / visual-regression (pull_request) Has been cancelled
Update ci.yaml
2025-09-02 21:28:32 -06:00

446 lines
17 KiB
YAML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
name: CI Pipeline
run-name: ${{ gitea.actor }} triggered CI pipeline
on:
workflow_dispatch: {}
push:
branches: [main, develop] # only direct pushes/merges to protected branches
pull_request:
branches: [main, develop] # PRs into main/develop
types: [opened, reopened, synchronize]
jobs:
test:
runs-on: [self-hosted, macos-latest]
strategy:
matrix: { node-version: [18, 20] }
env:
NODE_OPTIONS: "--max_old_space_size=4096"
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: npm
- run: npm ci
- run: npm test
# If the Codecov Action fails on Gitea, replace this with the bash uploader below
- name: Upload coverage to Codecov
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ./coverage/lcov.info
flags: unittests
# Bash uploader alternative (uncomment if the action above has issues)
# - name: Upload coverage to Codecov (bash)
# run: |
# curl -s https://codecov.io/bash > codecov.sh
# bash codecov.sh -t "${{ secrets.CODECOV_TOKEN }}" -f coverage/lcov.info -F unittests
e2e:
runs-on: [self-hosted, macos-latest]
strategy:
matrix: { browser: [chromium, firefox, webkit] }
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npx playwright install --with-deps ${{ matrix.browser }}
- run: npm run build
- name: Start app (background) + healthcheck
run: |
set -euxo pipefail
# Use port 3010 to avoid conflicts with local dev on 3000
export PORT="${PORT:-3010}"
export HOST="127.0.0.1"
# ensure build exists (dev server can build on-the-fly, but we need the build for production)
test -d .next || { echo "❌ Missing .next build output"; exit 1; }
# start and detach with logs
mkdir -p .next
# Use production server with enhanced stability for CI
# Start server in background but keep it alive with proper signal handling
(
# Create a new process group to isolate from CI cleanup
setsid bash -c '
# Set up signal handlers to prevent premature termination
trap "echo \"🛑 Received signal, shutting down gracefully...\"; exit 0" TERM INT
# Start the server
npm run start -- -p "'$PORT'" -H "'$HOST'" 2>&1 | tee .next/runner.log
' &
) &
echo $! > .next/runner.pid
echo "🌐 PID $(cat .next/runner.pid) listening on http://$HOST:$PORT"
# Wait for TCP connection
npx wait-on -t 120000 "tcp:$HOST:$PORT"
# Wait for HTTP response with retries
for i in {1..10}; do
if curl -fsS "http://$HOST:$PORT" >/dev/null 2>&1; then
echo "✅ App is responding on attempt $i"
break
fi
echo "⏳ Waiting for app to be ready... attempt $i/10"
sleep 5
done
# Final health check
curl -fsS "http://$HOST:$PORT" >/dev/null || { echo "❌ App failed final health check"; exit 1; }
echo "✅ App is fully ready for testing"
env:
NEXT_TELEMETRY_DISABLED: "1"
NODE_ENV: production
# Add stability measures for production server in CI
NODE_OPTIONS: "--max-old-space-size=4096 --max-semi-space-size=512"
NEXT_SHARP_PATH: "false"
- name: Show last 200 lines of server log on failure
if: failure()
run: |
echo "––– .next/runner.log (tail) –––"
tail -n 200 .next/runner.log || true
- name: Run E2E tests
run: |
# Give the server a moment to stabilize
sleep 10
echo "🚀 Starting E2E tests for ${{ matrix.browser }}..."
echo "🔍 Testing against: http://127.0.0.1:3010"
# Continuous server monitoring to catch if it dies
echo "📊 Monitoring server health for 30 seconds..."
for i in {1..6}; do
if curl -fsS "http://127.0.0.1:3010" >/dev/null 2>&1; then
echo "✅ Server healthy at check $i/6"
else
echo "❌ Server unhealthy at check $i/6"
break
fi
sleep 5
done
# Test server connectivity before running tests
curl -v "http://127.0.0.1:3010" | head -20 || echo "⚠️ Server connectivity check failed"
# Debug: Check Playwright configuration
echo "🔧 Playwright config check:"
echo " - CI env var: $CI"
echo " - BASE_URL: $BASE_URL"
echo " - Current working directory: $(pwd)"
echo " - Playwright version: $(npx playwright --version)"
# Debug: Check if server is still responding
echo "🌐 Final server health check:"
curl -s "http://127.0.0.1:3010" | head -5 || echo "❌ Server not responding"
# Debug: Check server process status
echo "🔍 Server process status:"
if [ -f .next/runner.pid ]; then
echo " - PID file exists: $(cat .next/runner.pid)"
echo " - Process running: $(ps -p $(cat .next/runner.pid) | grep -v PID || echo 'Process not found')"
echo " - Port 3010 listeners: $(lsof -i :3010 2>/dev/null | grep LISTEN || echo 'No listeners on 3010')"
# If process is missing, show the server logs to understand why it crashed
if ! ps -p $(cat .next/runner.pid) >/dev/null 2>&1; then
echo "❌ Server process has crashed! Showing last 50 lines of server log:"
tail -n 50 .next/runner.log || echo "No server log found"
echo "🔍 Checking for common crash causes..."
grep -i "error\|crash\|killed\|memory\|port\|bind" .next/runner.log | tail -10 || echo "No obvious errors found in log"
fi
else
echo " - No PID file found"
fi
# Debug: Check Playwright config file
echo "📁 Playwright config file contents:"
cat playwright.config.ts | grep -E "(baseURL|webServer|CI)" || echo "No config found"
# Debug: Test a simple Playwright command
echo "🧪 Testing Playwright connectivity..."
npx playwright show-trace --help >/dev/null 2>&1 && echo "✅ Playwright tools working" || echo "❌ Playwright tools issue"
# Run the tests with verbose output
echo "🧪 Running Playwright tests..."
npx playwright test --project=${{ matrix.browser }} --reporter=list || {
echo "❌ Playwright tests failed"
echo "📋 Last 50 lines of server log:"
tail -n 50 .next/runner.log || echo "No server log found"
echo "🔍 Checking if server is still running:"
ps aux | grep "npm run start" | grep -v grep || echo "No npm run start process found"
exit 1
}
env:
CI: true
BASE_URL: http://127.0.0.1:3010
# package artifacts (keeps file count small)
- name: Package E2E artifacts
if: always()
run: |
tar -czf playwright-${{ matrix.browser }}.tgz playwright-report test-results || true
- name: Upload E2E artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: playwright-results-${{ matrix.browser }}
path: playwright-${{ matrix.browser }}.tgz
retention-days: 30
- name: Stop app
if: always()
run: |
if [ -f .next/runner.pid ]; then
kill $(cat .next/runner.pid) 2>/dev/null || true
fi
visual-regression:
runs-on: [self-hosted, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npx playwright install --with-deps
- run: npm run build
# 1) Sanity check that the build exists
- name: Verify Next build output
run: |
set -euxo pipefail
ls -la .next || true
test -f .next/BUILD_ID || (echo "No Next build output (.next) did build fail?" && exit 1)
- name: Start app (background) + healthcheck
run: |
set -euxo pipefail
export PORT="${PORT:-3010}"
export HOST="127.0.0.1"
test -d .next || { echo "❌ Missing .next build output"; exit 1; }
mkdir -p .next
# Use production server with enhanced stability for CI
# Start server in background but keep it alive with proper signal handling
(
# Create a new process group to isolate from CI cleanup
setsid bash -c '
# Set up signal handlers to prevent premature termination
trap "echo \"🛑 Received signal, shutting down gracefully...\"; exit 0" TERM INT
# Start the server
npm run start -- -p "'$PORT'" -H "'$HOST'" 2>&1 | tee .next/runner.log
' &
) &
echo $! > .next/runner.pid
echo "🌐 PID $(cat .next/runner.pid) listening on http://$HOST:$PORT"
# Wait for TCP connection
npx wait-on -t 120000 "tcp:$HOST:$PORT"
# Wait for HTTP response with retries
for i in {1..10}; do
if curl -fsS "http://$HOST:$PORT" >/dev/null 2>&1; then
echo "✅ App is responding on attempt $i"
break
fi
echo "⏳ Waiting for app to be ready... attempt $i/10"
sleep 5
done
# Final health check
curl -fsS "http://$HOST:$PORT" >/dev/null || { echo "❌ App failed final health check"; exit 1; }
echo "✅ App is fully ready for testing"
env:
NEXT_TELEMETRY_DISABLED: "1"
NODE_ENV: production
# Add stability measures for production server in CI
NODE_OPTIONS: "--max-old-space-size=4096 --max-semi-space-size=512"
NEXT_SHARP_PATH: "false"
- name: Show last 200 lines of server log on failure
if: failure()
run: |
echo "––– .next/runner.log (tail) –––"
tail -n 200 .next/runner.log || true
# Seed snapshots on main branch only (one-time setup)
- name: Seed snapshots (main only)
if: github.ref == 'refs/heads/main'
run: PLAYWRIGHT_UPDATE_SNAPSHOTS=1 npx playwright test tests/e2e/visual-regression.spec.ts --project=chromium
env: { CI: true }
# Run visual regression tests
- name: Run visual regression tests
run: |
# Give the server a moment to stabilize
sleep 10
echo "🚀 Starting visual regression tests..."
npx playwright test tests/e2e/visual-regression.spec.ts
env: { CI: true }
- name: Package visual artifacts
if: always()
run: |
tar -czf visual-regression.tgz test-results tests/e2e/visual-regression.spec.ts-snapshots || true
- name: Upload visual artifacts
if: always()
uses: actions/upload-artifact@v3
with:
name: visual-regression-results
path: visual-regression.tgz
retention-days: 30
- name: Stop app
if: always()
run: |
if [ -f .next/runner.pid ]; then
kill $(cat .next/runner.pid) 2>/dev/null || true
fi
performance:
runs-on: [self-hosted, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- name: Install LHCI
run: npm i -D @lhci/cli
# Ensure a Chrome binary is available (works on Linux/macOS runners)
- name: Install Chrome via Puppeteer (portable)
run: |
npx @puppeteer/browsers install chrome@stable -P .cache/puppeteer
echo "CHROME_PATH=$(npx @puppeteer/browsers executable-path chrome@stable -P .cache/puppeteer)" >> $GITHUB_ENV
- name: Build application
run: npm run build
# 1) Sanity check that the build exists
- name: Verify Next build output
run: |
set -euxo pipefail
ls -la .next || true
test -f .next/BUILD_ID || (echo "No Next build output (.next) did build fail?" && exit 1)
- name: Start app (background) + healthcheck
run: |
set -euxo pipefail
export PORT=3010 HOST=127.0.0.1
test -d .next || { echo "❌ Missing .next build output"; exit 1; }
mkdir -p .next
# Use production server with enhanced stability for CI
# Start server in background but keep it alive with proper signal handling
(
# Create a new process group to isolate from CI cleanup
setsid bash -c '
# Set up signal handlers to prevent premature termination
trap "echo \"🛑 Received signal, shutting down gracefully...\"; exit 0" TERM INT
# Start the server
npm run start -- -p "'$PORT'" -H "'$HOST'" 2>&1 | tee .next/runner.log
' &
) &
echo $! > .next/runner.pid
echo "🌐 PID $(cat .next/runner.pid) listening on http://$HOST:$PORT"
# Wait for TCP connection
npx wait-on -t 120000 "tcp:$HOST:$PORT"
# Wait for HTTP response with retries
for i in {1..10}; do
if curl -fsS "http://$HOST:$PORT" >/dev/null 2>&1; then
echo "✅ App is responding on attempt $i"
break
fi
echo "⏳ Waiting for app to be ready... attempt $i/10"
sleep 5
done
# Final health check
curl -fsS "http://$HOST:$PORT" >/dev/null || { echo "❌ App failed final health check"; exit 1; }
echo "✅ App is fully ready for Lighthouse testing"
env:
NEXT_TELEMETRY_DISABLED: "1"
NODE_ENV: production
# Add stability measures for production server in CI
NODE_OPTIONS: "--max-old-space-size=4096 --max-semi-space-size=512"
NEXT_SHARP_PATH: "false"
- name: Show last 200 lines of server log on failure
if: failure()
run: |
echo "––– .next/runner.log (tail) –––"
tail -n 200 .next/runner.log || true
# ---- fixes begin here ----
- name: Ensure arm64 Node for LHCI
run: |
echo "node arch before: $(node -p "process.arch")"
if [ "$(node -p "process.arch")" != "arm64" ]; then
NODE_VER=20.17.0
curl -fsSLO https://nodejs.org/dist/v$NODE_VER/node-v$NODE_VER-darwin-arm64.tar.xz
tar -xJf node-v$NODE_VER-darwin-arm64.tar.xz
echo "$PWD/node-v$NODE_VER-darwin-arm64/bin" >> "$GITHUB_PATH"
echo "PATH updated to prefer arm64 node"
fi
echo "node arch after: $(node -p "process.arch")"
- name: Show arch & chrome info
run: |
echo "uname -m: $(uname -m)"
echo "node: $(node -v) arch=$(node -p "process.arch")"
"$CHROME_PATH" --version || true
- name: Run Lighthouse CI
run: |
# Give the server a moment to stabilize
sleep 10
echo "🚀 Starting Lighthouse CI performance testing..."
npx lhci autorun --chrome-path="$CHROME_PATH" --collect.url=http://127.0.0.1:3010/
env: { CI: true }
# ---- fixes end here ----
- name: Upload LHCI results
if: always()
uses: actions/upload-artifact@v3
with:
name: lhci-results
path: lhci-results
- name: Stop app
if: always()
run: |
if [ -f .next/runner.pid ]; then
kill $(cat .next/runner.pid) 2>/dev/null || true
fi
storybook:
runs-on: [self-hosted, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npm run storybook:build:github
- run: npm run test:sb
env: { CI: true }
lint:
runs-on: [self-hosted, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npm run lint
- run: npx prettier --check "**/*.{js,jsx,ts,tsx,json,css,md}"
build:
runs-on: [self-hosted, macos-latest]
steps:
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
with: { node-version: 20, cache: npm }
- run: npm ci
- run: npm run build
- run: npm run storybook:build:github