-
-
Notifications
You must be signed in to change notification settings - Fork 574
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ci: Display performance measurement results as custom metrics #3491
Open
k2tzumi
wants to merge
6
commits into
honojs:main
Choose a base branch
from
k2tzumi:octocov-custom-metrix
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+86
−35
Open
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
53e17a7
Debug result
k2tzumi 759489a
Fix
k2tzumi 5d7db19
Refactoring to convert standard input to json format for custom metri…
k2tzumi f3b05fe
Custom metrics are now output as comments in Pull Reqeust
k2tzumi 00ff3d0
Fix `undefined is not an object (evaluating 'line.split')`
k2tzumi 9d9c15a
Add check to make sure line is not undefined
k2tzumi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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() |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Delete this line if you do not need it to appear as a comment in every Pull Request.
You can also check the summary only.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How do you think we should enable or disable it? It's cool that the performance measuring result is posted to PR as a comment, but currently, it is only a TypeScript type performance. Many PRs are not related to the type definition, so it may not be important for them.
CC: @m-shaka
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
People often ignore such an automated comment, so it may not be a problem
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We believe that the comment display itself should always be displayed when measuring performance. Displaying comments makes people aware of performance.
I thought that the essential answer to this question is that we should consider not nudging the
perf-measures-type-check-on-pr
Job for PRs that do not affect TypeScript type performance.It is possible to specify a path base for the execution condition of a GHA job, but is the following the only files that affect TypeScript type performance?
If the source itself that measures performance is changed, it is also necessary to run the job
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@m-shaka @k2tzumi Thank you for the comment!
I see!
We have to add the following files that affect application type definitions:
src/types.ts
src/hono-base.ts
src/request.ts
src/context.ts
src/validator/validator.ts
- it can be used in the RPC-mode.@m-shaka
What do you think of this?