Skip to content

Commit 231a000

Browse files
committed
Github action to ensure vendored requests version.
1 parent 5ee2c8c commit 231a000

File tree

2 files changed

+79
-0
lines changed

2 files changed

+79
-0
lines changed
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
name: Check Dependencies
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
check:
8+
runs-on: ubuntu-latest
9+
strategy:
10+
matrix:
11+
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12']
12+
architecture: ['linux/amd64', 'linux/arm64']
13+
steps:
14+
- uses: actions/checkout@v3
15+
16+
- name: Check Dependencies
17+
run: |
18+
ARCHITECTURE=${{ matrix.architecture }} \
19+
PYTHON_VERSION=${{ matrix.python-version }} \
20+
./scripts/check_dependencies.sh

scripts/check_dependencies.sh

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#!/bin/bash -ex
2+
3+
# This script checks to make sure that the vendored version of requests shipped
4+
# with pip meets the minimum required version of requests as defined by the
5+
# datadog package.
6+
7+
if [[ -z $ARCHITECTURE ]]; then
8+
DOCKER_DEFAULT_PLATFORM='linux/amd64'
9+
else
10+
DOCKER_DEFAULT_PLATFORM=$ARCHITECTURE
11+
fi
12+
13+
if [[ -z $PYTHON_VERSION ]]; then
14+
PYTHON_VERSION=latest
15+
fi
16+
17+
# create virtual environment
18+
rm -rf venv
19+
pip install virtualenv
20+
virtualenv venv
21+
source venv/bin/activate
22+
23+
# determine highest available version of requests
24+
pip install .
25+
highest=$(pip freeze | grep requests | tr -d 'requests==')
26+
echo "Highest available version of requests: $highest"
27+
28+
# determine minumum required version of requests
29+
pip uninstall -y requests
30+
pip install uv
31+
uv pip install --resolution=lowest .
32+
lowest=$(pip freeze | grep requests | tr -d 'requests==')
33+
echo "Minimum required version of requests: $lowest"
34+
35+
# determine version of requests packaged with pip
36+
vendored=$(
37+
DOCKER_DEFAULT_PLATFORM=$DOCKER_DEFAULT_PLATFORM \
38+
docker run --entrypoint='' public.ecr.aws/lambda/python:$PYTHON_VERSION \
39+
python -c "import pip._vendor.requests; print(pip._vendor.requests.__version__)"
40+
)
41+
echo "Version of vendored requests: $vendored"
42+
43+
# compare versions
44+
pip install packaging
45+
compared=$(
46+
python -c "
47+
def parse(version):
48+
return map(int, version.split('.'))
49+
print(parse('$lowest') <= parse('$vendored'))"
50+
)
51+
52+
if [[ $compared == "True" ]]; then
53+
echo "The vendored version of requests meets the minimum requirement"
54+
echo " lowest required ($lowest) <= vendored version ($vendored) <= highest available ($highest)"
55+
else
56+
echo "The vendored version of requests does not meet the minimum requirement"
57+
echo " vendered version ($vendored) < lowest required ($lowest) <= highest available ($highest)"
58+
exit 1
59+
fi

0 commit comments

Comments
 (0)