From 6f80321c96fb60ce64889c4b33084e5791a812c4 Mon Sep 17 00:00:00 2001 From: ddsign Date: Wed, 1 Apr 2026 12:44:02 -0400 Subject: [PATCH] Add baseline:detect job for microbenchmarks (like dd-trace-py) Detect the PR's target branch via dd-octo-sts + gh CLI instead of relying on benchmarking-platform's github-find-merge-into-branch, which fails when the GitHub App is suspended (incident-51987). Co-Authored-By: Claude Sonnet 4.6 --- .gitlab/benchmarks.yml | 41 ++++++++++++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) diff --git a/.gitlab/benchmarks.yml b/.gitlab/benchmarks.yml index 70659233b2..3262ee944e 100644 --- a/.gitlab/benchmarks.yml +++ b/.gitlab/benchmarks.yml @@ -189,6 +189,42 @@ ddprof-benchmark: # Microbenchmarks # ----------------------------------------------------- +# Detect the PR's target branch from GitHub so microbenchmarks can compare +# against the correct baseline. Uses dd-octo-sts for GitHub auth instead of +# the benchmarking platform's GitHub App (which may be unavailable). +# Modeled on dd-trace-py's baseline:detect job. +microbenchmarks-baseline-detect: + stage: package + image: registry.ddbuild.io/images/dd-octo-sts-ci-base:2025.06-1 + tags: ["arch:amd64"] + id_tokens: + DDOCTOSTS_ID_TOKEN: + aud: dd-octo-sts + rules: + - if: $CI_COMMIT_REF_NAME == "master" + when: never + - changes: + - lib/**/* + - ext/**/* + - benchmarks/**/* + - datadog.gemspec + - .gitlab/**/* + - when: never + script: + - | + git config --global --add safe.directory "$CI_PROJECT_DIR" + git remote set-url origin "https://github.com/DataDog/dd-trace-rb.git" + - | + dd-octo-sts token --scope DataDog/dd-trace-rb --policy gitlab.github-access.read > /tmp/gh-token + gh auth login --with-token < /tmp/gh-token + rm /tmp/gh-token + - | + BASELINE_BRANCH=$(gh pr view --json "baseRefName" --jq ".baseRefName" "$CI_COMMIT_REF_NAME" || echo "master") + echo "MANUAL_BASELINE_BRANCH=${BASELINE_BRANCH}" | tee baseline.env + artifacts: + reports: + dotenv: baseline.env + # Configuration for executing microbenchmarks in parallel # Choose which benchmarks to execute, with how many CPUs, on what CI job include: @@ -198,7 +234,10 @@ microbenchmarks: extends: .execution # From benchmarks/execution.yml stage: microbenchmarks when: always - needs: [] + needs: + - job: microbenchmarks-baseline-detect + optional: true + artifacts: true tags: ["runner:apm-k8s-tweaked-metal"] image: $BASE_CI_IMAGE rules: