Skip to content

Commit

Permalink
chore: add a comment to show comparison
Browse files Browse the repository at this point in the history
  • Loading branch information
m-shaka committed Sep 12, 2024
1 parent b8e866f commit 63778f4
Show file tree
Hide file tree
Showing 4 changed files with 67 additions and 3 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,34 @@ jobs:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: bun type-check-perf/generate-app.ts
- run: bun tsc -p type-check-perf/tsconfig.json --diagnostics
- run: bun generate-app.ts
working-directory: type-check-perf
- run: |
{
echo 'DIAGNOSTICS<<EOF'
bun tsc --diagnostics
echo 'EOF'
} >> "$GITHUB_ENV"
working-directory: type-check-perf
post-type-check-perf-on-pr:
runs-on: ubuntu-latest
needs: type-check-perf-monitoring
if: github.event_name == 'pull_request'
steps:
- uses: actions/checkout@v4
- uses: oven-sh/setup-bun@v1
- run: bun install
- run: echo -e $DIAGNOSTICS > current.txt
- run: |
{
echo 'COMPARISON<<EOF'
bun process-results.ts
echo 'EOF'
} >> "$GITHUB_ENV"
working-directory: type-check-perf
- uses: thollander/actions-comment-pull-request@v2
with:
comment_tag: type-check-perf
message: ${{ env.COMPARISON }}

17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -89,3 +89,20 @@ _RegExpRouter_, _SmartRouter_, _LinearRouter_, and _PatternRouter_ are created b
## License

Distributed under the MIT License. See [LICENSE](LICENSE) for more information.

| Metrics | Current | Previous() |
|---|---|---|
| Files | 247 | 247 |
| Lines | 113520 | 113520 |
| Identifiers | 110226 | 110226 |
| Symbols | 256205 | 256205 |
| Types | 214588 | 214588 |
| **Instantiations** | 3438524 | 3438524 |
| Memory used | 467326K | 463038K |
| I/O read | 0.02s | 0.02s |
| I/O write | 0.00s | 0.00s |
| Parse time | 0.39s | 0.44s |
| Bind time | 0.16s | 0.16s |
| Check time | 5.45s | 5.38s |
| Emit time | 0.00s | 0.00s |
| Total time | 6.00s | 5.97s |
19 changes: 19 additions & 0 deletions type-check-perf/process-results.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import * as fs from 'node:fs/promises'

Check warning on line 1 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L1

Added line #L1 was not covered by tests

async function main() {
const currentResult = (await fs.readFile('./result.txt')).toString().split('\n')
const previousResult = await fs.readFile('./main-result.txt')
.then((data) => data.toString().split('\n'))
.catch(() => null)

Check warning on line 7 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L3-L7

Added lines #L3 - L7 were not covered by tests
// currentResultとpreviousResultを結合してmarkdownのテーブルを作る
const table = ['| Metrics | Current | Previous |', '|---|---|---|']
for (const [i, line] of currentResult.entries()) {
if (line === '') continue;
const [name, value] = line.split(':')
const mainValue = previousResult?.[i]?.split(':')?.[1]
table.push(`| ${name?.trim()} | ${value?.trim()} | ${mainValue ? mainValue.trim() : 'N/A'} |`)
}
console.log(table.join('\n'))
}

Check warning on line 17 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L9-L17

Added lines #L9 - L17 were not covered by tests

main()

Check warning on line 19 in type-check-perf/process-results.ts

View check run for this annotation

Codecov / codecov/patch

type-check-perf/process-results.ts#L19

Added line #L19 was not covered by tests
3 changes: 2 additions & 1 deletion type-check-perf/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
"compilerOptions": {
"module": "esnext",
"noEmit": true,
"rootDir": ".."
"rootDir": "..",
"strict": true
},
"include": [
"**/*.ts",
Expand Down

0 comments on commit 63778f4

Please sign in to comment.