Skip to content
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

[PR #6132/5d1f0eca backport][3.8] Run test in docker #6154

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
1 change: 1 addition & 0 deletions CHANGES/6131.misc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Add test targets to Makefile for different versions of Python
24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,30 @@ vtest: .develop
vvtest: .develop
@pytest -vv


define run_tests_in_docker
DOCKER_BUILDKIT=1 docker build --build-arg PYTHON_VERSION=$(1) --build-arg AIOHTTP_NO_EXTENSIONS=$(2) -t "aiohttp-test-$(1)-$(2)" -f tools/testing/Dockerfile .
docker run --rm -ti -v `pwd`:/src -w /src "aiohttp-test-$(1)-$(2)" $(TEST_SPEC)
endef

.PHONY: test-3.7-no-extensions test-3.7 test-3.8-no-extensions test-3.8 test-3.9-no-extensions test-3.9 test-3.10-no-extensions test-3.10
test-3.7-no-extensions:
$(call run_tests_in_docker,3.7,y)
test-3.7:
$(call run_tests_in_docker,3.7,n)
test-3.8-no-extensions:
$(call run_tests_in_docker,3.8,y)
test-3.8:
$(call run_tests_in_docker,3.8,n)
test-3.9-no-extensions:
$(call run_tests_in_docker,3.9,y)
test-3.9:
$(call run_tests_in_docker,3.9,n)
test-3.10-no-extensions:
$(call run_tests_in_docker,3.10,y)
test-3.10:
$(call run_tests_in_docker,3.10,n)

.PHONY: clean
clean:
@rm -rf `find . -name __pycache__`
Expand Down
12 changes: 12 additions & 0 deletions docs/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,18 @@ Please take a look on the produced output.

Any extra texts (print statements and so on) should be removed.

.. note::

If you see that CI build is failing on a specific Python version and
you don't have this version on your computer, you can use the helper to
run it (only if you have docker)::

make test-<python-version>[-no-extensions]

For example, if you want to run tests for python3.7
without extensions, you can run this command::

make test-3.7-no-extensions

Tests coverage
--------------
Expand Down
15 changes: 15 additions & 0 deletions tools/testing/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
ARG PYTHON_VERSION
FROM python:$PYTHON_VERSION

ARG AIOHTTP_NO_EXTENSIONS
ENV AIOHTTP_NO_EXTENSIONS=$AIOHTTP_NO_EXTENSIONS

WORKDIR /deps
ADD ./requirements ./requirements
ADD Makefile .
RUN make install

ADD ./tools/testing/entrypoint.sh /

WORKDIR /src
ENTRYPOINT ["/bin/bash", "/entrypoint.sh"]
4 changes: 4 additions & 0 deletions tools/testing/Dockerfile.dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
*
!/requirements
!/Makefile
!/tools/testing/entrypoint.sh
5 changes: 5 additions & 0 deletions tools/testing/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

[[ "$AIOHTTP_NO_EXTENSIONS" != "y" ]] && make cythonize

python -m pytest -qx --no-cov $1