Skip to content

Add scripts to verify compatibility with multiple Python versions #259

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
May 15, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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)",
Expand Down
15 changes: 15 additions & 0 deletions tools/verify/Dockerfile
Original file line number Diff line number Diff line change
@@ -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"]
6 changes: 6 additions & 0 deletions tools/verify/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash

cp -r /source/* /usr/src/app/

exec $@

31 changes: 31 additions & 0 deletions tools/verify/validate.sh
Original file line number Diff line number Diff line change
@@ -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

20 changes: 20 additions & 0 deletions verify.sh
Original file line number Diff line number Diff line change
@@ -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