Skip to content

Commit 591509d

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

File tree

2 files changed

+73
-0
lines changed

2 files changed

+73
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
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+
steps:
13+
- uses: actions/checkout@v3
14+
15+
- name: Set up Python ${{ matrix.python-version }}
16+
uses: actions/setup-python@v4
17+
with:
18+
python-version: ${{ matrix.python-version }}
19+
20+
- name: Check Dependencies
21+
run: |
22+
PYTHON_VERSION=${{ matrix.python-version }} \
23+
./scripts/check_dependencies.sh

scripts/check_dependencies.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#!/bin/bash -e
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 $PYTHON_VERSION ]]; then
8+
PYTHON_VERSION=latest
9+
fi
10+
11+
# create virtual environment
12+
rm -rf venv
13+
pip install virtualenv
14+
virtualenv venv
15+
source venv/bin/activate
16+
17+
# determine highest available version of requests
18+
pip install .
19+
highest=$(pip freeze | grep requests | tr -d 'requests==')
20+
echo "Highest available version of requests: $highest"
21+
22+
# determine minumum required version of requests
23+
pip uninstall -y requests
24+
pip install uv
25+
uv pip install --resolution=lowest .
26+
lowest=$(pip freeze | grep requests | tr -d 'requests==')
27+
echo "Minimum required version of requests: $lowest"
28+
29+
# determine version of requests packaged with pip
30+
vendored=$(
31+
docker run \
32+
--entrypoint='' \
33+
public.ecr.aws/lambda/python:$PYTHON_VERSION \
34+
python -c "import pip._vendor.requests; print(pip._vendor.requests.__version__)"
35+
)
36+
echo "Version of vendored requests: $vendored"
37+
38+
# compare versions
39+
compared=$(python -c "
40+
parse = lambda v: tuple(map(int, v.split('.')))
41+
print(parse('$lowest') <= parse('$vendored'))")
42+
43+
if [[ "$compared" == "True" ]]; then
44+
echo "The vendored version of requests meets the minimum requirement"
45+
echo " lowest required ($lowest) <= vendored version ($vendored) <= highest available ($highest)"
46+
else
47+
echo "The vendored version of requests does not meet the minimum requirement"
48+
echo " vendered version ($vendored) < lowest required ($lowest) <= highest available ($highest)"
49+
exit 1
50+
fi

0 commit comments

Comments
 (0)