Skip to content

Commit

Permalink
bug(ci): manually set values for fair comparison (#824)
Browse files Browse the repository at this point in the history
  • Loading branch information
Idrinth authored Apr 16, 2024
1 parent 7c77a96 commit fecfe52
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 52 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/cli.codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
history-website/package-lock.json
cli/package-lock.json
package-lock.json
- name: Build cli
run: cd cli && npm ci
- run: cd cli && npm ci
- run: cd cli && npm run language
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/documentation-website.codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ jobs:
history-website/package-lock.json
cli/package-lock.json
package-lock.json
run: cd documentation-website && npm ci
- run: cd documentation-website && npm ci
- run: cd documentation-website && npm run language
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/framework.codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
history-website/package-lock.json
cli/package-lock.json
package-lock.json
- name: Build framework
run: cd framework && npm ci
- run: cd framework && npm ci
- run: cd framework && npm run language
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/history-microservice.codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
history-website/package-lock.json
cli/package-lock.json
package-lock.json
- name: Build history service
run: cd history-microservice && npm ci
- run: cd history-microservice && npm ci
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/history-website.codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@ jobs:
history-website/package-lock.json
cli/package-lock.json
package-lock.json
- name: Build history website
run: cd history-website && npm ci
- run: cd history-website && npm ci
- run: cd history-website && npm run language
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/mindmap.codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
history-website/package-lock.json
cli/package-lock.json
package-lock.json
- name: Build
run: cd mindmap && npm ci
- run: cd mindmap && npm ci
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
Expand Down
3 changes: 1 addition & 2 deletions .github/workflows/root.codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ jobs:
history-website/package-lock.json
cli/package-lock.json
package-lock.json
- name: Build root
run: npm ci
- run: npm ci
- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
Expand Down
72 changes: 33 additions & 39 deletions documentation-website/tools/lighthouse-report.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,51 +10,45 @@ const chrome = await chromeLauncher.launch({
},);

const options = {
logLevel: 'info',
logLevel: 'error',
output: 'json',
port: chrome.port,
};

try {
// eslint-disable-next-line max-len
const liveSiteReport = await lighthouse('https://idrinth-api-ben.ch/', options,);
const prod_report = JSON.parse(liveSiteReport.report,);
const devSiteReport = await lighthouse('http://localhost:8080/', options,);
const dev_report = JSON.parse(devSiteReport.report,);

const devSiteReport = await lighthouse('http://localhost:8080/', options,);
const dev_report = JSON.parse(devSiteReport.report,);

const metricFields = [
'performance',
'accessibility',
'best-practices',
'seo',
'pwa',
];

for (const metricField of metricFields) {
const devMetricScore = dev_report?.categories[metricField]?.score;
const prodMetricScore = prod_report?.categories[metricField]?.score;

if (! devMetricScore) {
throw new Error(
// eslint-disable-next-line max-len
`Failure in fetching metric score for current site, found ${ metricField } to be null`,
);
}
const metricFields = {
performance: 0.55,
accessibility: 0.85,
'best-practices': 1,
seo: 1,
pwa: 0.35,
};

if (devMetricScore < prodMetricScore) {
// eslint-disable-next-line no-console
console.error(
// eslint-disable-next-line max-len
`${ metricField } score reduced to ${ devMetricScore } from ${ prodMetricScore }`,
);
process.exitCode = EXIT_FAILURE;
}
for (const metricField of Object.keys(metricFields,)) {
const devMetricScore = dev_report?.categories[metricField]?.score;

if (! devMetricScore) {
// eslint-disable-next-line no-console
console.error(
// eslint-disable-next-line max-len
`Failure in fetching metric score for current site, found ${ metricField } to be null`,
);
process.exitCode = EXIT_FAILURE;
} else if (devMetricScore < metricFields[metricField]) {
// eslint-disable-next-line no-console
console.error(
// eslint-disable-next-line max-len
`${ metricField } score reduced to ${ devMetricScore } from ${ metricFields[metricField] }`,
);
process.exitCode = EXIT_FAILURE;
} else {
// eslint-disable-next-line no-console
console.error(
// eslint-disable-next-line max-len
`${ metricField } score is at ${ devMetricScore }`,
);
}
} catch (err) {
// eslint-disable-next-line no-console
console.error(err,);
process.exitCode = EXIT_FAILURE;
}

process.exit();

0 comments on commit fecfe52

Please sign in to comment.