make: avoid fetching available LLVM revision #3961
Workflow file for this run
This file contains hidden or 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
| name: Binary size difference | |
| on: | |
| pull_request: | |
| concurrency: | |
| group: ${{ github.workflow }}-${{ github.ref }} | |
| cancel-in-progress: true | |
| jobs: | |
| sizediff: | |
| runs-on: ubuntu-24.04 | |
| permissions: | |
| pull-requests: write | |
| steps: | |
| # Prepare, install tools | |
| - name: Add GOBIN to $PATH | |
| run: | | |
| echo "$HOME/go/bin" >> $GITHUB_PATH | |
| - name: Install Go | |
| uses: actions/setup-go@v6 | |
| with: | |
| go-version: '~1.25' | |
| - name: Checkout | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 # fetch all history (no sparse checkout) | |
| submodules: true | |
| - uses: ./.github/actions/setup-llvm | |
| with: | |
| save-cache: "false" | |
| - name: Cache Go | |
| uses: actions/cache@v5 | |
| with: | |
| key: go-cache-linux-sizediff-v2-${{ hashFiles('go.mod') }} | |
| path: | | |
| ~/.cache/go-build | |
| ~/go/pkg/mod | |
| - run: make gen-device -j4 | |
| - name: Download drivers repo | |
| run: git clone https://github.com/tinygo-org/drivers.git | |
| - name: Save PR configuration | |
| id: pr | |
| run: | | |
| # Keep the action available after checking out the base commit. | |
| cp -r .github/actions/setup-llvm .github/actions/setup-llvm-base | |
| echo "base_sha=$(git rev-parse HEAD^1)" >> "$GITHUB_OUTPUT" | |
| echo "llvm_version=$(cat llvm-version.txt)" >> "$GITHUB_OUTPUT" | |
| # Compute sizes for the PR branch | |
| - name: Build tinygo binary for the PR branch | |
| run: make tinygo | |
| - name: Determine binary sizes on the PR branch | |
| run: | | |
| set -o pipefail | |
| export PATH="$PWD/build:$PATH" | |
| (cd drivers; make smoke-test | tee sizes-pr.txt) | |
| # Compute sizes for the dev branch | |
| - name: Checkout dev branch | |
| id: dev | |
| run: | | |
| git checkout --force "${{ steps.pr.outputs.base_sha }}" | |
| git submodule update --init | |
| rm -rf build | |
| git clean -fdX src/device | |
| export GOCACHE="$RUNNER_TEMP/go-build-base" | |
| export XDG_CACHE_HOME="$RUNNER_TEMP/cache-base" | |
| echo "GOCACHE=$GOCACHE" >> "$GITHUB_ENV" | |
| echo "XDG_CACHE_HOME=$XDG_CACHE_HOME" >> "$GITHUB_ENV" | |
| make gen-device -j4 | |
| echo "llvm_version=$(cat llvm-version.txt)" >> "$GITHUB_OUTPUT" | |
| - name: Remove LLVM build for the PR branch | |
| if: steps.pr.outputs.llvm_version != steps.dev.outputs.llvm_version | |
| run: rm -rf llvm-build llvm-project | |
| - name: Set up LLVM for the dev branch | |
| uses: ./.github/actions/setup-llvm-base | |
| if: steps.pr.outputs.llvm_version != steps.dev.outputs.llvm_version | |
| with: | |
| save-cache: "false" | |
| - name: Build tinygo binary for the dev branch | |
| run: make tinygo | |
| - name: Determine binary sizes on the dev branch | |
| run: | | |
| set -o pipefail | |
| export PATH="$PWD/build:$PATH" | |
| (cd drivers; make smoke-test | tee sizes-dev.txt) | |
| # Create comment | |
| # TODO: add a summary, something like: | |
| # - overall size difference (percent) | |
| # - number of binaries that grew / shrank / remained the same | |
| # - don't show the full diff when no binaries changed | |
| - name: Calculate size diff | |
| run: | | |
| set -o pipefail | |
| ./tools/sizediff drivers/sizes-dev.txt drivers/sizes-pr.txt | tee sizediff.txt | |
| - name: Create comment | |
| run: | | |
| echo "Size difference with the dev branch:" > comment.txt | |
| echo "<details><summary>Binary size difference</summary>" >> comment.txt | |
| echo "<pre>" >> comment.txt | |
| cat sizediff.txt >> comment.txt | |
| echo "</pre></details>" >> comment.txt | |
| - name: Comment contents | |
| run: cat comment.txt | |
| - name: Add comment | |
| if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} | |
| uses: thollander/actions-comment-pull-request@v2.3.1 | |
| with: | |
| GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
| filePath: comment.txt | |
| comment_tag: sizediff |