From 3a320f12dca0692948b1770d75485ade91b5d169 Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Sun, 4 Apr 2021 15:50:14 -0500 Subject: [PATCH 1/2] Add scripts to verify compatibility with multiple Python versions, using Docker --- pyproject.toml | 2 ++ tools/verify/Dockerfile | 15 +++++++++++++++ tools/verify/entrypoint.sh | 6 ++++++ tools/verify/validate.sh | 31 +++++++++++++++++++++++++++++++ verify.sh | 19 +++++++++++++++++++ 5 files changed, 73 insertions(+) create mode 100644 tools/verify/Dockerfile create mode 100755 tools/verify/entrypoint.sh create mode 100755 tools/verify/validate.sh create mode 100755 verify.sh 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..740ab85c --- /dev/null +++ b/tools/verify/Dockerfile @@ -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"] 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..90bfb2fa --- /dev/null +++ b/verify.sh @@ -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 From 6e29c7f1e12efe49db7aed7cb04c38972cda7f1b Mon Sep 17 00:00:00 2001 From: c0llab0rat0r <78339685+c0llab0rat0r@users.noreply.github.com> Date: Wed, 14 Apr 2021 17:01:44 -0500 Subject: [PATCH 2/2] Add Python 3.9 to Docker-based verification --- tools/verify/Dockerfile | 2 +- verify.sh | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/verify/Dockerfile b/tools/verify/Dockerfile index 740ab85c..2351ffea 100644 --- a/tools/verify/Dockerfile +++ b/tools/verify/Dockerfile @@ -1,6 +1,6 @@ ARG PYTHON_VERSION -FROM python:${PYTHON_VERSION} +FROM python:${PYTHON_VERSION}-slim RUN pip install --upgrade pip RUN pip install tox diff --git a/verify.sh b/verify.sh index 90bfb2fa..11b44439 100755 --- a/verify.sh +++ b/verify.sh @@ -13,6 +13,7 @@ if [ -z "$1" ]; then validate 3.6.2 validate 3.7.2 validate 3.8.0 + validate 3.9.0 else echo "Validating only $1..." validate "$1"