Skip to content

Commit 4fc91d2

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

File tree

2 files changed

+82
-0
lines changed

2 files changed

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

scripts/check_dependencies.sh

Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 $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 run \
38+
--platform=$DOCKER_DEFAULT_PLATFORM \
39+
--entrypoint='' \
40+
public.ecr.aws/lambda/python:$PYTHON_VERSION \
41+
python -c "import pip._vendor.requests; print(pip._vendor.requests.__version__)"
42+
)
43+
echo "Version of vendored requests: $vendored"
44+
45+
# compare versions
46+
compared=$(python -c "
47+
parse = lambda v: tuple(map(int, v.split('.')))
48+
print(parse('$lowest') <= parse('$vendored'))")
49+
50+
if [[ "$compared" == "True" ]]; then
51+
echo "The vendored version of requests meets the minimum requirement"
52+
echo " lowest required ($lowest) <= vendored version ($vendored) <= highest available ($highest)"
53+
else
54+
echo "The vendored version of requests does not meet the minimum requirement"
55+
echo " vendered version ($vendored) < lowest required ($lowest) <= highest available ($highest)"
56+
exit 1
57+
fi

0 commit comments

Comments
 (0)