Add Google Lighthouse CI configuration and integration

Co-authored-by: ntindle <8845353+ntindle@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot]
2025-09-24 22:01:04 +00:00
parent fcc7c8e931
commit 6d52e89466
6 changed files with 1885 additions and 1 deletions

View File

@@ -233,3 +233,122 @@ jobs:
- name: Print Final Docker Compose logs
if: always()
run: docker compose -f ../docker-compose.yml logs
lighthouse:
runs-on: ubuntu-latest
needs: setup
# Only run Lighthouse on main branches to avoid excessive resource usage
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/dev' || github.event_name == 'pull_request'
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: "21"
- name: Enable corepack
run: corepack enable
- name: Copy default supabase .env
run: |
cp ../.env.default ../.env
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Cache Docker layers
uses: actions/cache@v4
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-lighthouse-${{ hashFiles('autogpt_platform/docker-compose.yml', 'autogpt_platform/backend/Dockerfile', 'autogpt_platform/backend/pyproject.toml', 'autogpt_platform/backend/poetry.lock') }}
restore-keys: |
${{ runner.os }}-buildx-lighthouse-
- name: Run docker compose
run: |
NEXT_PUBLIC_PW_TEST=true docker compose -f ../docker-compose.yml up -d
env:
DOCKER_BUILDKIT: 1
BUILDX_CACHE_FROM: type=local,src=/tmp/.buildx-cache
BUILDX_CACHE_TO: type=local,dest=/tmp/.buildx-cache-new,mode=max
- name: Move cache
run: |
rm -rf /tmp/.buildx-cache
if [ -d "/tmp/.buildx-cache-new" ]; then
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
fi
- name: Wait for services to be ready
run: |
echo "Waiting for rest_server to be ready..."
timeout 60 sh -c 'until curl -f http://localhost:8006/health 2>/dev/null; do sleep 2; done' || echo "Rest server health check timeout, continuing..."
echo "Waiting for database to be ready..."
timeout 60 sh -c 'until docker compose -f ../docker-compose.yml exec -T db pg_isready -U postgres 2>/dev/null; do sleep 2; done' || echo "Database ready check timeout, continuing..."
- name: Create E2E test data
run: |
echo "Creating E2E test data..."
# First try to run the script from inside the container
if docker compose -f ../docker-compose.yml exec -T rest_server test -f /app/autogpt_platform/backend/test/e2e_test_data.py; then
echo "✅ Found e2e_test_data.py in container, running it..."
docker compose -f ../docker-compose.yml exec -T rest_server sh -c "cd /app/autogpt_platform && python backend/test/e2e_test_data.py" || {
echo "❌ E2E test data creation failed!"
docker compose -f ../docker-compose.yml logs --tail=50 rest_server
exit 1
}
else
echo "⚠️ e2e_test_data.py not found in container, copying and running..."
# Copy the script into the container and run it
docker cp ../backend/test/e2e_test_data.py $(docker compose -f ../docker-compose.yml ps -q rest_server):/tmp/e2e_test_data.py || {
echo "❌ Failed to copy script to container"
exit 1
}
docker compose -f ../docker-compose.yml exec -T rest_server sh -c "cd /app/autogpt_platform && python /tmp/e2e_test_data.py" || {
echo "❌ E2E test data creation failed!"
docker compose -f ../docker-compose.yml logs --tail=50 rest_server
exit 1
}
fi
- name: Restore dependencies cache
uses: actions/cache@v4
with:
path: ~/.pnpm-store
key: ${{ needs.setup.outputs.cache-key }}
restore-keys: |
${{ runner.os }}-pnpm-${{ hashFiles('autogpt_platform/frontend/pnpm-lock.yaml') }}
${{ runner.os }}-pnpm-
- name: Install dependencies
run: pnpm install --no-frozen-lockfile
- name: Build application
run: NEXT_PUBLIC_PW_TEST=true pnpm build
- name: Wait for frontend to be ready
run: |
echo "Waiting for frontend container to be ready..."
timeout 60 sh -c 'until curl -f http://localhost:3000 2>/dev/null; do sleep 2; done' || {
echo "Frontend readiness check timeout"
exit 1
}
- name: Run Lighthouse CI
run: pnpm lighthouse
- name: Upload Lighthouse reports
if: always()
uses: actions/upload-artifact@v4
with:
name: lighthouse-reports
path: lhci_reports/
- name: Print Final Docker Compose logs
if: always()
run: docker compose -f ../docker-compose.yml logs

View File

@@ -57,4 +57,7 @@ storybook-static
.cursorrules
# Generated API files
src/app/api/__generated__/
src/app/api/__generated__/
# Lighthouse CI reports
lhci_reports/

View File

@@ -0,0 +1,26 @@
{
"ci": {
"collect": {
"url": [
"http://localhost:3000/",
"http://localhost:3000/build",
"http://localhost:3000/login"
],
"numberOfRuns": 3
},
"assert": {
"assertions": {
"categories:performance": ["warn", {"minScore": 0.7}],
"categories:accessibility": ["error", {"minScore": 0.9}],
"categories:best-practices": ["warn", {"minScore": 0.85}],
"categories:seo": ["warn", {"minScore": 0.85}],
"categories:pwa": "off"
}
},
"upload": {
"target": "filesystem",
"outputDir": "./lhci_reports",
"reportFilenamePattern": "%%PATHNAME%%-%%DATETIME%%-report.%%EXTENSION%%"
}
}
}

View File

@@ -0,0 +1,24 @@
{
"ci": {
"collect": {
"url": [
"http://localhost:3000/"
],
"numberOfRuns": 1
},
"assert": {
"assertions": {
"categories:performance": ["warn", {"minScore": 0.6}],
"categories:accessibility": ["warn", {"minScore": 0.8}],
"categories:best-practices": ["warn", {"minScore": 0.7}],
"categories:seo": ["warn", {"minScore": 0.7}],
"categories:pwa": "off"
}
},
"upload": {
"target": "filesystem",
"outputDir": "./lhci_reports",
"reportFilenamePattern": "local-%%PATHNAME%%-%%DATETIME%%-report.%%EXTENSION%%"
}
}
}

View File

@@ -18,6 +18,8 @@
"build-storybook": "storybook build",
"test-storybook": "test-storybook",
"test-storybook:ci": "concurrently -k -s first -n \"SB,TEST\" -c \"magenta,blue\" \"pnpm run build-storybook -- --quiet && npx http-server storybook-static --port 6006 --silent\" \"wait-on tcp:6006 && pnpm run test-storybook\"",
"lighthouse": "lhci autorun",
"lighthouse:local": "lhci autorun --config=./lighthouserc.local.json",
"generate:api": "npx --yes tsx ./scripts/generate-api-queries.ts && orval --config ./orval.config.ts",
"generate:api:force": "npx --yes tsx ./scripts/generate-api-queries.ts --force && orval --config ./orval.config.ts"
},
@@ -107,6 +109,7 @@
},
"devDependencies": {
"@chromatic-com/storybook": "4.1.1",
"@lhci/cli": "^0.15.0",
"@playwright/test": "1.55.0",
"@storybook/addon-a11y": "9.1.5",
"@storybook/addon-docs": "9.1.5",

File diff suppressed because it is too large Load Diff