-
-
Notifications
You must be signed in to change notification settings - Fork 344
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: dist file size chekcing with github actions (#2063)
* chore: dist file size chekcing with github actions * fix: size checking scripts * fix: add size reporting scripts * fix: add github action workflows * fix: tweak workflow name * fix: add test for size reporting with workflow dispatch
- Loading branch information
Showing
13 changed files
with
445 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
name: nightly release | ||
name: Nightly release | ||
on: | ||
push: | ||
branches: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
name: Size data | ||
|
||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
upload: | ||
if: github.repository == 'intlify/vue-i18n' | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout codes | ||
uses: actions/checkout@v4 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/[email protected] | ||
|
||
- name: Setup node | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 23 | ||
cache: pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Check size | ||
run: pnpm size | ||
|
||
- name: Save PR number & base branch | ||
if: ${{github.event_name == 'pull_request'}} | ||
run: | | ||
echo ${{ github.event.number }} > ./temp/size/number.txt | ||
echo ${{ github.base_ref }} > ./temp/size/base.txt | ||
- name: Upload Size Data | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: size-data | ||
path: temp/size |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,83 @@ | ||
name: Size report | ||
|
||
on: | ||
workflow_run: | ||
workflows: ['Size data'] | ||
types: | ||
- completed | ||
workflow_dispatch: | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: write | ||
issues: write | ||
|
||
jobs: | ||
size-report: | ||
runs-on: ubuntu-latest | ||
if: > | ||
github.repository == 'intlify/vue-i18n' && | ||
github.event.workflow_run.event == 'pull_request' && | ||
github.event.workflow_run.conclusion == 'success' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- name: Install pnpm | ||
uses: pnpm/[email protected] | ||
|
||
- name: Install Node.js | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 23 | ||
cache: pnpm | ||
|
||
- name: Install dependencies | ||
run: pnpm install --frozen-lockfile | ||
|
||
- name: Download Size Data | ||
uses: dawidd6/action-download-artifact@v6 | ||
with: | ||
name: size-data | ||
run_id: ${{ github.event.workflow_run.id }} | ||
path: temp/size | ||
|
||
- name: Read PR Number | ||
id: pr-number | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: temp/size/number.txt | ||
|
||
- name: Read base branch | ||
id: pr-base | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: temp/size/base.txt | ||
|
||
- name: Download Previous Size Data | ||
uses: dawidd6/action-download-artifact@v6 | ||
with: | ||
branch: ${{ steps.pr-base.outputs.content }} | ||
workflow: size-data.yml | ||
event: push | ||
name: size-data | ||
path: temp/size-prev | ||
if_no_artifact_found: warn | ||
|
||
- name: Prepare report | ||
run: npx tsx scripts/size-report.ts > size-report.md | ||
|
||
- name: Read Size Report | ||
id: size-report | ||
uses: juliangruber/read-file-action@v1 | ||
with: | ||
path: ./size-report.md | ||
|
||
- name: Create Comment | ||
uses: actions-cool/maintain-one-comment@v3 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
number: ${{ steps.pr-number.outputs.content }} | ||
body: | | ||
${{ steps.size-report.outputs.content }} | ||
<!-- INTLIFY_VUE_I18N_SIZE --> | ||
body-include: '<!-- INTLIFY_VUE_I18N_SIZE -->' |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { brotliCompressSync, gzipSync } from 'node:zlib' | ||
import { build } from 'vite' | ||
|
||
const generated = await build({ | ||
logLevel: 'silent', | ||
build: { | ||
minify: true | ||
} | ||
}) | ||
const bundled = generated.output[0].code | ||
|
||
const size = bundled.length | ||
const gzip = gzipSync(bundled).length | ||
const brotli = brotliCompressSync(bundled).length | ||
|
||
const report = { | ||
name: '@intlify/core', | ||
size, | ||
gzip, | ||
brotli | ||
} | ||
console.log(JSON.stringify(report)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { brotliCompressSync, gzipSync } from 'node:zlib' | ||
import { build } from 'vite' | ||
|
||
const generated = await build({ | ||
logLevel: 'silent', | ||
build: { | ||
minify: true | ||
} | ||
}) | ||
const bundled = generated.output[0].code | ||
|
||
const size = bundled.length | ||
const gzip = gzipSync(bundled).length | ||
const brotli = brotliCompressSync(bundled).length | ||
|
||
const report = { | ||
name: 'petite-vue-i18n', | ||
size, | ||
gzip, | ||
brotli | ||
} | ||
console.log(JSON.stringify(report)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { brotliCompressSync, gzipSync } from 'node:zlib' | ||
import { build } from 'vite' | ||
|
||
const generated = await build({ | ||
logLevel: 'silent', | ||
build: { | ||
minify: true | ||
} | ||
}) | ||
const bundled = generated.output[0].code | ||
|
||
const size = bundled.length | ||
const gzip = gzipSync(bundled).length | ||
const brotli = brotliCompressSync(bundled).length | ||
|
||
const report = { | ||
name: 'vue-i18n', | ||
size, | ||
gzip, | ||
brotli | ||
} | ||
console.log(JSON.stringify(report)) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,6 @@ | |
|
||
set -e | ||
|
||
pnpm build --withTypes --size | ||
pnpm build --withTypes | ||
|
||
tsx ./scripts/postprocess.ts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.