Skip to content

ADFA-<ticket>: Make benchmark clean respect ENABLE_DAEMON #3

ADFA-<ticket>: Make benchmark clean respect ENABLE_DAEMON

ADFA-<ticket>: Make benchmark clean respect ENABLE_DAEMON #3

name: Build benchmark (measure only)
on:
# Push to the benchmarking branch triggers a run using the committed
# scripts/benchmark/bench.env config (push events cannot carry inputs).
# This is how the workflow runs before it exists on the default branch,
# where workflow_dispatch would otherwise be undispatchable.
push:
branches:
- worktree-build-optimization
workflow_dispatch:
inputs:
variant:
description: "Which APK(s) to build"
type: choice
options: [v8-debug, v7v8-release]
default: v8-debug
enable_daemon:
description: "Reuse the Gradle daemon (false = --no-daemon)"
type: boolean
default: false
gradle_daemon_heap:
description: "Gradle daemon -Xmx (e.g. 4g / 4096M)"
default: "8192M"
kotlin_daemon_heap:
description: "Kotlin daemon -Xmx"
default: "8192M"
aapt2_heap:
description: "android.aapt2.daemonHeapSize"
default: "8192M"
workers_max:
description: "org.gradle.workers.max"
default: "30"
parallel:
description: "org.gradle.parallel"
type: boolean
default: true
clean_first:
description: "Run ./gradlew clean before the timed build"
type: boolean
default: false
permissions:
contents: read
jobs:
benchmark:
name: Build & measure
runs-on: self-hosted
timeout-minutes: 90
env:
INCLUDE_LLAMA_ASSETS: "false"
# Neutralize Sentry so no upload/network step perturbs timings.
SENTRY_DSN_DEBUG: ""
SENTRY_DSN_RELEASE: ""
SENTRY_AUTO_UPLOAD: "false"
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Check if Nix is installed
id: check_nix
run: |
if command -v nix >/dev/null 2>&1; then
echo "nix_installed=true" >> $GITHUB_ENV
else
echo "nix_installed=false" >> $GITHUB_ENV
fi
- name: Install Flox
if: env.nix_installed == 'false'
uses: flox/install-flox-action@v2
- name: Create google-services.json
env:
GOOGLE_SERVICES_JSON: ${{ secrets.GOOGLE_SERVICES_JSON }}
run: |
echo "$GOOGLE_SERVICES_JSON" > app/google-services.json
- name: Resolve benchmark parameters
run: |
if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then
echo "Using workflow_dispatch inputs."
{
echo "VARIANT=${{ inputs.variant }}"
echo "ENABLE_DAEMON=${{ inputs.enable_daemon }}"
echo "GRADLE_DAEMON_HEAP=${{ inputs.gradle_daemon_heap }}"
echo "KOTLIN_DAEMON_HEAP=${{ inputs.kotlin_daemon_heap }}"
echo "AAPT2_HEAP=${{ inputs.aapt2_heap }}"
echo "WORKERS_MAX=${{ inputs.workers_max }}"
echo "PARALLEL=${{ inputs.parallel }}"
echo "CLEAN_FIRST=${{ inputs.clean_first }}"
} >> "$GITHUB_ENV"
else
cfg="scripts/benchmark/bench.env"
if [ ! -f "$cfg" ]; then
echo "::error::$cfg not found — cannot resolve benchmark parameters for a push run"
exit 1
fi
echo "Loading benchmark parameters from $cfg:"
# Only simple KEY=VALUE lines; ignores comments/blanks and blocks
# any multi-line $GITHUB_ENV injection.
grep -E '^[A-Z_][A-Z0-9_]*=[^[:space:]]*$' "$cfg" | tee -a "$GITHUB_ENV"
fi
- name: Run build benchmark
run: bash scripts/benchmark/run-build-benchmark.sh
- name: Upload benchmark results
if: always()
uses: actions/upload-artifact@v4
with:
name: benchmark-${{ env.VARIANT }}-${{ github.run_id }}
path: benchmark-results/
- name: Cleanup google-services.json
if: always()
run: rm -f app/google-services.json