Skip to content
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

Add Playwright to test UI and features #552

Merged
merged 9 commits into from
May 26, 2024
Merged
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
9 changes: 4 additions & 5 deletions .envs/.example
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
# Use this file to create a .env with filled variables
# Django Variables
DJANGO_DEBUG=True
DEV_DB=False
DEBUG_TOOLBAR=True
DJANGO_SECRET_KEY=change_me
USE_MINIO=True
Expand Down Expand Up @@ -30,12 +29,12 @@ MINIO_USER_SECRET_KEY=minio-secret-key
## Postgres variables
POSTGRES_HOST=postgres
POSTGRES_PORT=5432
POSTGRES_DB=goldpenny
POSTGRES_USER=goldpenny
POSTGRES_PASSWORD=goldpenny123
POSTGRES_DB=jandig
POSTGRES_USER=jandig
POSTGRES_PASSWORD=secret

# Email server variables
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
JANDIG_EMAIL=local_jandig@memelab.com.br
JANDIG_EMAIL=local_jandig@jandig.com
JANDIG_EMAIL_PASSWORD=local_password
24 changes: 12 additions & 12 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,9 @@ RUN apt-get update && \
curl \
wget


COPY ./pyproject.toml /pyproject.toml
COPY ./poetry.lock /poetry.lock



ENV PATH="$PATH:/root/.local/bin" \
POETRY_NO_INTERACTION=1 \
POETRY_VIRTUALENVS_CREATE=false \
Expand All @@ -26,22 +23,25 @@ ENV PATH="$PATH:/root/.local/bin" \
RUN curl -sSL https://install.python-poetry.org | python3 - \
&& poetry --version

RUN pip install --upgrade pip
RUN poetry install

RUN dpkgArch="$(dpkg --print-architecture | awk -F- '{ print $NF }')" \
&& wget "https://github.com/krallin/tini/releases/download/${TINI_VERSION}/tini-${dpkgArch}" -O /usr/local/bin/tini \
&& chmod +x /usr/local/bin/tini && tini --version

RUN mkdir -p /src
WORKDIR /src
COPY ./src/ /src/
COPY ./docs/ /src/docs/
COPY ./locale/ /src/locale/
COPY ./tasks.py /src/tasks.py
COPY ./run.sh /src/run.sh
COPY ./etc/ /src/etc/

RUN pip install --upgrade pip
RUN mkdir -p /jandig/src /jandig/locale /jandig/docs /jandig/static /jandig/build

WORKDIR /jandig

COPY ./src/ /jandig/src/
COPY ./docs/ /jandig/docs/
COPY ./locale/ /jandig/locale/
COPY ./tasks.py /jandig/tasks.py
COPY ./run.sh /jandig/run.sh
COPY ./etc/ /jandig/etc/


RUN find . | grep -E "(__pycache__|\.pyc|\.pyo$)" | xargs rm -rf

Expand Down
20 changes: 18 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
RUNNING_CONTAINER := $(shell docker compose ps --services --filter "status=running" | grep django )

test:
poetry run pytest src
@if [[ -n "${RUNNING_CONTAINER}" ]]; then \
docker compose exec django poetry run pytest src/core src/users; \
else \
docker compose run --rm django poetry run pytest src/core src/users;\
fi

test-ui:
docker compose up -d
poetry run pytest src/tests

lint:
poetry run black --line-length=200 src
Expand All @@ -11,4 +21,10 @@ migrations:
poetry run python src/manage.py makemigrations

migrate:
poetry run python src/manage.py migrate
poetry run python src/manage.py migrate

gen:
poetry run playwright codegen -b chromium --target python-pytest localhost:8000

translate_es:
poetry run inv i18n -l es_ES
40 changes: 24 additions & 16 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: '3.5'
version: '3.8'

services:
django:
Expand All @@ -8,37 +8,45 @@ services:
ports:
- 8000:8000
volumes:
- ./src/:/src/
- ./docs/:/src/docs/
- ./etc/:/src/etc/
- ./locale/:/src/locale/
- ./run.sh:/src/run.sh
- ./tasks.py:/src/tasks.py
- ./src/:/jandig/src/
- ./docs/:/jandig/docs/
- ./etc/:/jandig/etc/
- ./locale/:/jandig/locale/
- ./run.sh:/jandig/run.sh
- ./tasks.py:/jandig/tasks.py
env_file:
- .envs/.example
depends_on:
- postgres
- storage
- createbuckets
command: ./run.sh
storage:
condition: service_started
createbuckets:
condition: service_started
postgres:
condition: service_healthy
command: /jandig/run.sh

postgres:
image: postgres:15.2
image: postgres:15.4
env_file:
- .envs/.env
- .envs/.example
command: postgres -c max_connections=10000
ports:
- "5432:5432"
volumes:
- postgres_data:/var/lib/postgresql/data

healthcheck:
test: ["CMD-SHELL", "pg_isready", "-d", "jandig"]
interval: 3s
timeout: 60s
retries: 20

storage:
image: minio/minio:latest
ports:
- 9000:9000
- 9001:9001
volumes:
- storage:/storage
- media_data:/storage
env_file:
- .envs/.env
command: server /storage --console-address ":9001"
Expand All @@ -62,4 +70,4 @@ services:

volumes:
postgres_data:
storage:
media_data:
Loading
Loading