From b2c7047e6138b163ff78b186b7d507bf1106717b Mon Sep 17 00:00:00 2001 From: Russell Keith-Magee Date: Sat, 4 May 2024 10:26:46 +0800 Subject: [PATCH] Add some basic testing environment info. --- README.rst | 35 ++++++++++++++++++++++++++++++++++- tests/Dockerfile | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 1 deletion(-) create mode 100644 tests/Dockerfile diff --git a/README.rst b/README.rst index 0be44c4..f6cd194 100644 --- a/README.rst +++ b/README.rst @@ -38,7 +38,7 @@ If you notice any differences, please report them. Requirements ------------ -- python 3.7+ +- python 3.8+ - pygobject - glib - gtk+3 (optional) @@ -129,6 +129,39 @@ actually prevent you from doing that (in accordance with PEP 3156), however in mind that enclosed loops may be started at any time by third-party code calling GLib's primitives. +Testing +------- + +Testing GBulb requires a Linux environment that has GLib and GTK development +libraries available. + +The tests folder contains a Dockerfile that defines a complete testing +environment. To use the Docker environment, run the following from the root of +the git checkout: + + $ docker buildx build --tag beeware/gbulb:latest --file ./tests/Dockerfile . + $ docker run --rm --volume $(PWD):/home/brutus/gbulb:z -it beeware/gbulb:latest + +This will drop you into an Ubuntu 24.04 shell that has Python 3.8-3.13 +installed, mounting the current working directory as `/home/brutus/gbulb`. You +can use this to create virtual environments for each Python version. + +Once you have an active virtual environment, run: + + (venv) $ pip install -e .[dev] + (venv) $ pytest + +to run the test suite. Alternatively, you can install tox, and then run: + + # To test a single Python version + (venv) $ tox -e py + + # To test Python 3.10 specifically + (venv) $ tox -e py310 + + # To test all versions + (venv) $ tox + Community --------- diff --git a/tests/Dockerfile b/tests/Dockerfile new file mode 100644 index 0000000..8ae89f0 --- /dev/null +++ b/tests/Dockerfile @@ -0,0 +1,48 @@ +FROM ubuntu:24.04 + +# Disable pip's warnings and SDL audio +ENV PIP_ROOT_USER_ACTION=ignore \ + PIP_NO_WARN_SCRIPT_LOCATION=0 \ + SDL_AUDIODRIVER=dummy + +# Run apt non-interactively; use ARG so this only applies while building the image +ARG DEBIAN_FRONTEND="noninteractive" + +# Add deadsnakes +RUN apt-get update -y && \ + apt-get install --no-install-recommends -y software-properties-common && \ + add-apt-repository ppa:deadsnakes/ppa + +# Install System python +RUN apt-get update -y && \ + apt-get install --no-install-recommends -y \ + libgirepository1.0-dev \ + gir1.2-gtk-3.0 \ + libcairo2-dev \ + build-essential \ + git \ + python3.8-dev \ + python3.8-venv \ + python3.9-dev \ + python3.9-venv \ + python3.10-dev \ + python3.10-venv \ + python3.11-dev \ + python3.11-venv \ + python3-dev \ + python3-venv \ + python3.13-dev \ + python3.13-venv \ + python3-pip + +RUN groupadd beeware && \ + useradd brutus -g beeware --home /home/brutus && \ + mkdir -p /home/brutus && chown brutus:beeware /home/brutus + +# Use the brutus user for operations in the container +USER brutus + +# Set the working directory +WORKDIR /home/brutus/gbulb + +CMD /bin/bash