From 1aee963ed2e783e627a0ecbc36091175bdfd081c Mon Sep 17 00:00:00 2001 From: Pauljd Date: Sat, 12 Sep 2026 20:34:44 +0100 Subject: [PATCH] Refine Lighthouse findings and project detection --- modules/detect.sh | 35 ++++++++++++++++++++++------------- scripts/parse-lighthouse.php | 9 ++++++++- 2 files changed, 30 insertions(+), 14 deletions(-) diff --git a/modules/detect.sh b/modules/detect.sh index 64e8293..b8d9bba 100755 --- a/modules/detect.sh +++ b/modules/detect.sh @@ -1,24 +1,37 @@ #!/bin/bash - set -euo pipefail echo "================================" echo " Davidson CI - Project Detection" echo "================================" -PHP_COUNT=$(find . -type f -name "*.php" \ - -not -path "*/vendor/*" | wc -l) +PHP_COUNT=$(find . \ + -type f \ + -name "*.php" \ + -not -path "*/vendor/*" \ + -not -path "./.davidson-ci/*" \ + | wc -l) -JS_COUNT=$(find . -type f \ +JS_COUNT=$(find . \ + -type f \ \( -name "*.js" -o -name "*.mjs" -o -name "*.cjs" \) \ - -not -path "*/node_modules/*" | wc -l) + -not -path "*/node_modules/*" \ + -not -path "./.davidson-ci/*" \ + | wc -l) -TS_COUNT=$(find . -type f \ +TS_COUNT=$(find . \ + -type f \ \( -name "*.ts" -o -name "*.tsx" \) \ - -not -path "*/node_modules/*" | wc -l) + -not -path "*/node_modules/*" \ + -not -path "./.davidson-ci/*" \ + | wc -l) -CSS_COUNT=$(find . -type f -name "*.css" \ - -not -path "*/node_modules/*" | wc -l) +CSS_COUNT=$(find . \ + -type f \ + -name "*.css" \ + -not -path "*/node_modules/*" \ + -not -path "./.davidson-ci/*" \ + | wc -l) FRONTEND_TYPE="none" LIGHTHOUSE_ELIGIBLE="false" @@ -26,11 +39,9 @@ LIGHTHOUSE_ELIGIBLE="false" if [ -f "./vite.config.js" ] || [ -f "./vite.config.ts" ]; then FRONTEND_TYPE="vite" LIGHTHOUSE_ELIGIBLE="true" - elif [ -f "./next.config.js" ] || [ -f "./next.config.mjs" ]; then FRONTEND_TYPE="next" LIGHTHOUSE_ELIGIBLE="true" - elif [ -f "./index.html" ]; then FRONTEND_TYPE="static" LIGHTHOUSE_ELIGIBLE="true" @@ -46,13 +57,11 @@ echo "Frontend: $FRONTEND_TYPE" echo "Lighthouse: $LIGHTHOUSE_ELIGIBLE" echo -# Make detection results available to later CI steps. { echo "DAVIDSON_PHP_COUNT=$PHP_COUNT" echo "DAVIDSON_JS_COUNT=$JS_COUNT" echo "DAVIDSON_TS_COUNT=$TS_COUNT" echo "DAVIDSON_CSS_COUNT=$CSS_COUNT" - echo "DAVIDSON_FRONTEND_TYPE=$FRONTEND_TYPE" echo "DAVIDSON_LIGHTHOUSE_ELIGIBLE=$LIGHTHOUSE_ELIGIBLE" } >> "${GITHUB_ENV:-/dev/null}" \ No newline at end of file diff --git a/scripts/parse-lighthouse.php b/scripts/parse-lighthouse.php index 540f097..91e1e6b 100644 --- a/scripts/parse-lighthouse.php +++ b/scripts/parse-lighthouse.php @@ -95,6 +95,7 @@ $skipModes = [ 'informative', 'manual', 'error', + 'numeric', ]; foreach ($data['audits'] ?? [] as $auditId => $audit) { @@ -113,9 +114,15 @@ foreach ($data['audits'] ?? [] as $auditId => $audit) { continue; } + $categories = $auditCategories[$auditId] ?? []; + + if ($categories === []) { + continue; + } + $findings[] = [ 'id' => $auditId, - 'categories' => $auditCategories[$auditId] ?? [], + 'categories' => $categories, 'title' => $audit['title'] ?? $auditId, 'problem' => $audit['description'] ?? '', 'impact' => $audit['displayValue'] ?? null,