Skip to content

Commit

Permalink
Run test in docker (#6132)
Browse files Browse the repository at this point in the history
* Add make targets for testing with specific version in Docker

* Update docs

* add CHANGES file

* fix spelling

(cherry picked from commit 5d1f0ec)
  • Loading branch information
derlih authored and Patchback committed Oct 28, 2021
1 parent 7d046b5 commit c802983
Show file tree
Hide file tree
Showing 6 changed files with 61 additions and 0 deletions.
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

0 comments on commit c802983

Please sign in to comment.