-
Notifications
You must be signed in to change notification settings - Fork 45
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Github action to ensure vendored requests version.
- Loading branch information
1 parent
5ee2c8c
commit c69e6d1
Showing
2 changed files
with
75 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
name: Check Dependencies | ||
|
||
on: | ||
pull_request: | ||
|
||
jobs: | ||
check: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
python-version: ['3.8', '3.9', '3.10', '3.11', '3.12'] | ||
architecture: ['linux/amd64', 'linux/arm64'] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Check Dependencies | ||
run: | | ||
ARCHITECTURE=${{ matrix.architecture }} \ | ||
PYTHON_VERSION=${{ matrix.python-version }} \ | ||
./scripts/check_dependencies.sh |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
#!/bin/bash -ex | ||
|
||
# This script checks to make sure that the vendored version of requests shipped | ||
# with pip meets the minimum required version of requests as defined by the | ||
# datadog package. | ||
|
||
if [[ -z $ARCHITECTURE ]]; then | ||
DOCKER_DEFAULT_PLATFORM='linux/amd64' | ||
else | ||
DOCKER_DEFAULT_PLATFORM=$ARCHITECTURE | ||
fi | ||
|
||
if [[ -z $PYTHON_VERSION ]]; then | ||
PYTHON_VERSION=latest | ||
fi | ||
|
||
# create virtual environment | ||
rm -rf venv | ||
pip install virtualenv | ||
virtualenv venv | ||
source venv/bin/activate | ||
|
||
# determine highest available version of requests | ||
pip install . | ||
highest=$(pip freeze | grep requests | tr -d 'requests==') | ||
echo "Highest available version of requests: $highest" | ||
|
||
# determine minumum required version of requests | ||
pip uninstall -y requests | ||
pip install uv | ||
uv pip install --resolution=lowest . | ||
lowest=$(pip freeze | grep requests | tr -d 'requests==') | ||
echo "Minimum required version of requests: $lowest" | ||
|
||
# determine version of requests packaged with pip | ||
vendored=$( | ||
DOCKER_DEFAULT_PLATFORM=$DOCKER_DEFAULT_PLATFORM \ | ||
docker run --entrypoint='' public.ecr.aws/lambda/python:$PYTHON_VERSION \ | ||
python -c "import pip._vendor.requests; print(pip._vendor.requests.__version__)" | ||
) | ||
echo "Version of vendored requests: $vendored" | ||
|
||
# compare versions | ||
compared=$(python -c " | ||
parse = lambda v: tuple(map(int, v.split('.'))) | ||
print(parse('$lowest') <= parse('$vendored'))") | ||
|
||
if [[ $compared == "True" ]]; then | ||
echo "The vendored version of requests meets the minimum requirement" | ||
echo " lowest required ($lowest) <= vendored version ($vendored) <= highest available ($highest)" | ||
else | ||
echo "The vendored version of requests does not meet the minimum requirement" | ||
echo " vendered version ($vendored) < lowest required ($lowest) <= highest available ($highest)" | ||
exit 1 | ||
fi |