Add scripts to verify compatibility with multiple Python versions, using Docker

This commit is contained in:
c0llab0rat0r
2021-04-04 15:50:14 -05:00
committed by Alexander Schlarb
parent 895df8bb6d
commit ca46d2abc9
5 changed files with 73 additions and 0 deletions

View File

@@ -18,6 +18,8 @@ description-file = "README.md"
# `typing.NoReturn` function signature support. (Also, many other `typing` module
# items were only introduced post-release in 3.6 and version restrictions on these
# versions ensure that those are all available as well.)
#
# Maintain this concurrently with verify.sh
requires-python = ">=3.6.2,!=3.7.0,!=3.7.1"
requires = [
"multiaddr (>=0.0.7)",

15
tools/verify/Dockerfile Normal file
View File

@@ -0,0 +1,15 @@
ARG PYTHON_VERSION
FROM python:${PYTHON_VERSION}
RUN pip install --upgrade pip
RUN pip install tox
# Mount the source code here, instead of to /usr/src/app.
# Otherwise, tox will fail due to folder being read-only.
# Mount only the source code; avoid mounting working folders.
RUN mkdir /source
ADD entrypoint.sh /
ENTRYPOINT ["/entrypoint.sh"]

6
tools/verify/entrypoint.sh Executable file
View File

@@ -0,0 +1,6 @@
#!/usr/bin/env bash
cp -r /source/* /usr/src/app/
exec $@

31
tools/verify/validate.sh Executable file
View File

@@ -0,0 +1,31 @@
#!/bin/bash
set -e
python_version=$1
script_path=$(dirname $0)
source=$(realpath "$script_path/../..")
tag=py-ipfs-http-client-verify:$python_version
pushd "$script_path"
echo "Building validator for Python $python_version..."
docker build --build-arg PYTHON_VERSION="$python_version" -t "$tag" .
echo "Validating version $python_version"
docker run \
-it \
-v "$source/docs":/source/docs:ro \
-v "$source/ipfshttpclient":/source/ipfshttpclient:ro \
-v "$source/test":/source/test:ro \
-v "$source/pyproject.toml":/source/pyproject.toml:ro \
-v "$source/README.md":/source/README.md:ro \
-v "$source/tox.ini":/source/tox.ini:ro \
-w /usr/src/app \
"$tag" \
tox -e styleck -e typeck
popd

19
verify.sh Executable file
View File

@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e
function validate() {
./tools/verify/validate.sh "$1"
}
if [ -z "$1" ]; then
echo "Validating minimum point release of each supported minor version..."
# Maintain this concurrently with [tool.flit.metadata].requires-python in pyproject.toml.
validate 3.6.2
validate 3.7.2
validate 3.8.0
else
echo "Validating only $1..."
validate "$1"
fi