|
43 | 43 | runs-on: ubuntu-latest
|
44 | 44 | outputs:
|
45 | 45 | packages: ${{ steps.filter.outputs.changes }}
|
| 46 | + files: ${{ toJSON(steps.filter.outputs) }} |
46 | 47 | steps:
|
47 | 48 | - uses: actions/checkout@v4
|
48 | 49 | - uses: actions/setup-node@v4
|
|
72 | 73 | - id: filter
|
73 | 74 | uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
|
74 | 75 | with:
|
| 76 | + list-files: json |
75 | 77 | filters: ${{ steps.generate.outputs.filters }}
|
76 | 78 |
|
| 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 | + |
77 | 165 | lint:
|
78 | 166 | needs: list-packages
|
79 | 167 |
|
|
0 commit comments