Skip to content

Add a folder and a separated Dockerfile for the frontend tests #178

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

Draft
wants to merge 8 commits into
base: master
Choose a base branch
from
Draft
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
20 changes: 0 additions & 20 deletions .github/workflows/ci_frontend.yml

This file was deleted.

12 changes: 0 additions & 12 deletions clockwork_dev.Dockerfile
Original file line number Diff line number Diff line change
@@ -1,14 +1,6 @@
FROM python:3.9-slim-buster

RUN mkdir /clockwork
# Create folder required by Playwright to install browsers,
# and set permissions so that Playwright can install browsers in these folders.
RUN mkdir /.cache
RUN chmod -R 777 /.cache
RUN chmod -R 777 /clockwork

# Add a variable available only inside container.
ENV WE_ARE_IN_DOCKER=1

ENV CLOCKWORK_ROOT=/clockwork
ENV PYTHONPATH=${PYTHONPATH}:${CLOCKWORK_ROOT}:${CLOCKWORK_ROOT}/clockwork_tools
Expand All @@ -22,10 +14,6 @@ ENV MONGODB_DATABASE_NAME="clockwork"
# to have gcc to build `dulwich` used by poetry
RUN apt update && apt install -y build-essential git

# Install OS packages required for Playwright browsers
# https://github.com/microsoft/playwright-python/issues/498#issuecomment-856349356
RUN apt install -y gstreamer1.0-libav libnss3-tools libatk-bridge2.0-0 libcups2-dev libxkbcommon-x11-0 libxcomposite-dev libxrandr2 libgbm-dev libgtk-3-0

RUN pip install --upgrade pip poetry

COPY clockwork_web/requirements.txt /requirements_web.txt
Expand Down
24 changes: 24 additions & 0 deletions clockwork_frontend_test/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
FROM clockwork_web

# Create folder required by Playwright to install browsers
# and set permissions so that Playwright can install browsers in this folder
RUN mkdir /.cache
RUN chmod -R 777 /.cache
Copy link
Collaborator Author

@soline-b soline-b Dec 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not really happy with this, but could not find another option for now.


RUN apt update && apt install -y build-essential

# Install OS packages required for Playwright browsers
# https://github.com/microsoft/playwright-python/issues/498#issuecomment-856349356
RUN apt install -y gstreamer1.0-libav libnss3-tools libatk-bridge2.0-0 libcups2-dev libxkbcommon-x11-0 libxcomposite-dev libxrandr2 libgbm-dev libgtk-3-0

# Install Python requirements for clockwork frontend/javascript tests.
# This include package `pytest-playwright`.
COPY clockwork_frontend_test/requirements.txt /requirements_frontend_test.txt
RUN pip install -r /requirements_frontend_test.txt && rm -rf /root/.cache

# Add a variable available only inside container.
ENV WE_ARE_IN_DOCKER=1
ENV CLOCKWORK_ENABLE_TESTING_LOGIN="True"

CMD ["bash", "clockwork_frontend_test/launch_frontend_tests_in_clockwork_dev.sh"]

Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ python3 -m flask run --host="0.0.0.0" &
echo Wait 5 seconds to let server fully start
sleep 5

echo Check that server is onlinw
echo Check that server is online
python -c "import urllib.request; print(urllib.request.urlopen('http://127.0.0.1:5000/').getcode())"

echo Run tests
Expand Down
19 changes: 19 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,25 @@ services:
clockwork_tools_test_EMAIL: ${clockwork_tools_test_EMAIL}
clockwork_tools_test_CLOCKWORK_API_KEY: ${clockwork_tools_test_CLOCKWORK_API_KEY}

clockwork_frontend_test:
image: clockwork_frontend_test
depends_on:
- mongodb
- clockwork_web-dev
user: "${CLOCKWORK_UID}:${CLOCKWORK_GID}"
working_dir: /clockwork
volumes:
- ./clockwork_web:/clockwork/clockwork_web
- ./clockwork_frontend_test:/clockwork/clockwork_frontend_test
- ./scripts:/clockwork/scripts
- ./slurm_state:/clockwork/slurm_state
- ./test_common:/clockwork/test_common
- ./test_config.toml:/clockwork/test_config.toml
ports:
- ${EXTERNAL_FLASK_RUN_PORT}:${FLASK_RUN_PORT}
environment:
CLOCKWORK_CONFIG: /clockwork/test_config.toml

slurm_state_test:
image: slurm_state_test
depends_on:
Expand Down
2 changes: 2 additions & 0 deletions test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ docker build -t clockwork_web_test clockwork_web_test
docker build -t clockwork_tools_test -f clockwork_tools_test/Dockerfile .
docker build -t slurm_state_test -f slurm_state_test/Dockerfile .
docker build -t scripts_test -f scripts_test/Dockerfile .
docker build -t clockwork_frontend_test -f clockwork_frontend_test/Dockerfile .

. ./env.sh

Expand All @@ -16,3 +17,4 @@ docker-compose run clockwork_web_test
docker-compose run clockwork_tools_test
docker-compose run slurm_state_test
docker-compose run scripts_test
docker-compose run clockwork_frontend_test