diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4daa0ea1..3a6b109e 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -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<> "$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 }} \ No newline at end of file diff --git a/perf-measures/bundle-check/.gitignore b/perf-measures/bundle-check/.gitignore new file mode 100644 index 00000000..49795c58 --- /dev/null +++ b/perf-measures/bundle-check/.gitignore @@ -0,0 +1,2 @@ +generated +!generated/.gitkeep diff --git a/perf-measures/bundle-check/generated/.gitkeep b/perf-measures/bundle-check/generated/.gitkeep new file mode 100644 index 00000000..e69de29b diff --git a/perf-measures/bundle-check/scripts/process-results.ts b/perf-measures/bundle-check/scripts/process-results.ts new file mode 100644 index 00000000..e570a188 --- /dev/null +++ b/perf-measures/bundle-check/scripts/process-results.ts @@ -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()