diff --git a/pyproject.toml b/pyproject.toml index c2cbffe2..96387bef 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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)", diff --git a/tools/verify/Dockerfile b/tools/verify/Dockerfile new file mode 100644 index 00000000..2351ffea --- /dev/null +++ b/tools/verify/Dockerfile @@ -0,0 +1,15 @@ +ARG PYTHON_VERSION + +FROM python:${PYTHON_VERSION}-slim + +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"] diff --git a/tools/verify/entrypoint.sh b/tools/verify/entrypoint.sh new file mode 100755 index 00000000..d35ce232 --- /dev/null +++ b/tools/verify/entrypoint.sh @@ -0,0 +1,6 @@ +#!/usr/bin/env bash + +cp -r /source/* /usr/src/app/ + +exec $@ + diff --git a/tools/verify/validate.sh b/tools/verify/validate.sh new file mode 100755 index 00000000..3c96c277 --- /dev/null +++ b/tools/verify/validate.sh @@ -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 + diff --git a/verify.sh b/verify.sh new file mode 100755 index 00000000..11b44439 --- /dev/null +++ b/verify.sh @@ -0,0 +1,20 @@ +#!/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 + validate 3.9.0 +else + echo "Validating only $1..." + validate "$1" +fi