mirror of
https://github.com/honojs/hono.git
synced 2024-11-21 10:08:58 +01:00
ci: compare bundle size (#3661)
* ci: compare bundle size
* chore: change name of task
* for SDGs
* Revert "for SDGs"
This reverts commit 7861d1a5fe
.
* add gitignore
* update
* fix
This commit is contained in:
parent
a15bec3275
commit
53bd319b43
43
.github/workflows/ci.yml
vendored
43
.github/workflows/ci.yml
vendored
@ -182,6 +182,7 @@ jobs:
|
||||
path: coverage/
|
||||
|
||||
perf-measures-type-check-on-pr:
|
||||
name: 'Type Check on PR'
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event_name == 'pull_request'
|
||||
steps:
|
||||
@ -209,6 +210,7 @@ jobs:
|
||||
name: display comparison
|
||||
|
||||
perf-measures-type-check-on-main:
|
||||
name: 'Type Check on Main'
|
||||
runs-on: ubuntu-latest
|
||||
if: github.ref == 'refs/heads/main'
|
||||
steps:
|
||||
@ -223,3 +225,44 @@ jobs:
|
||||
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 }}
|
2
perf-measures/bundle-check/.gitignore
vendored
Normal file
2
perf-measures/bundle-check/.gitignore
vendored
Normal file
@ -0,0 +1,2 @@
|
||||
generated
|
||||
!generated/.gitkeep
|
0
perf-measures/bundle-check/generated/.gitkeep
Normal file
0
perf-measures/bundle-check/generated/.gitkeep
Normal file
14
perf-measures/bundle-check/scripts/process-results.ts
Normal file
14
perf-measures/bundle-check/scripts/process-results.ts
Normal file
@ -0,0 +1,14 @@
|
||||
import * as fs from 'node:fs/promises'
|
||||
|
||||
async function main() {
|
||||
const currentResult = (await fs.readFile('./generated/after.js')).byteLength
|
||||
let previousResult: number | null = null
|
||||
try {
|
||||
previousResult = (await fs.readFile('./generated/before.js')).byteLength
|
||||
} catch (e) {}
|
||||
const table = ['| | Current | Previous |', '| --- | --- | --- |']
|
||||
table.push(`| Bundle Size | ${currentResult} | ${previousResult || 'N/A'} |`)
|
||||
console.log(table.join('\n'))
|
||||
}
|
||||
|
||||
main()
|
Loading…
Reference in New Issue
Block a user