Skip to content

Commit 622cd33

Browse files
authored
Merge pull request #5653 from NomicFoundation/galargh/bundle-sizes
ci: start tracking hardhat dependencies
2 parents 79e6db8 + ca4dc98 commit 622cd33

File tree

11 files changed

+118
-0
lines changed

11 files changed

+118
-0
lines changed

.github/workflows/v-next-ci.yml

+88
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ jobs:
4343
runs-on: ubuntu-latest
4444
outputs:
4545
packages: ${{ steps.filter.outputs.changes }}
46+
files: ${{ toJSON(steps.filter.outputs) }}
4647
steps:
4748
- uses: actions/checkout@v4
4849
- uses: actions/setup-node@v4
@@ -72,8 +73,95 @@ jobs:
7273
- id: filter
7374
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
7475
with:
76+
list-files: json
7577
filters: ${{ steps.generate.outputs.filters }}
7678

79+
bundle:
80+
# Depending on list-packages only to check whether pnpm-lock.yaml has changed
81+
# This could be handled by a simpler job, but an extra runner would have to be allocated for it
82+
needs: list-packages
83+
84+
if: |
85+
contains(fromJSON(needs.list-packages.outputs.files).hardhat_files, '.github/workflows/v-next-ci.yml') ||
86+
contains(fromJSON(needs.list-packages.outputs.files).hardhat_files, 'pnpm-lock.yaml')
87+
88+
# Using a matrix strategy even though there's only one package
89+
# because we will want to add, at least, hardhat-toolbox in the future
90+
strategy:
91+
fail-fast: false
92+
matrix:
93+
package: ['hardhat']
94+
95+
name: "[${{ matrix.package }}] bundle"
96+
runs-on: ubuntu-latest
97+
defaults:
98+
run:
99+
working-directory: v-next/${{ matrix.package }}
100+
steps:
101+
- uses: actions/checkout@v4
102+
- uses: ./.github/actions/setup-env
103+
with:
104+
node-version: 22
105+
- name: Install dependencies
106+
run: pnpm install --frozen-lockfile --prefer-offline
107+
- name: Build
108+
run: pnpm build
109+
# https://github.com/pnpm/pnpm/issues/6166
110+
- name: Deploy
111+
run: pnpm deploy --config.shamefully-hoist=true --config.hoist=true --config.node-linker=true --config.shared-workspace-lockfile=false --filter="$(jq -r .name package.json)" --prod --no-optional bundle
112+
- uses: actions/upload-artifact@v4
113+
with:
114+
name: ${{ matrix.package }}
115+
path: |
116+
v-next/${{ matrix.package }}/bundle
117+
118+
bundle-aggregate:
119+
needs: bundle
120+
121+
if: ${{ !cancelled() }}
122+
123+
name: bundle
124+
runs-on: ubuntu-latest
125+
126+
permissions:
127+
pull-requests: write
128+
129+
steps:
130+
- env:
131+
result: ${{ needs.bundle.result }}
132+
run: |
133+
if [[ "$result" == "failure" ]]; then
134+
exit 1
135+
fi
136+
shell: bash
137+
- uses: actions/download-artifact@v4
138+
- id: comment
139+
run: |
140+
echo 'body<<EOF' >> $GITHUB_OUTPUT
141+
for bundle in *; do
142+
echo "# $bundle" | tee -a $GITHUB_OUTPUT
143+
echo '' | tee -a $GITHUB_OUTPUT
144+
echo "Total size of the bundle: "'`'"$(du -sh $bundle --exclude=$bundle/node_modules/.pnpm | cut -f1)"'`' | tee -a $GITHUB_OUTPUT
145+
echo "Total number of dependencies (including transitive): "'`'"$(find $bundle/node_modules/@* $bundle/node_modules -mindepth 1 -maxdepth 1 -type d ! -name '.*' ! -name '@*' | wc -l)"'`' | tee -a $GITHUB_OUTPUT
146+
echo '' | tee -a $GITHUB_OUTPUT
147+
echo '<details>' | tee -a $GITHUB_OUTPUT
148+
echo '<summary>List of dependencies (sorted by size)</summary>' | tee -a $GITHUB_OUTPUT
149+
echo '' | tee -a $GITHUB_OUTPUT
150+
echo '```' | tee -a $GITHUB_OUTPUT
151+
du -shc $bundle/node_modules/@*/* $bundle/node_modules/* |
152+
grep -Ev '/node_modules/@[^/]+$' | sort -rh |
153+
sed "s|$bundle/node_modules/||" | tee -a $GITHUB_OUTPUT
154+
echo '```' | tee -a $GITHUB_OUTPUT
155+
echo '</details>' | tee -a $GITHUB_OUTPUT
156+
echo '' | tee -a $GITHUB_OUTPUT
157+
done
158+
echo 'EOF' >> $GITHUB_OUTPUT
159+
- if: github.event_name == 'pull_request'
160+
uses: marocchino/sticky-pull-request-comment@331f8f5b4215f0445d3c07b4967662a32a2d3e31 # v2.9.0
161+
with:
162+
header: bundle
163+
message: ${{ steps.comment.outputs.body }}
164+
77165
lint:
78166
needs: list-packages
79167

v-next/core/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,6 @@
1212

1313
# c8 output
1414
/coverage
15+
16+
# pnpm deploy output
17+
/bundle

v-next/example-project/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/hardhat-build-system/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/hardhat-errors/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/hardhat-node-test-reporter/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/hardhat-test-utils/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/hardhat-utils/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/hardhat-zod-utils/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/hardhat/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

v-next/template-package/.gitignore

+3
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,6 @@
33

44
# Compilation output
55
/dist
6+
7+
# pnpm deploy output
8+
/bundle

0 commit comments

Comments
 (0)