Skip to content

Commit 429b26d

Browse files
committed
Revert "ci: revert PRs #762 and #775 (#776)"
This reverts commit a3f0640.
1 parent a3f0640 commit 429b26d

File tree

1 file changed

+29
-12
lines changed

1 file changed

+29
-12
lines changed

scripts/build_layers.sh

Lines changed: 29 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -98,22 +98,41 @@ function make_path_absolute {
9898
echo "$(cd "$(dirname "$1")"; pwd)/$(basename "$1")"
9999
}
100100

101+
function search_wheel {
102+
# Args: [wheel base name] [index]
103+
104+
WHEEL_BASENAME=$1
105+
INDEX=$2
106+
107+
SEARCH_PATTERN="${WHEEL_BASENAME}-[^\"]*${PY_TAG}[^\"]*${PLATFORM}[^\"]*\.whl"
108+
INDEX_URL="${S3_BASE}/index-${INDEX}.html"
109+
echo "Searching for wheel ${SEARCH_PATTERN}"
110+
export WHEEL_FILE=$(curl -sSfL ${INDEX_URL} | grep -o "$SEARCH_PATTERN" | head -n 1)
111+
if [ ! -z "${WHEEL_FILE}" ]; then
112+
curl -sSfL "${S3_BASE}/${WHEEL_FILE}" -o "${WHEEL_FILE}"
113+
echo "Using S3 wheel: ${WHEEL_FILE}"
114+
replace_ddtrace_dep "${WHEEL_BASENAME} = { file = \"${WHEEL_FILE}\" }"
115+
fi
116+
}
117+
101118
function docker_build_zip {
102-
# Args: [python version] [zip destination]
119+
# Args: [python version] [zip destination] [wheel base name] [index]
103120

104121
destination=$(make_path_absolute $2)
105122
arch=$3
123+
wheel_basename=$4
124+
index=$5
106125

107126
# Restore pyproject.toml to a clean state for each build iteration
108127
cp pyproject.toml.bak pyproject.toml
109128

110129
# Replace ddtrace source if necessary
111130
if [ -n "$DD_TRACE_COMMIT" ]; then
112-
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }"
131+
replace_ddtrace_dep "${wheel_basename} = { git = \"https://github.com/DataDog/dd-trace-py.git\", rev = \"$DD_TRACE_COMMIT\" }"
113132
elif [ -n "$DD_TRACE_COMMIT_BRANCH" ]; then
114-
replace_ddtrace_dep "ddtrace = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }"
133+
replace_ddtrace_dep "${wheel_basename} = { git = \"https://github.com/DataDog/dd-trace-py.git\", branch = \"$DD_TRACE_COMMIT_BRANCH\" }"
115134
elif [ -n "$DD_TRACE_WHEEL" ]; then
116-
replace_ddtrace_dep "ddtrace = { file = \"$DD_TRACE_WHEEL\" }"
135+
replace_ddtrace_dep "${wheel_basename} = { file = \"$DD_TRACE_WHEEL\" }"
117136
elif [ -n "$UPSTREAM_PIPELINE_ID" ]; then
118137
S3_BASE="https://dd-trace-py-builds.s3.amazonaws.com/${UPSTREAM_PIPELINE_ID}"
119138
if [ "${arch}" = "amd64" ]; then
@@ -122,15 +141,9 @@ function docker_build_zip {
122141
PLATFORM="manylinux2014_aarch64"
123142
fi
124143
PY_TAG="cp$(echo "$1" | tr -d '.')"
125-
WHEEL_FILE=$(curl -sSfL "${S3_BASE}/index-manylinux2014.html" \
126-
| grep -o "ddtrace-[^\"]*${PY_TAG}[^\"]*${PLATFORM}[^\"]*\.whl" \
127-
| head -n 1)
144+
search_wheel ${wheel_basename} ${index}
128145
if [ -z "${WHEEL_FILE}" ]; then
129146
echo "No S3 wheel found for ${PY_TAG} ${PLATFORM}, using default pyproject.toml version"
130-
else
131-
curl -sSfL "${S3_BASE}/${WHEEL_FILE}" -o "${WHEEL_FILE}"
132-
echo "Using S3 wheel: ${WHEEL_FILE}"
133-
replace_ddtrace_dep "ddtrace = { file = \"${WHEEL_FILE}\" }"
134147
fi
135148
fi
136149

@@ -149,6 +162,7 @@ function docker_build_zip {
149162

150163
rm -rf $temp_dir
151164
echo "Done creating archive $destination"
165+
rm pyproject.toml.bak
152166
}
153167

154168
rm -rf $LAYER_DIR
@@ -159,7 +173,10 @@ do
159173
for architecture in "${ARCHS[@]}"
160174
do
161175
echo "Building layer for Python ${python_version} arch=${architecture}"
162-
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture}
176+
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture} "ddtrace_serverless" "serverless" || true
177+
if [ -f pyproject.toml.bak ]; then # true means the previous attempt failed
178+
docker_build_zip ${python_version} $LAYER_DIR/${LAYER_FILES_PREFIX}-${architecture}-${python_version}.zip ${architecture} "ddtrace" "manylinux2014"
179+
fi
163180
done
164181
done
165182

0 commit comments

Comments
 (0)