-
Notifications
You must be signed in to change notification settings - Fork 28
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: refactor docker setup for local testing
The previous setup for local testing, using docker and tox, had multiple problems: 1) Tests ran as root in the container. All files, created by tox in the container belonged to root after the test-suite finished. That meant that caches and test artifacts, like screenshots or clips, had to be accessed using sudo. 2) Playwright installation steps could not be cached. The playwright installation commands, that setup the underlying ubuntu container and install the actual browsers, had to run on every run of the test-suite, which is expensive. 3) The test container had only one, unspecified, Python version installed. The docker image for the test-suite is based on the Microsofts playwright image, which is based some Ubuntu image. So the Python version always was the current Python3 version on Ubuntu. This was problematic because the version could change on every run and testing with multiple Python versions was impossible. This patch fixes all of these problems by adding a script that runs the test container as the current user, and updates the playwright docker file to install all Python versions that Lona supports, using pyenv. Signed-off-by: Florian Scherf <[email protected]>
- Loading branch information
Showing
8 changed files
with
75 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
#!/bin/bash | ||
|
||
# set the docker user to the local user so test environments and artifacts | ||
# can be access from inside and outside of the test container | ||
export DOCKER_USER=$(id -u):$(id -g) | ||
|
||
exec docker-compose $@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
version: "3" | ||
|
||
networks: | ||
net: | ||
driver: bridge | ||
|
||
services: | ||
playwright: | ||
user: ${DOCKER_USER} | ||
|
||
build: | ||
context: ./ | ||
dockerfile: playwright.Dockerfile | ||
|
||
networks: | ||
- net | ||
|
||
volumes: | ||
- ./:/app | ||
|
||
environment: | ||
- PLAYWRIGHT_BROWSERS_PATH=/ms-playwright | ||
|
||
working_dir: "/app" | ||
command: "tox" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
FROM mcr.microsoft.com/playwright:v1.34.0-jammy | ||
|
||
# upgrade ubuntu | ||
RUN apt update && apt upgrade -y | ||
|
||
# setup tzdata (required by pyenv dependencies) | ||
RUN apt update && DEBIAN_FRONTEND=noninteractive TZ=Gmt/UTC apt-get -y install tzdata | ||
|
||
# install pyenv dependencies | ||
RUN apt update && apt install -y \ | ||
git build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \ | ||
libsqlite3-dev curl libncursesw5-dev xz-utils tk-dev libxml2-dev \ | ||
libxmlsec1-dev libffi-dev liblzma-dev | ||
|
||
# setup pyenv | ||
RUN git clone https://github.com/yyuu/pyenv.git .pyenv | ||
ENV PYENV_ROOT $HOME/.pyenv | ||
ENV PATH $PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH | ||
|
||
RUN pyenv install 3.7:latest | ||
RUN pyenv install 3.8:latest | ||
RUN pyenv install 3.9:latest | ||
RUN pyenv install 3.10:latest | ||
RUN pyenv install 3.11:latest | ||
|
||
RUN pyenv global `pyenv versions --bare` | ||
|
||
# setup commandline tools | ||
RUN pip3.10 install --upgrade pip tox | ||
RUN pyenv rehash |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters