Something went wrong. Try again.
My version of https://github.com/vercel-labs/fx
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170name: Binary Size
on: pull_request:
concurrency: group: binary-size-${{ github.event.pull_request.number }} cancel-in-progress: true
permissions: contents: read
jobs: compare: name: ReleaseSafe delta (${{ matrix.name }}) runs-on: ${{ matrix.runner }} timeout-minutes: 30 strategy: fail-fast: false matrix: include: - name: linux-x86_64 target: x86_64-linux runner: ubuntu-24.04 section_format: elf expected_file: "ELF 64-bit LSB.*x86-64" - name: linux-aarch64 target: aarch64-linux runner: ubuntu-24.04-arm section_format: elf expected_file: "ELF 64-bit LSB.*ARM aarch64" - name: macos-x86_64 target: x86_64-macos runner: macos-15-intel section_format: macho expected_file: "Mach-O 64-bit executable x86_64" - name: macos-aarch64 target: aarch64-macos runner: macos-15 section_format: macho expected_file: "Mach-O 64-bit executable arm64" env: BASE_SHA: ${{ github.event.pull_request.base.sha }} HEAD_SHA: ${{ github.sha }} EXPECTED_FILE: ${{ matrix.expected_file }} SECTION_FORMAT: ${{ matrix.section_format }} TARGET: ${{ matrix.target }}
steps: - uses: actions/checkout@v4 with: fetch-depth: 0
- name: Setup Zig uses: mlugg/setup-zig@v2 with: version: "0.16.0" use-cache: false
- name: Test size reporter run: python3 -m unittest scripts.tests.test_binary_size -v
- name: Build pull request binary shell: bash run: | set -euo pipefail evidence_dir="$RUNNER_TEMP/fx-binary-size-evidence" mkdir -p "$evidence_dir" test "$(git rev-parse HEAD)" = "$HEAD_SHA" zig build \ -Dtarget=${{ matrix.target }} \ -Doptimize=ReleaseSafe \ --cache-dir "$RUNNER_TEMP/fx-head-cache" \ --global-cache-dir "$RUNNER_TEMP/fx-global-cache" cp zig-out/bin/fx "$evidence_dir/head-fx" file "$evidence_dir/head-fx" > "$evidence_dir/head-file.txt" cat "$evidence_dir/head-file.txt" grep -Eq "$EXPECTED_FILE" "$evidence_dir/head-file.txt" if [ "$SECTION_FORMAT" = "macho" ]; then size -m "$evidence_dir/head-fx" > "$evidence_dir/head-sections.txt" else size -A -d "$evidence_dir/head-fx" > "$evidence_dir/head-sections.txt" fi cat "$evidence_dir/head-sections.txt"
- name: Build base binary shell: bash run: | set -euo pipefail evidence_dir="$RUNNER_TEMP/fx-binary-size-evidence" base_worktree="$RUNNER_TEMP/fx-binary-size-base" cleanup() { git worktree remove --force "$base_worktree" >/dev/null 2>&1 || true } trap cleanup EXIT INT TERM git worktree add --detach "$base_worktree" "$BASE_SHA" test "$(git -C "$base_worktree" rev-parse HEAD)" = "$BASE_SHA" ( cd "$base_worktree" zig build \ -Dtarget=${{ matrix.target }} \ -Doptimize=ReleaseSafe \ --cache-dir "$RUNNER_TEMP/fx-base-cache" \ --global-cache-dir "$RUNNER_TEMP/fx-global-cache" ) cp "$base_worktree/zig-out/bin/fx" "$evidence_dir/base-fx" file "$evidence_dir/base-fx" > "$evidence_dir/base-file.txt" cat "$evidence_dir/base-file.txt" grep -Eq "$EXPECTED_FILE" "$evidence_dir/base-file.txt" if [ "$SECTION_FORMAT" = "macho" ]; then size -m "$evidence_dir/base-fx" > "$evidence_dir/base-sections.txt" else size -A -d "$evidence_dir/base-fx" > "$evidence_dir/base-sections.txt" fi cat "$evidence_dir/base-sections.txt"
- name: Compare binary sizes id: size shell: bash run: | set -euo pipefail evidence_dir="$RUNNER_TEMP/fx-binary-size-evidence" python3 -m scripts.binary_size \ --base-binary "$evidence_dir/base-fx" \ --head-binary "$evidence_dir/head-fx" \ --base-sections "$evidence_dir/base-sections.txt" \ --head-sections "$evidence_dir/head-sections.txt" \ --base-sha "$BASE_SHA" \ --head-sha "$HEAD_SHA" \ --target "$TARGET" \ --warning-bytes 52429 \ --output-json "$evidence_dir/report.json" \ --output-markdown "$evidence_dir/report.md" \ --github-output "$GITHUB_OUTPUT" cat "$evidence_dir/report.md" >> "$GITHUB_STEP_SUMMARY"
- name: Annotate notable growth if: steps.size.outputs.warning == 'true' env: DELTA_BYTES: ${{ steps.size.outputs.delta_bytes }} run: | printf '%s\n' \ "::warning title=Binary size increase::${TARGET} ReleaseSafe grew by ${DELTA_BYTES} bytes; inspect the retained section report."
- name: Upload size evidence if: always() uses: actions/upload-artifact@v4 with: name: binary-size-evidence-${{ matrix.name }}-${{ github.event.pull_request.number }} path: | ${{ runner.temp }}/fx-binary-size-evidence/report.json ${{ runner.temp }}/fx-binary-size-evidence/report.md ${{ runner.temp }}/fx-binary-size-evidence/base-file.txt ${{ runner.temp }}/fx-binary-size-evidence/head-file.txt ${{ runner.temp }}/fx-binary-size-evidence/base-sections.txt ${{ runner.temp }}/fx-binary-size-evidence/head-sections.txt if-no-files-found: warn retention-days: 30
- name: Upload binaries for investigation if: steps.size.outputs.warning == 'true' uses: actions/upload-artifact@v4 with: name: binary-size-binaries-${{ matrix.name }}-${{ github.event.pull_request.number }} path: | ${{ runner.temp }}/fx-binary-size-evidence/base-fx ${{ runner.temp }}/fx-binary-size-evidence/head-fx compression-level: 0 retention-days: 7