From cebb189d337eab303f3badab2bf77422e3902037 Mon Sep 17 00:00:00 2001 From: toofar Date: Sun, 13 Oct 2024 15:01:27 +1300 Subject: [PATCH] Add docker compose file I find it difficult to reproduce issues on old python versions, or when archlinux brings in a newer build of Qt than I have and I can't be bothered rebuilding. I've been using docker for a while to help test in these environments locally, but the docker command is a bit long and unwieldy. Docker compose is a method I've used before to provide canned docker invocation. We could probably get away with writing our own script for it, but using standard components is good. This should work with podman-compose too. This commit encodes the docker command I've been using so that I, and other people, can use it with a less arcane command line. Hopefully it helps other people. There are still a few rough edges like for any runs of the "other" service you will pretty much have to drop into a bash shell and install tox and some X11 stuff. But the images we publish work in one-liners (although they would be a little faster with a tox/pip cache directory mounted from the host so they don't setup the venv every time). See also: the docker related hints in the contributor guidlines. --- docker-compose.yml | 67 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 000000000..358246b71 --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,67 @@ +# Holds common docker settings for running containerized tests. +# +# Examples: +# docker-compose run archlinux-webkit tox -e py-qt5 -- tests/unit/browser/webengine/test_webenginesettings.py +# docker-compose run archlinux-webengine-unstable-qt6 tox -e py -- tests/unit/browser/webengine/test_webenginesettings.py +# IMAGE=python:3.8 docker-compose run other bash +# +# archlinux-* images are generated by scripts/dev/ci/docker/generate.py and +# published from CI. +# For other images, like python:3.8 or ubuntu:20.04, use +# `IMAGE=python:3.8 docker-compose run other bash`. +# See doc/contributing.asciidoc for more notes. +# +# `extends` might not work on some compose versions: https://stackoverflow.com/questions/36283908/re-using-environment-variables-in-docker-compose-yml +# Env var interpolation (for the "other") service, might not work on older +# compose versions. +services: + base: + image: index.docker.io/library/python:3 + environment: + QUTE_TESTS_BACKEND: "webengine" + # DISPLAY allows connecting applications in the container to a Xephyr display on + # the host via the mounted /tmp/ directory below. + # Run like: + # Xephyr :27 -ac -resizeable -title qutetests -screen 1920x1080 -no-host-grab + DISPLAY: ":27" + # Since we are mounting the source dir from the host, move cache dirs + # out of the work directory into the container so we can avoid conflicts + # with permissions. + TOX_WORK_DIR: "/home/user/.tox" + HYPOTHESIS_EXAMPLES_DIR: "/home/user/.hypothesis/examples" + # This tells tox to make the system site packages available in the + # virtualenvs it creates, which lets you use the distro Qt when doing `tox -e py` + VIRTUALENV_SYSTEM_SITE_PACKAGES: "true" + working_dir: /work + volumes: + - /tmp/.X11-unix:/tmp/.X11-unix + - type: bind + source: $PWD + target: /work + read_only: true + + archlinux-webengine-unstable-qt6: + extends: base + image: index.docker.io/qutebrowser/ci:archlinux-webengine-unstable-qt6 + + archlinux-webengine-unstable: + image: index.docker.io/qutebrowser/ci:archlinux-webengine-unstable + extends: base + + archlinux-webengine-qt6: + image: index.docker.io/qutebrowser/ci:archlinux-webengine-qt6 + extends: base + + archlinux-webengine: + image: index.docker.io/qutebrowser/ci:archlinux-webengine + extends: base + + archlinux-webkit: + image: index.docker.io/qutebrowser/ci:archlinux-webkit + extends: base + environment: + QUTE_TESTS_BACKEND: "webkit" + + other: + image: "${IMAGE}" + extends: base