feat(ci): add automated Lighthouse audit pipeline #2

Merged
Lucas merged 12 commits from develop into master 2026-01-12 11:53:24 +00:00
2 changed files with 50 additions and 38 deletions
Showing only changes of commit c6b180ff45 - Show all commits

31
Jenkinsfile vendored
View File

@@ -18,18 +18,28 @@ pipeline {
}
stage('Lighthouse Audit') {
steps {
// Temporary container to get data in /dist folder
// Reuse of just build portfolio image
sh "mkdir -p ./dist-audit ./.lighthouseci"
// Create volumes but no run
sh "docker compose --profile audit create lighthouse-audit"
// Extract astro data from image to tmp-dist
sh "docker create --name audit-tmp portfolio:${env.APP_VERSION}"
sh "docker cp audit-tmp:/usr/share/caddy/. ./dist-audit"
sh "docker rm audit-tmp"
sh "mkdir -p ./tmp-dist"
sh "docker cp audit-tmp:/usr/share/caddy/. ./tmp-dist"
// Add audit config in the same folder
sh "cp .lighthouserc.cjs ./dist-audit/audit-config.cjs"
// Inject data from tmp-dist and config to audit container
sh "docker cp ./tmp-dist/. lighthouse-audit:/app/dist/"
sh "docker cp .lighthouserc.cjs lighthouse-audit:/app/dist/audit-config.cjs"
// Launch special service in docker compose
sh "docker compose --profile audit run --rm lighthouse-audit"
// Now run
sh "docker compose --profile audit run lighthouse-audit"
// Get reports
sh "mkdir -p ./.lighthouseci"
sh "docker cp lighthouse-audit:/app/.lighthouseci/. ./.lighthouseci/"
// Clean temp
sh "docker rm lighthouse-audit"
sh "rm -rf ./tmp-dist"
}
}
stage('Deploy') {
@@ -61,9 +71,8 @@ pipeline {
reportFiles: 'index.html',
reportName: 'Lighthouse Report'
])
echo "Clean unused image and files..."
echo "Clean unused image"
sh "docker image prune -f"
sh "rm -rf ./dist-audit"
}
success { echo "Success !" }
failure { echo "Failed." }

View File

@@ -18,14 +18,17 @@ services:
container_name: lighthouse-audit
user: "0:0"
volumes:
# astro file + config
- ./dist-audit:/app/dist
- ./.lighthouseci:/app/.lighthouseci
- audit_dist:/app/dist
- audit_reports:/app/.lighthouseci
environment:
- CHROME_PATH=/usr/bin/chromium-browser
working_dir: /app
command: npx @lhci/cli@${LHCI_VERSION} collect --config=/app/dist/audit-config.cjs
volumes:
audit_dist:
audit_reports:
networks:
reverse-proxy:
external: true