Skip to content

Commit

Permalink
feature/IVYPORTAL-17377-Create-pipeline-to-run-Lighthouse-report
Browse files Browse the repository at this point in the history
  • Loading branch information
nhthinh-axonivy committed Dec 27, 2024
1 parent 84a5956 commit 4f8dc88
Showing 1 changed file with 43 additions and 17 deletions.
60 changes: 43 additions & 17 deletions .github/workflows/lighthouse-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -178,24 +178,50 @@ jobs:
uses: actions/upload-artifact@v4
with:
name: lighthouse-report
path: lighthouse-report.html
path: |
AxonIvyPortal/portal-selenium-test/lighthouse/lighthouse-report.html
AxonIvyPortal/portal-selenium-test/lighthouse/lighthouse-reports/report.json
- name: Generate HTML Summary
run: |
node -e "
const core = require('@actions/core');
const fs = require('fs');
const path = require('path');
const htmlReport = fs.readFileSync('lighthouse-report.html', 'utf8');
const summary = core.summary
.addHeading('🚦 Lighthouse Audit Results')
.addRaw(htmlReport)
.addSeparator()
.addLink('📋 Download Full Report',
`https://github.com/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}/artifacts/${process.env.ARTIFACT_ID}`)
.write();
"
cd AxonIvyPortal/portal-selenium-test/lighthouse
if [ -f "lighthouse-report.html" ]; then
node -e "
const core = require('@actions/core');
const fs = require('fs');
const path = require('path');
try {
const htmlReport = fs.readFileSync('lighthouse-report.html', 'utf8');
const jsonReport = fs.readFileSync('lighthouse-reports/report.json', 'utf8');
const results = JSON.parse(jsonReport);
const summary = core.summary
.addHeading('🚦 Lighthouse Audit Results')
.addRaw('## Performance Scores\n\n');
// Add scores from JSON
Object.entries(results.categories).forEach(([key, value]) => {
summary.addRaw(`### ${value.title}\n📊 Score: ${Math.floor(value.score * 100)}%\n\n`);
});
summary
.addSeparator()
.addLink('📋 Download Full Report',
'https://github.com/' +
process.env.GITHUB_REPOSITORY +
'/actions/runs/' +
process.env.GITHUB_RUN_ID)
.write();
} catch (error) {
console.error('Error generating summary:', error);
process.exit(1);
}
"
else
echo "Lighthouse report file not found"
exit 1
fi
env:
ARTIFACT_ID: ${{ steps.upload-artifact.outputs.artifact-id }}
GITHUB_REPOSITORY: ${{ github.repository }}
GITHUB_RUN_ID: ${{ github.run_id }}

0 comments on commit 4f8dc88

Please sign in to comment.