Skip to content

Commit 98d646b

Browse files
authored
ci: correctly identify base branch for microbenchmarks (#13195)
This PR addresses two separate issues with the microbenchmarks: 1. The `check-big-regressions` job for the microbenchmarks has been failing on some release branches due to the following silent error in the `baseline:detect` job: ``` none of the git remotes configured for this repository point to a known GitHub host. To tell gh about a new GitHub host, please use `gh auth login` ``` See example [here](https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-py/-/jobs/895493368). As a result, the subsequent `git describe --tags` command would always be comparing the release branch to the last tag on `main`, not on the release branch. Adding the `git config`s and `git remote set-url origin` in the `microbenchmarks.yml` file remediates this. 2. Given that we're moving forward with NO default backporting (except for 2.21), there will be more cases where a release is tagged on the `main` branch, not on its own minor release branch like `3.5`. This is updated in the `detect-baseline.sh` file to reflect that additional condition. Now if there is no minor release branch, it defaults to main (see example [here](https://gitlab.ddbuild.io/DataDog/apm-reliability/dd-trace-py/-/jobs/896300765)). ## Checklist - [x] PR author has checked that all the criteria below are met - The PR description includes an overview of the change - The PR description articulates the motivation for the change - The change includes tests OR the PR description describes a testing strategy - The PR description notes risks associated with the change, if any - Newly-added code is easy to change - The change follows the [library release note guidelines](https://ddtrace.readthedocs.io/en/stable/releasenotes.html) - The change includes or references documentation updates if necessary - Backport labels are set (if [applicable](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)) ## Reviewer Checklist - [x] Reviewer has checked that all the criteria below are met - Title is accurate - All changes are related to the pull request's stated goal - Avoids breaking [API](https://ddtrace.readthedocs.io/en/stable/versioning.html#interfaces) changes - Testing strategy adequately addresses listed risks - Newly-added code is easy to change - Release note makes sense to a user of the library - If necessary, author has acknowledged and discussed the performance implications of this PR as reported in the benchmarks PR comment - Backport labels are set in a manner that is consistent with the [release branch maintenance policy](https://ddtrace.readthedocs.io/en/latest/contributing.html#backporting)
1 parent 717c54c commit 98d646b

File tree

2 files changed

+16
-5
lines changed

2 files changed

+16
-5
lines changed

.gitlab/benchmarks/microbenchmarks.yml

+5-3
Original file line numberDiff line numberDiff line change
@@ -64,16 +64,18 @@ baseline:detect:
6464
variables:
6565
UPSTREAM_BRANCH: $CI_COMMIT_REF_NAME
6666
script: |
67+
GITHUB_REPO_URL="https://github.com/DataDog/dd-trace-py.git"
68+
git config --global --add safe.directory "${GITHUB_REPO_URL}"
69+
git config --global --add safe.directory ${CI_PROJECT_DIR}
70+
git remote set-url origin "${GITHUB_REPO_URL}"
71+
6772
if [ -z ${GH_TOKEN} ]
6873
then
6974
aws ssm get-parameter --region us-east-1 --name ci.$CI_PROJECT_NAME.gh_token --with-decryption --query "Parameter.Value" --out text > token
7075
gh auth login --with-token < token
7176
rm token
7277
fi
7378
74-
# Needed to run `git describe`
75-
git config --global --add safe.directory ${CI_PROJECT_DIR}
76-
7779
# Determine baseline to test against and save env variables into `baseline.env`
7880
.gitlab/benchmarks/steps/detect-baseline.sh
7981
artifacts:

.gitlab/benchmarks/steps/detect-baseline.sh

+11-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
set -e -o pipefail
2+
set -ex -o pipefail
33

44
# Script to determine the baseline version to compare against for a given CI run
55
# The results are written as environment variables to a `baseline.env` file
@@ -25,10 +25,19 @@ if [ "${UPSTREAM_BRANCH}" == "main" ]; then
2525
elif [[ "${UPSTREAM_BRANCH}" =~ ^v[0-9]+\.[0-9]+\.[0-9]+ ]]; then
2626
# Baseline branch is the major.minor version of the tag
2727
BASELINE_BRANCH=$(echo "${UPSTREAM_BRANCH:1}" | cut -d. -f1-2)
28-
echo "BASELINE_BRANCH=${BASELINE_BRANCH}" | tee baseline.env
28+
29+
# Check if a release branch exists or not
30+
if git ls-remote --exit-code --heads origin "${BASELINE_BRANCH}" > /dev/null; then
31+
echo "Found remote branch origin/${BASELINE_BRANCH}"
32+
else
33+
echo "Remote branch origin/${BASELINE_BRANCH} not found. Falling back to main."
34+
BASELINE_BRANCH="main"
35+
fi
2936
# Don't forget to omit the current tag we are testing
3037
BASELINE_TAG=$(git describe --tags --abbrev=0 --exclude "*rc*" --exclude "${UPSTREAM_BRANCH}" "origin/${BASELINE_BRANCH}" || echo "")
3138

39+
echo "BASELINE_BRANCH=${BASELINE_BRANCH}" | tee baseline.env
40+
3241
# If this is a release branch (e.g. `2.21`) then test against the latest version from that point (e.g. v2.21.2 or v2.20.x)
3342
elif [[ "${UPSTREAM_BRANCH}" =~ ^[0-9]+\.[0-9]+$ ]]; then
3443
BASELINE_BRANCH="${UPSTREAM_BRANCH}"

0 commit comments

Comments
 (0)