Skip to content

Commit ca46d2a

Browse files
c0llab0rat0rntninja
authored andcommitted
Add scripts to verify compatibility with multiple Python versions, using Docker
1 parent 895df8b commit ca46d2a

File tree

5 files changed

+73
-0
lines changed

5 files changed

+73
-0
lines changed

pyproject.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ description-file = "README.md"
1818
# `typing.NoReturn` function signature support. (Also, many other `typing` module
1919
# items were only introduced post-release in 3.6 and version restrictions on these
2020
# versions ensure that those are all available as well.)
21+
#
22+
# Maintain this concurrently with verify.sh
2123
requires-python = ">=3.6.2,!=3.7.0,!=3.7.1"
2224
requires = [
2325
"multiaddr (>=0.0.7)",

tools/verify/Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
ARG PYTHON_VERSION
2+
3+
FROM python:${PYTHON_VERSION}
4+
5+
RUN pip install --upgrade pip
6+
RUN pip install tox
7+
8+
# Mount the source code here, instead of to /usr/src/app.
9+
# Otherwise, tox will fail due to folder being read-only.
10+
# Mount only the source code; avoid mounting working folders.
11+
12+
RUN mkdir /source
13+
ADD entrypoint.sh /
14+
15+
ENTRYPOINT ["/entrypoint.sh"]

tools/verify/entrypoint.sh

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
#!/usr/bin/env bash
2+
3+
cp -r /source/* /usr/src/app/
4+
5+
exec $@
6+

tools/verify/validate.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
python_version=$1
6+
script_path=$(dirname $0)
7+
source=$(realpath "$script_path/../..")
8+
tag=py-ipfs-http-client-verify:$python_version
9+
10+
pushd "$script_path"
11+
12+
echo "Building validator for Python $python_version..."
13+
14+
docker build --build-arg PYTHON_VERSION="$python_version" -t "$tag" .
15+
16+
echo "Validating version $python_version"
17+
18+
docker run \
19+
-it \
20+
-v "$source/docs":/source/docs:ro \
21+
-v "$source/ipfshttpclient":/source/ipfshttpclient:ro \
22+
-v "$source/test":/source/test:ro \
23+
-v "$source/pyproject.toml":/source/pyproject.toml:ro \
24+
-v "$source/README.md":/source/README.md:ro \
25+
-v "$source/tox.ini":/source/tox.ini:ro \
26+
-w /usr/src/app \
27+
"$tag" \
28+
tox -e styleck -e typeck
29+
30+
popd
31+

verify.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
#!/usr/bin/env bash
2+
3+
set -e
4+
5+
function validate() {
6+
./tools/verify/validate.sh "$1"
7+
}
8+
9+
if [ -z "$1" ]; then
10+
echo "Validating minimum point release of each supported minor version..."
11+
12+
# Maintain this concurrently with [tool.flit.metadata].requires-python in pyproject.toml.
13+
validate 3.6.2
14+
validate 3.7.2
15+
validate 3.8.0
16+
else
17+
echo "Validating only $1..."
18+
validate "$1"
19+
fi

0 commit comments

Comments
 (0)