Skip to content
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

Merged
merged 34 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
d166c17
Debug result
k2tzumi Oct 5, 2024
0ef0296
Fix
k2tzumi Oct 5, 2024
88844ad
Refactoring to convert standard input to json format for custom metri…
k2tzumi Oct 5, 2024
9ccd330
Custom metrics are now output as comments in Pull Reqeust
k2tzumi Oct 5, 2024
94181b5
Fix `undefined is not an object (evaluating 'line.split')`
k2tzumi Oct 5, 2024
5543989
Add check to make sure line is not undefined
k2tzumi Oct 5, 2024
a27e3ca
Merge pull request #1 from k2tzumi/octocov-custom-metrix
k2tzumi Oct 5, 2024
6b36a6c
Merge branch 'honojs:main' into main
k2tzumi Oct 12, 2024
53e17a7
Debug result
k2tzumi Oct 5, 2024
759489a
Fix
k2tzumi Oct 5, 2024
5d7db19
Refactoring to convert standard input to json format for custom metri…
k2tzumi Oct 5, 2024
f3b05fe
Custom metrics are now output as comments in Pull Reqeust
k2tzumi Oct 5, 2024
00ff3d0
Fix `undefined is not an object (evaluating 'line.split')`
k2tzumi Oct 5, 2024
9d9c15a
Add check to make sure line is not undefined
k2tzumi Oct 5, 2024
f1eead4
Merge branch 'main' into octocov-custom-metrix
k2tzumi Nov 16, 2024
be560f1
Merge remote-tracking branch 'origin'
k2tzumi Nov 16, 2024
982d6d1
Merge branch 'main' into octocov-custom-metrix
k2tzumi Nov 16, 2024
86ac9b3
Move path to parent directory to consolidate multiple metrics and out…
k2tzumi Nov 17, 2024
f458f5e
Refactoring to convert to octocov custom metrics format
k2tzumi Nov 17, 2024
16e5312
The two performance measurement jobs were merged and compared output …
k2tzumi Nov 17, 2024
9822436
Append unit
k2tzumi Nov 17, 2024
7aba3c2
bonsai
k2tzumi Nov 17, 2024
2715eec
Review of title
k2tzumi Nov 17, 2024
ebe43e0
Merge branch 'main' of https://github.com/k2tzumi/hono
k2tzumi Nov 18, 2024
8c37498
Merge remote-tracking branch 'origin' into octocov-custom-metrix
k2tzumi Nov 18, 2024
2d78668
Integrate bundling and size check processes
k2tzumi Nov 18, 2024
28fcd2c
Fix code style
k2tzumi Nov 18, 2024
6a43d74
bonsai
k2tzumi Nov 18, 2024
96999ad
Fix
k2tzumi Nov 18, 2024
bce772b
Merge pull request #3 from k2tzumi/octocov-custom-metrix
k2tzumi Nov 18, 2024
c7d053e
refs https://github.com/k2tzumi/hono/actions/runs/11903022493/job/331…
k2tzumi Nov 18, 2024
7853b3e
Merge pull request #4 from k2tzumi/octocov-custom-metrix
k2tzumi Nov 18, 2024
188c1bf
Merge branch 'honojs:main' into main
k2tzumi Nov 18, 2024
8ba2da0
Fix lint & code style
k2tzumi Nov 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
105 changes: 35 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -181,88 +181,53 @@ jobs:
name: coverage-lambda-edge
path: coverage/

perf-measures-type-check-on-pr:
name: 'Type Check on PR'
perf-measures-type-and-bundle-check-on-pr:
name: 'Type & Bundle size Check on PR'
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- uses: actions/cache/restore@v4
with:
path: perf-measures/type-check/previous-result.txt
restore-keys: |
type-check-perf-previous-result-
key: type-check-perf-previous-result-
- run: bun scripts/generate-app.ts
working-directory: perf-measures/type-check
- run: bun tsc -p tsconfig.build.json --diagnostics > result.txt
- name: Performance measurement of type check
run: |
bun scripts/generate-app.ts
bun tsc -p tsconfig.build.json --diagnostics | bun scripts/process-results.ts > diagnostics.json
working-directory: perf-measures/type-check
- run: |
{
echo 'COMPARISON<<EOF'
bun scripts/process-results.ts | column -s '|' -t
echo 'EOF'
} >> "$GITHUB_ENV"
working-directory: perf-measures/type-check
- run: echo "$COMPARISON"
name: display comparison
- name: Performance measurement of bundle check
run: |
bun run build
bun perf-measures/bundle-check/scripts/check-bundle-size.ts > perf-measures/bundle-check/size.json
- name: Run octocov
uses: k1LoW/octocov-action@v1
with:
config: perf-measures/.octocov.perf-measures.yml
env:
OCTOCOV_CUSTOM_METRICS_BENCHMARK_BUNDLE: perf-measures/bundle-check/size.json
OCTOCOV_CUSTOM_METRICS_BENCHMARK_TYPE: perf-measures/type-check/diagnostics.json
yusukebe marked this conversation as resolved.
Show resolved Hide resolved

