From e0cbee5a08a177941a5fb72d7752fe86b2fdb0d5 Mon Sep 17 00:00:00 2001 From: brettlangdon Date: Fri, 21 Nov 2025 14:10:57 -0500 Subject: [PATCH 1/2] ci: publish and use s3 wheels by commit sha --- .gitlab/benchmarks/steps/build-baseline.sh | 34 ++++++++++++++-------- .gitlab/package.yml | 6 ++++ 2 files changed, 28 insertions(+), 12 deletions(-) diff --git a/.gitlab/benchmarks/steps/build-baseline.sh b/.gitlab/benchmarks/steps/build-baseline.sh index 8ed61992164..5db00cea65c 100755 --- a/.gitlab/benchmarks/steps/build-baseline.sh +++ b/.gitlab/benchmarks/steps/build-baseline.sh @@ -2,20 +2,30 @@ 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 +# Otherwise, try to download from S3 by commit SHA, or build the wheel from scratch if [[ -n "${BASELINE_TAG}" ]]; then 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 + # Try to download the wheel from S3 using the baseline commit SHA + S3_BUCKET="dd-trace-py-builds" + S3_INDEX_URL="https://${S3_BUCKET}.s3.amazonaws.com/${BASELINE_COMMIT_SHA}/index.html" + + echo "Attempting to download wheel from S3 index: ${S3_INDEX_URL}" + if python3.9 -m pip download --no-deps --index-url "${S3_INDEX_URL}" ddtrace 2>/dev/null; then + echo "Successfully downloaded wheel from S3" + else + echo "Failed to download from S3, building wheel from scratch..." + 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 + fi fi diff --git a/.gitlab/package.yml b/.gitlab/package.yml index e1740dc5858..7d05c2e8391 100644 --- a/.gitlab/package.yml +++ b/.gitlab/package.yml @@ -120,11 +120,13 @@ publish-wheels-to-s3: # Upload all wheels to versioned prefix and pipeline-id prefix - aws s3 cp --recursive --exclude "*" --include "*.whl" pywheels "s3://${BUCKET}/${VERSION}/" + - aws s3 cp --recursive --exclude "*" --include "*.whl" pywheels "s3://${BUCKET}/${CI_COMMIT_SHA}/" - aws s3 cp --recursive --exclude "*" --include "*.whl" pywheels "s3://${BUCKET}/${CI_PIPELINE_ID}/" - | VERSION_ENC="${VERSION//+/%2B}" S3_BASE_VER="https://${BUCKET}.s3.amazonaws.com/${VERSION_ENC}" + S3_BASE_COMMIT="https://${BUCKET}.s3.amazonaws.com/${CI_COMMIT_SHA}" S3_BASE_PIPE="https://${BUCKET}.s3.amazonaws.com/${CI_PIPELINE_ID}" generate_index_html() { @@ -142,14 +144,18 @@ publish-wheels-to-s3: # Generate both minimal indexes generate_index_html "index.version.html" + generate_index_html "index.commit.html" generate_index_html "index.pipeline.html" # Upload to each S3 prefix aws s3 cp "index.version.html" "s3://${BUCKET}/${VERSION}/index.html" --content-type text/html + aws s3 cp "index.commit.html" "s3://${BUCKET}/${CI_COMMIT_SHA}/index.html" --content-type text/html aws s3 cp "index.pipeline.html" "s3://${BUCKET}/${CI_PIPELINE_ID}/index.html" --content-type text/html # Print the clickable URLs VER_INDEX_URL="${S3_BASE_VER}/index.html" + COMMIT_INDEX_URL="${S3_BASE_COMMIT}/index.html" PIPE_INDEX_URL="${S3_BASE_PIPE}/index.html" echo "S3 index (version): ${VER_INDEX_URL}" + echo "S3 index (commit): ${COMMIT_INDEX_URL}" echo "S3 index (pipeline): ${PIPE_INDEX_URL}" From a8ad1af94fcfdab4028a4c266ed3fed00e4dcc6d Mon Sep 17 00:00:00 2001 From: Brett Langdon Date: Mon, 24 Nov 2025 08:32:49 -0500 Subject: [PATCH 2/2] Update .gitlab/package.yml Co-authored-by: T. Kowalski --- .gitlab/package.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.gitlab/package.yml b/.gitlab/package.yml index 7d05c2e8391..e5da7b9ec76 100644 --- a/.gitlab/package.yml +++ b/.gitlab/package.yml @@ -157,5 +157,5 @@ publish-wheels-to-s3: COMMIT_INDEX_URL="${S3_BASE_COMMIT}/index.html" PIPE_INDEX_URL="${S3_BASE_PIPE}/index.html" echo "S3 index (version): ${VER_INDEX_URL}" - echo "S3 index (commit): ${COMMIT_INDEX_URL}" + echo "S3 index (commit): ${COMMIT_INDEX_URL}" echo "S3 index (pipeline): ${PIPE_INDEX_URL}"