Skip to content

Commit d00a7a0

Browse files
committed
Fix build lambda layer issue
1 parent fc16d73 commit d00a7a0

4 files changed

Lines changed: 14 additions & 40 deletions

File tree

.github/workflows/compute-workflow-parameters.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ jobs:
165165
with:
166166
name: binaries_dev_${{ inputs.library }}
167167
path: binaries/
168-
include-hidden-files: ${{ inputs.library == 'python' }}
168+
include-hidden-files: ${{ inputs.library == 'python' || inputs.library == 'python_lambda' }}
169169
- name: Set unique ID
170170
id: unique_id
171171
run: echo "value=$(openssl rand -hex 8)" >> $GITHUB_OUTPUT

conftest.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def pytest_addoption(parser: pytest.Parser) -> None:
106106
action="store",
107107
default="",
108108
help="Library to test (e.g. 'python', 'ruby')",
109-
choices=["cpp", "golang", "dotnet", "java", "nodejs", "php", "python", "ruby"],
109+
choices=["cpp", "golang", "dotnet", "java", "nodejs", "php", "python", "ruby", "python_lambda"],
110110
)
111111

112112
# report data to feature parity dashboard

utils/build/docker/python_lambda/build_lambda_layer.sh

Lines changed: 6 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ SKIP_BUILD=0
2121
for var in $(compgen -v SYSTEM_TESTS_AWS_); do
2222
export "${var/SYSTEM_TESTS_AWS_/AWS_}"
2323
done
24-
echo "Following AWS variables are set:"
25-
env | grep '^AWS_'
2624

2725
if [ -e "datadog-lambda-python" ]; then
2826
echo "datadog-lambda-python already exists, skipping clone."
@@ -60,66 +58,41 @@ elif command -v aws >/dev/null 2>&1 && aws sts get-caller-identity >/dev/null 2>
6058
SKIP_BUILD=1
6159
else
6260
echo "Failed to get download URL for layer. Falling back to git clone..."
61+
exit 1
6362
fi
6463
else
6564
echo "No layer version found. Falling back to git clone..."
65+
exit 1
6666
fi
6767
else
6868
echo "Impossible to download datadog-lambda-python layer from AWS and no local layer provided, Aborting."
6969
exit 1
7070
fi
7171

72-
# Patch the ddtrace dependency in datadog-lambda-python based on the same rules as install_ddtrace.sh
7372
if [[ $SKIP_BUILD -eq 0 ]]; then
74-
if [ -e "dd-trace-py" ]; then
75-
echo "Install from local folder /binaries/dd-trace-py"
73+
if [ -e "datdog-lambda-python/dd-trace-py" ]; then
74+
echo "Install from local folder /binaries/datadog-lambda-python/dd-trace-py"
7675
if [[ "$OSTYPE" == "darwin"* ]]; then
7776
sed -i '' 's|^ddtrace =.*$|ddtrace = { path = "./dd-trace-py" }|' datadog-lambda-python/pyproject.toml
7877
else
7978
sed -i 's|^ddtrace =.*$|ddtrace = { path = "./dd-trace-py" }|' datadog-lambda-python/pyproject.toml
8079
fi
81-
cp -r dd-trace-py datadog-lambda-python/dd-trace-py
82-
elif [ "$(find . -maxdepth 1 -name "*.whl" | wc -l)" = "1" ]; then
80+
elif [ "$(find . -maxdepth 1 -name "datadog-lambda-python/*.whl" | wc -l)" = "1" ]; then
8381
path=$(readlink -f "$(find . -maxdepth 1 -name "*.whl")")
8482
echo "Install ddtrace from ${path}"
8583
if [[ "$OSTYPE" == "darwin"* ]]; then
8684
sed -i '' "s|^ddtrace =.*$|ddtrace = { path = \"file://${path}\" }|" datadog-lambda-python/pyproject.toml
8785
else
8886
sed -i "s|^ddtrace =.*$|ddtrace = { path = \"file://${path}\" }|" datadog-lambda-python/pyproject.toml
8987
fi
90-
cp -r ./*.whl datadog-lambda-python/
91-
elif [ "$(find . -maxdepth 1 -name "python-load-from-pip" | wc -l)" = "1" ]; then
92-
echo "Install ddtrace from $(cat python-load-from-pip)"
93-
94-
pip_spec=$(cat python-load-from-pip)
95-
if [[ $pip_spec =~ ddtrace\ @\ git\+(.*)@(.*)$ ]]; then
96-
# Format with revision: ddtrace @ git+https://...@revision
97-
git_url="${BASH_REMATCH[1]}"
98-
git_rev="${BASH_REMATCH[2]}"
99-
if [[ "$OSTYPE" == "darwin"* ]]; then
100-
sed -i '' "s|^ddtrace =.*$|ddtrace = { git = \"${git_url}\", rev = \"${git_rev}\" }|" datadog-lambda-python/pyproject.toml
101-
else
102-
sed -i "s|^ddtrace =.*$|ddtrace = { git = \"${git_url}\", rev = \"${git_rev}\" }|" datadog-lambda-python/pyproject.toml
103-
fi
104-
elif [[ $pip_spec =~ ddtrace\ @\ git\+(.*)$ ]]; then
105-
# Format without revision: ddtrace @ git+https://... (defaults to main)
106-
git_url="${BASH_REMATCH[1]}"
107-
if [[ "$OSTYPE" == "darwin"* ]]; then
108-
sed -i '' "s|^ddtrace =.*$|ddtrace = { git = \"${git_url}\" }|" datadog-lambda-python/pyproject.toml
109-
else
110-
sed -i "s|^ddtrace =.*$|ddtrace = { git = \"${git_url}\" }|" datadog-lambda-python/pyproject.toml
111-
fi
112-
else
113-
echo "ERROR: Unable to parse git URL from python-load-from-pip format: $pip_spec"
114-
exit 1
115-
fi
11688
elif [ "$(find . -maxdepth 1 -name "*.whl" | wc -l)" = "0" ]; then
11789
echo "Install ddtrace from pypi"
11890
# Keep the default ddtrace dependency in pyproject.toml
11991
else
12092
echo "ERROR: Found several wheel files in binaries/, abort."
12193
exit 1
12294
fi
95+
12396
# Build the datadog-lambda-python package
12497
cd datadog-lambda-python
12598
ARCH=$ARCH PYTHON_VERSION=$PYTHON_VERSION bash ./scripts/build_layers.sh

utils/scripts/load-binary.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -300,17 +300,18 @@ elif [ "$TARGET" = "python_lambda" ]; then
300300
assert_version_is_dev
301301
assert_target_branch_is_not_set
302302

303-
rm -rf dd-trace-py/
304303
rm -rf datadog-lambda-python/
304+
305+
git clone https://github.com/DataDog/datadog-lambda-python.git
306+
cd datadog-lambda-python
307+
echo "Checking out the datadog_lambda ref"
308+
git log -1 --format=%H
309+
305310
# do not use `--depth 1`, setuptools_scm, does not like it
306311
git clone https://github.com/DataDog/dd-trace-py.git
307-
git clone https://github.com/DataDog/datadog-lambda-python.git
308312
cd dd-trace-py
309313
echo "Checking out the ddtrace ref"
310314
git log -1 --format=%H
311-
cd ../datadog-lambda-python
312-
echo "Checking out the datadog_lambda ref"
313-
git log -1 --format=%H
314315

315316
else
316317
echo "Unknown target: $1"

0 commit comments

Comments
 (0)