Skip to content
Merged
Show file tree
Hide file tree
Changes from 10 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 37 additions & 0 deletions .github/workflows/on-main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "on #main"
Comment thread
NullVoxPopuli marked this conversation as resolved.
Outdated

on:
push:
branches:
- main

jobs:
build:
name: 'Build'
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: sudo snap install dust
- run: pnpm build

- name: "Get sizes for development outputs"
id: main-dev
run: |
mkdir -p main
cd dist
dust --ignore_hidden \
--reverse --apparent-size \
--filter ".+.js$" \
--no-percent-bars \
--only-file \
--full-paths > out.txt
cp out.txt ../main/


- uses: actions/upload-artifact@v4
with:
name: sizes-main
path: main/
overwrite: true
44 changes: 44 additions & 0 deletions .github/workflows/receive-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
#
# Do a build
# Measure assets sizes
# Upload artifact
# Consumed by size.yml for comparison
name: Receive PR
Comment thread
NullVoxPopuli marked this conversation as resolved.
Outdated

# read-only repo token
# no access to secrets
on:
pull_request:

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup
- run: pnpm build
- run: sudo snap install dust

- name: Save PR number
run: |
mkdir -p ./pr
echo ${{ github.event.number }} > ./pr/NR

- name: "Get sizes for development outputs"
id: dev
run: |
cd dist
dust --ignore_hidden \
--reverse --apparent-size \
--filter ".+.js$" \
--no-percent-bars \
--only-file \
--full-paths > pr/out.txt


- uses: actions/upload-artifact@v4
with:
name: pr
Comment thread
NullVoxPopuli marked this conversation as resolved.
Outdated
path: pr/
95 changes: 95 additions & 0 deletions .github/workflows/size.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: Size
Comment thread
NullVoxPopuli marked this conversation as resolved.
Outdated

# read-write repo token
# access to secrets
#
# https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
on:
workflow_run:
Comment thread
NullVoxPopuli marked this conversation as resolved.
workflows: ["Receive PR"]
types:
- completed

jobs:
compare_sizes:
name: 'Compare Sizes and Comment'
runs-on: 'ubuntu-latest'

steps:
- uses: actions/checkout@v4
Comment thread
NullVoxPopuli marked this conversation as resolved.
Outdated
with:
ref: main
- uses: ./.github/actions/setup
- run: sudo snap install dust
- run: pnpm build

- uses: actions/download-artifact@v4
with:
name: pr
run-id: ${{ github.event.workflow_run.id }}

- uses: actions/download-artifact@v4
with:
name: sizes-main

- name: "[PR] Get sizes for development outputs"
id: dev
run: |
cd pr/

echo 'sizes<<EOF' >> $GITHUB_OUTPUT
while IFS= read -r line; do
echo "$line" >> $GITHUB_OUTPUT
done <<< $(cat out.txt)
echo 'EOF' >> $GITHUB_OUTPUT
cat out.txt

- name: "[Main] Get sizes for development outputs"
id: main-dev
run: |
cd main/

echo 'sizes<<EOF' >> $GITHUB_OUTPUT
while IFS= read -r line; do
echo "$line" >> $GITHUB_OUTPUT
done <<< $(cat out.txt)
echo 'EOF' >> $GITHUB_OUTPUT
cat out.txt

#########################
# Intended Layout:
#
# | | This PR | Main |
# | Dev | x1 | y1 |
# | Prod | x2 | y2 |
#
# NOTE: we we don't have a prod build for this library
# because we currently expect non-compiler usage
# (so consumers should have terser or similar properly configured for DCE)
#
#########################
- uses: mshick/add-pr-comment@v2
with:
Comment thread
NullVoxPopuli marked this conversation as resolved.
message: |
<table><thead><tr><th></th><th>This PR</th><th>main</th></tr></thead>
<tbody>
<tr><td>Dev</td><td>

```
${{ steps.dev.outputs.sizes }}
```

</td><td>

```
${{ steps.main-dev.outputs.sizes }}
```

</td></tr>
</tbody></table>



env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

Loading