github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/.github/workflows/sizediff.yml (about) 1 name: Binary size difference 2 3 on: 4 pull_request: 5 6 concurrency: 7 group: ${{ github.workflow }}-${{ github.ref }} 8 cancel-in-progress: true 9 10 jobs: 11 sizediff: 12 runs-on: ubuntu-22.04 13 permissions: 14 pull-requests: write 15 steps: 16 # Prepare, install tools 17 - name: Add GOBIN to $PATH 18 run: | 19 echo "$HOME/go/bin" >> $GITHUB_PATH 20 - name: Checkout 21 uses: actions/checkout@v4 22 with: 23 fetch-depth: 0 # fetch all history (no sparse checkout) 24 submodules: true 25 - name: Install apt dependencies 26 run: ./.github/workflows/sizediff-install-pkgs.sh 27 - name: Restore LLVM source cache 28 uses: actions/cache@v4 29 id: cache-llvm-source 30 with: 31 key: llvm-source-17-sizediff-v1 32 path: | 33 llvm-project/compiler-rt 34 - name: Download LLVM source 35 if: steps.cache-llvm-source.outputs.cache-hit != 'true' 36 run: make llvm-source 37 - name: Cache Go 38 uses: actions/cache@v4 39 with: 40 key: go-cache-linux-sizediff-v1-${{ hashFiles('go.mod') }} 41 path: | 42 ~/.cache/go-build 43 ~/go/pkg/mod 44 - run: make gen-device -j4 45 - name: Download drivers repo 46 run: git clone https://github.com/tinygo-org/drivers.git 47 - name: Save HEAD 48 run: git branch github-actions-saved-HEAD HEAD 49 50 # Compute sizes for the PR branch 51 - name: Build tinygo binary for the PR branch 52 run: go install 53 - name: Determine binary sizes on the PR branch 54 run: (cd drivers; make smoke-test XTENSA=0 | tee sizes-pr.txt) 55 56 # Compute sizes for the dev branch 57 - name: Checkout dev branch 58 run: | 59 git reset --hard origin/dev 60 git checkout --no-recurse-submodules `git merge-base HEAD origin/dev` 61 - name: Install apt dependencies on the dev branch 62 # this is only needed on a PR that changes the LLVM version 63 run: ./.github/workflows/sizediff-install-pkgs.sh 64 - name: Build tinygo binary for the dev branch 65 run: go install 66 - name: Determine binary sizes on the dev branch 67 run: (cd drivers; make smoke-test XTENSA=0 | tee sizes-dev.txt) 68 69 # Create comment 70 # TODO: add a summary, something like: 71 # - overall size difference (percent) 72 # - number of binaries that grew / shrank / remained the same 73 # - don't show the full diff when no binaries changed 74 - name: Calculate size diff 75 run: ./tools/sizediff drivers/sizes-dev.txt drivers/sizes-pr.txt | tee sizediff.txt 76 - name: Create comment 77 run: | 78 echo "Size difference with the dev branch:" > comment.txt 79 echo "<details><summary>Binary size difference</summary>" >> comment.txt 80 echo "<pre>" >> comment.txt 81 cat sizediff.txt >> comment.txt 82 echo "</pre></details>" >> comment.txt 83 - name: Comment contents 84 run: cat comment.txt 85 - name: Add comment 86 if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }} 87 uses: thollander/actions-comment-pull-request@v2.3.1 88 with: 89 GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} 90 filePath: comment.txt 91 comment_tag: sizediff