perf-measures-type-check-on-main:
name: 'Type Check on Main'
perf-measures-type-and-bundle-check-on-main:
name: 'Type & Bundle size Check on Main'
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun scripts/generate-app.ts
- name: Performance measurement of type check
run: |
bun scripts/generate-app.ts
bun tsc -p tsconfig.build.json --diagnostics | bun scripts/process-results.ts > diagnostics.json
working-directory: perf-measures/type-check
- run: bun tsc -p tsconfig.build.json --diagnostics > previous-result.txt
working-directory: perf-measures/type-check
- uses: actions/cache/save@v4
with:
path: perf-measures/type-check/previous-result.txt
key: type-check-perf-previous-result-${{ github.sha }}

perf-measures-bundle-check-on-pr:
name: 'Bundle Check on PR'
runs-on: ubuntu-latest
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run build
- run: bunx esbuild --minify --bundle dist/index.js --format=esm --outfile=perf-measures/bundle-check/generated/after.js
- uses: actions/cache/restore@v4
with:
path: perf-measures/bundle-check/generated/before.js
restore-keys: |
perf-measures-bundle-check-previous-file-
key: perf-measures-bundle-check-previous-file-
- run: |
{
echo 'COMPARISON<<EOF'
bun scripts/process-results.ts | column -s '|' -t
echo 'EOF'
} >> "$GITHUB_ENV"
working-directory: perf-measures/bundle-check
- run: echo "$COMPARISON"
name: display comparison

perf-measures-bundle-check-on-main:
name: 'Bundle Check on Main'
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v2
- run: bun install
- run: bun run build
- run: bunx esbuild --minify --bundle dist/index.js --format=esm --outfile=perf-measures/bundle-check/generated/before.js
- uses: actions/cache/save@v4
with:
path: perf-measures/bundle-check/generated/before.js
key: perf-measures-bundle-check-previous-file-${{ github.sha }}
- name: Performance measurement of bundle check
run: |
bun run build
bun perf-measures/bundle-check/scripts/check-bundle-size.ts > perf-measures/bundle-check/size.json
- name: Run octocov (main)
uses: k1LoW/octocov-action@v1
with:
config: perf-measures/.octocov.perf-measures.main.yml
env:
OCTOCOV_GITHUB_REF: refs/heads/main
OCTOCOV_CUSTOM_METRICS_BENCHMARK_BUNDLE: perf-measures/bundle-check/size.json
yusukebe marked this conversation as resolved.
Show resolved Hide resolved
OCTOCOV_CUSTOM_METRICS_BENCHMARK_TYPE: perf-measures/type-check/diagnostics.json
13 changes: 13 additions & 0 deletions perf-measures/.octocov.perf-measures.main.yml
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
15 changes: 15 additions & 0 deletions perf-measures/.octocov.perf-measures.yml
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
1 change: 1 addition & 0 deletions perf-measures/bundle-check/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
generated
!generated/.gitkeep
size.json
43 changes: 43 additions & 0 deletions perf-measures/bundle-check/scripts/check-bundle-size.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
import * as esbuild from 'esbuild'
import * as fs from 'node:fs'
import * as os from 'os'
import * as path from 'path'

async function main() {
const tempDir = os.tmpdir()
const tempFilePath = path.join(tempDir, 'bundle.tmp.js')

try {
await esbuild.build({
entryPoints: ['dist/index.js'],
bundle: true,
minify: true,
format: 'esm' as esbuild.Format,
target: 'es2022',
outfile: tempFilePath,
})
yusukebe marked this conversation as resolved.
Show resolved Hide resolved

const bundleSize = fs.statSync(tempFilePath).size
const metrics = []
metrics.push({
key: 'bundle-size',
name: 'Bundle Size',
value: bundleSize,
unit: 'B',
})
const benchmark = {
key: 'bundle-size-check',
name: 'Bundle size check',
metrics,
}
console.log(JSON.stringify(benchmark, null, 2))
} catch (error) {
console.error('Build failed:', error)
} finally {
if (fs.existsSync(tempFilePath)) {
fs.unlinkSync(tempFilePath)
}
}
}

main()
14 changes: 0 additions & 14 deletions perf-measures/bundle-check/scripts/process-results.ts

This file was deleted.

1 change: 1 addition & 0 deletions perf-measures/type-check/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ generated
!generated/.gitkeep
trace
*result.txt
diagnostics.json
49 changes: 37 additions & 12 deletions perf-measures/type-check/scripts/process-results.ts
Original file line number Diff line number Diff line change
@@ -1,21 +1,46 @@
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 === '') {
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 benchmark = {
key: 'diagnostics',
name: 'Compiler Diagnostics',
metrics,
}
console.log(table.join('\n'))
console.log(JSON.stringify(benchmark, null, 2))
}

main()
Loading