servo/.github/workflows/bencher.yml
shuppy 25147c75cb
ci: Stop using python3 ./mach (#39271)
this way of invoking mach is incorrect now that we use uv, and it will
prevent us from running bencher builds on self-hosted runners (#39269),
where the system Python is too old (3.10 vs 3.11).

Testing:
- mach try bencher
<https://github.com/servo/servo/actions/runs/17675086579>

Fixes: part of #39269

Signed-off-by: Delan Azabani <dazabani@igalia.com>
2025-09-12 14:45:31 +00:00

145 lines
5.9 KiB
YAML

name: Bencher
on:
workflow_call:
inputs:
target:
required: false
default: "linux"
type: string
profile:
required: false
default: "release"
type: string
compressed-file-path:
required: false
default: ""
type: string
binary-path:
required: false
default: ""
type: string
file-size:
required: false
default: false
type: boolean
stripped-file-size:
required: false
default: false
type: boolean
speedometer:
required: false
default: false
type: boolean
dromaeo:
required: false
default: false
type: boolean
env:
RUST_BACKTRACE: 1
SHELL: /bin/bash
# allows overriding bencher project for pushes
BENCHER_PROJECT: ${{ vars.BENCHER_PROJECT || 'servo' }}
jobs:
bencher:
name: Bencher (${{ inputs.target }})
# This needs to be kept in sync with the `--testbed` argument sent to bencher.
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
if: github.event_name != 'pull_request_target'
with:
fetch-depth: 0
# This is necessary to checkout the pull request if this run was triggered via a
# `pull_request_target` event.
- uses: actions/checkout@v4
if: github.event_name == 'pull_request_target'
with:
ref: refs/pull/${{ github.event.number }}/head
fetch-depth: 0
- uses: actions/download-artifact@v4
with:
name: ${{ inputs.profile }}-binary-${{ inputs.target }}
path: ${{ inputs.profile }}-binary-${{ inputs.target }}
# Linux and macOS uploads compressed binary, need to extract first
- name: unPackage binary (tar)
if: ${{ inputs.compressed-file-path != '' && contains(inputs.compressed-file-path, '.tar.gz') }}
run: tar -xzf ${{ inputs.compressed-file-path }}
- name: unPackage binary (unzip)
if: ${{ inputs.compressed-file-path != '' && !contains(inputs.compressed-file-path, '.tar.gz') }}
run: unzip ${{ inputs.compressed-file-path }}
- name: Setup Python
uses: ./.github/actions/setup-python
- name: Bootstrap dependencies
if: ${{ inputs.speedometer == true || inputs.dromaeo == true }}
run: |
sudo apt update
sudo apt install -qy --no-install-recommends mesa-vulkan-drivers
./mach bootstrap --skip-lints
- uses: bencherdev/bencher@main
- name: File size
if: ${{ inputs.file-size == true }}
run: |
./etc/ci/bencher.py filesize ${{ inputs.binary-path }} ${{ inputs.target }}-${{ inputs.profile }} --bmf-output size.json
echo "SERVO_FILE_SIZE_RESULT=size.json" >> "$GITHUB_ENV"
# We'll additionally strip and measure the size of the binary when using production profile
- name: Install LLVM
if: ${{ inputs.file-size == true && inputs.profile == 'production' }}
uses: KyleMayes/install-llvm-action@v2
with:
version: "17"
- name: Install llvm-strip dependency
if: ${{ inputs.file-size == true && inputs.profile == 'production' }}
run: sudo apt install libncurses5
- name: File size (llvm stripped)
if: ${{ inputs.file-size == true && inputs.profile == 'production' }}
run: |
llvm-strip ${{ inputs.binary-path }}
./etc/ci/bencher.py filesize ${{ inputs.binary-path }} ${{ inputs.target }}-${{ inputs.profile }}-stripped --bmf-output size-stripped.json
echo "SERVO_STRIPPED_FILE_SIZE_RESULT=size-stripped.json" >> "$GITHUB_ENV"
- name: Speedometer
if: ${{ inputs.speedometer == true }}
run: |
./mach test-speedometer -r --bmf-output speedometer.json
echo "SERVO_SPEEDOMETER_RESULT=speedometer.json" >> "$GITHUB_ENV"
- name: Dromaeo
if: ${{ inputs.dromaeo == true }}
run: |
./mach test-dromaeo -r dom --bmf-output dromaeo.json
echo "SERVO_DROMAEO_RESULT=dromaeo.json" >> "$GITHUB_ENV"
# set options
- name: Set bencher opts for PRs (label try run)
if: github.event_name == 'pull_request_target'
run: |
echo "RUN_BENCHER_OPTIONS=--branch ${{ github.event.number }}/PR \
--start-point ${{ github.base_ref }} \
--start-point-hash ${{ github.event.pull_request.base.sha }} \
--start-point-reset \
--start-point-clone-thresholds \
--github-actions ${{ secrets.GITHUB_TOKEN }}" >> "$GITHUB_ENV"
- name: Set bencher opts for main
if: ${{ github.event_name == 'push' && github.ref_name == 'main' }}
run: |
echo "RUN_BENCHER_OPTIONS=--branch main \
--github-actions ${{ secrets.GITHUB_TOKEN }}" >> "$GITHUB_ENV"
- name: Set bencher opts for try branch
if: ${{ github.event_name == 'push' && github.ref_name == 'try' }}
run: |
git remote add upstream https://github.com/servo/servo
git fetch upstream main
echo "RUN_BENCHER_OPTIONS=--branch try \
--github-actions ${{ secrets.GITHUB_TOKEN }} \
--hash $(git rev-parse HEAD~1) \
--start-point main \
--start-point-hash $(git merge-base upstream/main HEAD) \
--start-point-clone-thresholds \
--branch-reset" >> "$GITHUB_ENV"
# we join results and send all data once to have it all in one report
- name: Send results
continue-on-error: true
run: |
./etc/ci/bencher.py merge ${{ env.SERVO_FILE_SIZE_RESULT }} ${{ env.SERVO_STRIPPED_FILE_SIZE_RESULT }} ${{ env.SERVO_SPEEDOMETER_RESULT }} ${{ env.SERVO_DROMAEO_RESULT }} --bmf-output b.json
bencher run --adapter json --file b.json \
--project ${{ env.BENCHER_PROJECT }} --token ${{ secrets.BENCHER_API_TOKEN }} --testbed ubuntu-22.04 \
$RUN_BENCHER_OPTIONS