Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 30 additions & 13 deletions .gitlab/benchmarks/steps/build-baseline.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,37 @@
set -e -o pipefail

# If we have a tag (e.g. v2.21.1), then use the PyPI published wheel
# Otherwise, build the wheel from commit hash
if [[ -n "${BASELINE_TAG}" ]];
then
echo "Downloading wheel for tag ${BASELINE_TAG} from PyPI"
python3.9 -m pip download --no-deps "ddtrace==${BASELINE_TAG:1}"
else
ulimit -c unlimited
curl -sSf https://sh.rustup.rs | sh -s -- -y;
export PATH="$HOME/.cargo/bin:$PATH"
echo "Building wheel for ${BASELINE_BRANCH}:${BASELINE_COMMIT_SHA}"
git checkout "${BASELINE_COMMIT_SHA}"
mkdir ./tmp
PYO3_PYTHON=python3.9 CIBW_BUILD=1 python3.9 -m pip wheel --no-deps -w ./tmp/ ./
for wheel in ./tmp/*.whl;
do
auditwheel repair "$wheel" --plat "manylinux2014_x86_64" -w ./
done
exit 0
fi


# If we have a commit SHA, try to download the prebuild wheel from GitHub Actions
if [[ -n "${BASELINE_COMMIT_SHA}" ]];
then
# Try to download the wheel from the public S3 bucket if we have one
PIPELINE_ID=$(.gitlab/scripts/get-pipelines-for-ref.sh "${BASELINE_COMMIT_SHA}" | jq -r 'if length > 0 then .[0].id else empty end')

if [[ -n "${PIPELINE_ID}" ]];
then
echo "Downloading prebuilt wheel for ${BASELINE_BRANCH}:${BASELINE_COMMIT_SHA} from pipeline ${PIPELINE_ID}"
python3.9 -m pip download --no-deps --index-url "https://dd-trace-py-builds.s3.amazonaws.com/${PIPELINE_ID}/" "ddtrace"
exit 0
fi
fi

# Otherwise, build from source
ulimit -c unlimited
curl -sSf https://sh.rustup.rs | sh -s -- -y;
export PATH="$HOME/.cargo/bin:$PATH"
echo "Building wheel for ${BASELINE_BRANCH}:${BASELINE_COMMIT_SHA}"
git checkout "${BASELINE_COMMIT_SHA}"
mkdir ./tmp
PYO3_PYTHON=python3.9 CIBW_BUILD=1 python3.9 -m pip wheel --no-deps -w ./tmp/ ./
for wheel in ./tmp/*.whl;
do
auditwheel repair "$wheel" --plat "manylinux2014_x86_64" -w ./
done
30 changes: 30 additions & 0 deletions .gitlab/scripts/get-pipelines-for-ref.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
#!/usr/bin/env bash
set -euo pipefail

# Usage:
# ./get-pipelines-for-ref.sh <ref>
#
# Example:
# ./get-pipelines-for-ref.sh 3dbf82a
#
# Environment:
# GITLAB_TOKEN (required)

GITLAB_API_URL=${GITLAB_API_URL:-"https://gitlab.ddbuild.io/api/v4"}
GITLAB_PROJECT_ID=${GITLAB_PROJECT_ID:-"358"}

if [[ $# -ne 1 ]]; then
echo "usage: $0 <commit-sha-or-tag>" >&2
exit 1
fi

if [[ -z "${GITLAB_TOKEN:-}" ]]; then
echo "GITLAB_TOKEN is not set" >&2
exit 1
fi

REF="$1"

curl --show-error --silent --fail \
--header "PRIVATE-TOKEN: ${GITLAB_TOKEN}" \
"${GITLAB_API_URL}/projects/${GITLAB_PROJECT_ID}/pipelines?sha=${REF}"
Loading