ci: Type check perf (#3406)
Before adoption: this commit came in with the history the project adopted, so no landing records it.
* chore: add scripts to monitor type check performance * chore: add jobs for type-check-perf-monitoring * chore: rm a comment * refactor: mv type-check-perf perf-measures/type-check * rm .eslintrc.cjs * chore: ignore *result.txt
authored by m-shaka · committed by GitHub · parent dfbd717 · Browse files · 9 files·+120 added−0 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
9 files+120 added−0 removed
- other:+120 added−0 removed
Provenance
- Commit
66df4e1- Tree
93c6b85- Author
m-shaka <buddha0818@gmail.com>- Committer
GitHub <noreply@github.com>- Parent
dfbd717
9 files changed+120 added−0 removed
modified:.github/workflows/ci.yml+51 added
175 unmodified lines176 - uses: actions/upload-artifact@v4177 with:178 name: coverage-lambda-edge179 path: coverage/180+181+ perf-measures-type-check-on-pr:182+ runs-on: ubuntu-latest183+ permissions:184+ contents: 'read'185+ pull-requests: 'write'186+ if: github.event_name == 'pull_request'187+ steps:188+ - uses: actions/checkout@v4189+ - uses: oven-sh/setup-bun@v1190+ - run: bun install191+ - uses: actions/cache/restore@v4192+ with:193+ path: perf-measures/type-check/previous-result.txt194+ restore-keys: |195+ type-check-perf-previous-result-196+ key: type-check-perf-previous-result-197+ - run: bun scripts/generate-app.ts198+ working-directory: perf-measures/type-check199+ - run: bun tsc -p tsconfig.build.json --diagnostics > result.txt200+ working-directory: perf-measures/type-check201+ - run: |202+ {203+ echo 'COMPARISON<<EOF'204+ bun scripts/process-results.ts205+ echo 'EOF'206+ } >> "$GITHUB_ENV"207+ working-directory: perf-measures/type-check208+ - run: echo "$COMPARISON"209+ # remove the comment out after we make sure that caching is working210+ # - uses: thollander/actions-comment-pull-request@v2211+ # with:212+ # comment_tag: perf-measures/type-check213+ # message: ${{ env.COMPARISON }}214+215+216+ perf-measures-type-check-on-main:217+ runs-on: ubuntu-latest218+ if: github.ref == 'refs/heads/main'219+ steps:220+ - uses: actions/checkout@v4221+ - uses: oven-sh/setup-bun@v1222+ - run: bun install223+ - run: bun scripts/generate-app.ts224+ working-directory: perf-measures/type-check225+ - run: bun tsc -p tsconfig.build.json --diagnostics > previous-result.txt226+ working-directory: perf-measures/type-check227+ - uses: actions/cache/save@v4228+ with:229+ path: perf-measures/type-check/previous-result.txt230+ key: type-check-perf-previous-result-${{ github.sha }}added:perf-measures/type-check/generated/.gitkeep
added:perf-measures/type-check/scripts/generate-app.ts+25 added
12345678910111213141516171819202122232425import { writeFile } from 'node:fs'import * as path from 'node:path'
const count = 200
const generateRoutes = (count: number) => { let routes = `import { Hono } from '../../../src'export const app = new Hono()` for (let i = 1; i <= count; i++) { routes += ` .get('/route${i}/:id', (c) => { return c.json({ ok: true }) })` } return routes}
const routes = generateRoutes(count)
writeFile(path.join(import.meta.dirname, '../generated/app.ts'), routes, (err) => { if (err) { throw err } console.log(`${count} routes have been written to app.ts`)})added:perf-measures/type-check/scripts/process-results.ts+18 added
123456789101112131415161718import * as fs from 'node:fs/promises'
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 [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'))}
main()added:perf-measures/type-check/.gitignore+4 added
1+generated2+!generated/.gitkeep3+trace4+*result.txtadded:perf-measures/type-check/client.ts+4 added
1234import type { app } from './generated/app'import { hc } from '../../src/client'
const client = hc<typeof app>('/')added:perf-measures/type-check/tsconfig.build.json+4 added
1234{ "extends": "../tsconfig.json", "include": ["client.ts"]}added:perf-measures/tsconfig.json+13 added
12345678910111213{ "extends": "../tsconfig.json", "compilerOptions": { "module": "esnext", "noEmit": true, "rootDir": "..", "strict": true }, "include": [ "**/*.ts", "**/*.tsx" ]}modified:vitest.config.ts+1 added
20 unmodified lines21 'benchmarks',22 'runtime-tests',23 'build.ts',24 'src/test-utils',25+ 'perf-measures',26 27 // types are compile-time only, so their coverage cannot be measured28 'src/**/types.ts',29 'src/jsx/intrinsic-elements.ts',6 unmodified lines