-
-
Notifications
You must be signed in to change notification settings - Fork 574
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1 from k2tzumi/octocov-custom-metrix
Display performance measurement results as custom metrics
- Loading branch information
Showing
4 changed files
with
86 additions
and
36 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
locale: "en" | ||
repository: ${GITHUB_REPOSITORY}/perf-measures | ||
coverage: | ||
if: false | ||
codeToTestRatio: | ||
if: false | ||
testExecutionTime: | ||
if: false | ||
report: | ||
datastores: | ||
- artifact://${GITHUB_REPOSITORY} | ||
summary: | ||
if: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
locale: "en" | ||
repository: ${GITHUB_REPOSITORY}/perf-measures | ||
coverage: | ||
if: false | ||
codeToTestRatio: | ||
if: false | ||
testExecutionTime: | ||
if: false | ||
diff: | ||
datastores: | ||
- artifact://${GITHUB_REPOSITORY} | ||
comment: | ||
if: is_pull_request | ||
summary: | ||
if: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,44 @@ | ||
import * as fs from 'node:fs/promises' | ||
import * as readline from 'node:readline'; | ||
|
||
async function main() { | ||
const currentResult = (await fs.readFile('./result.txt')).toString().split('\n') | ||
const previousResult = await fs.readFile('./previous-result.txt') | ||
.then((data) => data.toString().split('\n')) | ||
.catch(() => null) | ||
const table = ['| | Current | Previous |', '| --- | --- | --- |'] | ||
for (const [i, line] of currentResult.entries()) { | ||
if (line === '') {continue} | ||
const rl = readline.createInterface({ | ||
input: process.stdin, | ||
output: process.stdout, | ||
terminal: false | ||
}) | ||
const toKebabCase = (str: string): string => { | ||
return str | ||
.replace(/([a-z])([A-Z])/g, '$1-$2') | ||
.replace(/[\s_\/]+/g, '-') | ||
.toLowerCase() | ||
} | ||
const metrics = [] | ||
for await (const line of rl) { | ||
if (!line || line.trim() === '') continue | ||
const [name, value] = line.split(':') | ||
const mainValue = previousResult?.[i]?.split(':')?.[1] | ||
table.push(`| ${name?.trim()} | ${value?.trim()} | ${mainValue ? mainValue.trim() : 'N/A'} |`) | ||
const unitMatch = value?.trim().match(/^(\d+(\.\d+)?)([a-zA-Z]*)$/) | ||
if (unitMatch) { | ||
const [, number, , unit] = unitMatch; | ||
metrics.push({ | ||
key: toKebabCase(name?.trim()), | ||
name: name?.trim(), | ||
value: parseFloat(number), | ||
unit: unit || undefined | ||
}) | ||
} else { | ||
metrics.push({ | ||
key: toKebabCase(name?.trim()), | ||
name: name?.trim(), | ||
value: parseFloat(value?.trim()), | ||
}) | ||
} | ||
} | ||
const diagnostics = { | ||
key: "diagnostics", | ||
name: "Compiler Diagnostics", | ||
metrics | ||
} | ||
console.log(table.join('\n')) | ||
console.log(JSON.stringify(diagnostics, null, 2)) | ||
} | ||
|
||
main() |