-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: Daniil Sapa <[email protected]>
- Loading branch information
1 parent
66d6f40
commit be217c4
Showing
36 changed files
with
1,992 additions
and
1,404 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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 |
---|---|---|
@@ -0,0 +1,70 @@ | ||
# This is the trusted counterpart of the Bundle size workflow. | ||
# It generates a report and posts a comment on the PR. | ||
|
||
name: Bundle size (trusted) | ||
|
||
on: | ||
workflow_run: | ||
workflows: [Bundle size] | ||
types: | ||
- completed | ||
|
||
permissions: | ||
pull-requests: write | ||
|
||
jobs: | ||
print: | ||
name: Print the sizes | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Download the sizes | ||
uses: actions/download-artifact@v4 | ||
with: | ||
merge-multiple: true | ||
path: '.' | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
run-id: ${{ github.event.workflow_run.id }} | ||
|
||
- name: Create the report | ||
id: create-report | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
script: | | ||
function parseDuOutput(output) { | ||
return Object.fromEntries(output.trim().split('\n').map(line => { | ||
const [size, folderName] = line.split(/\s+/); | ||
const [_packages, packageName, _dist] = folderName.split('/'); | ||
return [packageName, parseInt(size, 10)]; | ||
})); | ||
} | ||
function formatSize(sizeInBytes) { | ||
if (sizeInBytes < 1000) { | ||
return `${sizeInBytes} B`; | ||
} else { | ||
const sizeInKb = sizeInBytes / 1000; | ||
return `${sizeInKb.toFixed(2)} KB`; | ||
} | ||
} | ||
const fs = require('fs'); | ||
const sizes = parseDuOutput(fs.readFileSync(`sizes-${${{ toJson(github.base_ref) }}}.txt`, 'utf8')); | ||
const sizesPR = parseDuOutput(fs.readFileSync(`sizes-${${{ toJson(github.head_ref) }}}.txt`, 'utf8')); | ||
core.summary.addHeading('📊 Package size report', '3'); | ||
core.summary.addTable([ | ||
['Package', 'Before', 'After'].map((data) => ({ data, header: true })), | ||
...Object.keys(sizes).map((packageName) => { | ||
const size = sizes[packageName]; | ||
const sizePR = sizesPR[packageName]; | ||
return [packageName, formatSize(size), sizePR === size ? 'No change' : formatSize(sizePR)]; | ||
}), | ||
]); | ||
const report = core.summary.stringify(); | ||
core.summary.write(); | ||
return report; | ||
- name: Post the report to the PR | ||
uses: thollander/actions-comment-pull-request@24bffb9b452ba05a4f3f77933840a6a841d1b32b # v3.0.1 | ||
with: | ||
message: ${{ steps.create-report.outputs.result }} | ||
pr-number: ${{ github.event.workflow_run.pull_requests.number }} | ||
comment-tag: bundle-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,44 @@ | ||
# This workflow builds the packages on the base branch and the PR branch, and then records the sizes of the built packages. | ||
# The size comparison is done in a separate workflow because this one can't leave PR comments. | ||
|
||
name: Bundle size | ||
|
||
on: | ||
pull_request: | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.ref }} | ||
cancel-in-progress: true | ||
|
||
permissions: | ||
contents: read | ||
|
||
jobs: | ||
build: | ||
name: Build on the base branch and the PR branch | ||
strategy: | ||
matrix: | ||
branch: | ||
- ${{ github.base_ref }} | ||
- ${{ github.head_ref }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
ref: ${{ matrix.branch }} | ||
|
||
- name: Setup | ||
uses: ./.github/actions/setup | ||
|
||
- name: Build the packages | ||
run: turbo run build | ||
|
||
- name: Collect sizes in bytes | ||
id: sizes | ||
run: du -sb packages/*/dist > sizes-${{ matrix.branch }}.txt | ||
|
||
- name: Upload the sizes | ||
uses: actions/upload-artifact@v4 | ||
with: | ||
name: sizes-${{ matrix.branch }} | ||
path: sizes-${{ matrix.branch }}.txt |
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,53 @@ | ||
name: Publish Approved Pull Requests to pkg.pr.new | ||
on: | ||
pull_request_review: | ||
types: [submitted] | ||
|
||
permissions: | ||
contents: read | ||
pull-requests: read | ||
|
||
jobs: | ||
check: | ||
# First, trigger a permissions check on the user approving the pull request. | ||
if: github.event.review.state == 'approved' | ||
runs-on: ubuntu-latest | ||
outputs: | ||
has-permissions: ${{ steps.checkPermissions.outputs.result }} | ||
steps: | ||
- name: Check permissions | ||
id: checkPermissions | ||
uses: actions/github-script@v7 | ||
with: | ||
result-encoding: string | ||
# The approver must have write access to the repository to trigger the package preview. | ||
script: | | ||
const { data: { permission } } = | ||
await github.rest.repos.getCollaboratorPermissionLevel({ | ||
...context.repo, | ||
username: context.actor, | ||
}); | ||
return permission === 'write' || permission === 'admin'; | ||
publish: | ||
needs: check | ||
# Publish the preview package only if the permissions check passed. | ||
if: needs.check.outputs.has-permissions == 'true' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v4 | ||
|
||
- run: corepack enable | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 22 | ||
cache: 'pnpm' | ||
|
||
- name: Install dependencies | ||
run: pnpm install | ||
|
||
- name: Build | ||
run: pnpm exec turbo build | ||
|
||
- run: pnpm dlx pkg-pr-new publish './packages/*' |
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,25 +2,24 @@ | |
"name": "@steiger/root", | ||
"private": true, | ||
"scripts": { | ||
"format": "prettier --write . \"!packages/** !tooling/**\" --cache", | ||
"check-formatting": "prettier --check . \"!packages/** !tooling/**\" --cache", | ||
"format": "prettier --cache --write . \"!packages/**\" \"!tooling/**\"", | ||
"check-formatting": "prettier --cache --check . \"!packages/**\" \"!tooling/**\"", | ||
"check-monorepo": "manypkg check", | ||
"prepare": "husky" | ||
}, | ||
"engines": { | ||
"node": ">= 20" | ||
"node": ">= 18" | ||
}, | ||
"packageManager": "[email protected]", | ||
"dependencies": { | ||
"@changesets/cli": "^2.27.9", | ||
"@manypkg/cli": "^0.21.4", | ||
"devDependencies": { | ||
"@changesets/cli": "^2.27.10", | ||
"@manypkg/cli": "^0.23.0", | ||
"@steiger/eslint-config": "workspace:*", | ||
"@tsconfig/node-lts": "^20.1.3", | ||
"eslint": "^9.12.0", | ||
"husky": "^9.1.6", | ||
"eslint": "^9.16.0", | ||
"husky": "^9.1.7", | ||
"lint-staged": "^15.2.10", | ||
"prettier": "^3.3.3", | ||
"turbo": "^2.1.3" | ||
"prettier": "^3.4.2", | ||
"turbo": "^2.3.3" | ||
}, | ||
"lint-staged": { | ||
"*": "prettier --write --ignore-unknown", | ||
|
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
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
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
Oops, something went wrong.