From 6dffecb9bb0bfb3411790bf8a8f4697438935544 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 20 Jul 2022 10:08:01 +0200 Subject: [PATCH] Docker - add commands for lint and tests --- Makefile | 23 +++++++++++++++++++++-- docker-compose-dev.yml | 6 ++++++ docker/init-database.sh | 2 +- docker/lint-python.sh | 7 +++++++ docker/run-workers.sh | 2 +- docker/set-admin.sh | 2 +- docker/shell.sh | 2 +- docker/test-e2e.sh | 8 ++++++++ docker/test-python.sh | 7 +++++++ 9 files changed, 53 insertions(+), 6 deletions(-) create mode 100755 docker/lint-python.sh create mode 100755 docker/test-e2e.sh create mode 100755 docker/test-python.sh diff --git a/Makefile b/Makefile index 680a6351..c6aac8ee 100644 --- a/Makefile +++ b/Makefile @@ -55,6 +55,13 @@ docker-init: docker-init-db docker-restart docker-run-workers docker-init-db: docker-compose -f docker-compose-dev.yml exec fittrackee docker/init-database.sh +docker-lint-client: + docker-compose -f docker-compose-dev.yml up -d fittrackee_client + docker-compose -f docker-compose-dev.yml exec fittrackee_client yarn lint + +docker-lint-python: docker-run + docker-compose -f docker-compose-dev.yml exec fittrackee docker/lint-python.sh + docker-logs: docker-compose -f docker-compose-dev.yml logs --follow @@ -85,6 +92,18 @@ docker-shell: docker-stop: docker-compose -f docker-compose-dev.yml stop +docker-test-client: + docker-compose -f docker-compose-dev.yml up -d fittrackee_client + docker-compose -f docker-compose-dev.yml exec fittrackee_client yarn test:unit + +# needs a running application +docker-test-e2e: docker-run + docker-compose -f docker-compose-dev.yml up -d selenium + docker-compose -f docker-compose-dev.yml exec fittrackee docker/test-e2e.sh $(PYTEST_ARGS) + +docker-test-python: docker-run + docker-compose -f docker-compose-dev.yml exec fittrackee docker/test-python.sh $(PYTEST_ARGS) + docker-up: docker-compose -f docker-compose-dev.yml up fittrackee @@ -184,11 +203,11 @@ set-admin: echo "Deprecated command, will be removed in a next version. Use 'user-set-admin' instead." $(FTCLI) users update $(USERNAME) --set-admin true +test-all: test-client test-python + test-e2e: $(PYTEST) e2e --driver firefox $(PYTEST_ARGS) -test-all: test-client test-python - test-e2e-client: E2E_ARGS=client $(PYTEST) e2e --driver firefox $(PYTEST_ARGS) diff --git a/docker-compose-dev.yml b/docker-compose-dev.yml index f1b5f3c8..440dcf3a 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -64,3 +64,9 @@ services: ports: - "1025:1025" - "8025:8025" + + selenium: + image: selenium/standalone-firefox:latest + hostname: selenium + privileged: true + shm_size: 2g \ No newline at end of file diff --git a/docker/init-database.sh b/docker/init-database.sh index a013b0df..f919e418 100755 --- a/docker/init-database.sh +++ b/docker/init-database.sh @@ -2,7 +2,7 @@ set -e cd /usr/src/app -source .env.docker +source .env ftcli db drop ftcli db upgrade \ No newline at end of file diff --git a/docker/lint-python.sh b/docker/lint-python.sh new file mode 100755 index 00000000..7643ba2b --- /dev/null +++ b/docker/lint-python.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e +cd /usr/src/app + +source .env + +pytest --flake8 --isort --black -m "flake8 or isort or black" fittrackee e2e --ignore=fittrackee/migrations \ No newline at end of file diff --git a/docker/run-workers.sh b/docker/run-workers.sh index c7937a1c..228d406b 100755 --- a/docker/run-workers.sh +++ b/docker/run-workers.sh @@ -2,6 +2,6 @@ set -e cd /usr/src/app -source .env.docker +source .env flask worker --processes=$WORKERS_PROCESSES >> dramatiq.log 2>&1 diff --git a/docker/set-admin.sh b/docker/set-admin.sh index f3d57f1b..84eeb7c0 100755 --- a/docker/set-admin.sh +++ b/docker/set-admin.sh @@ -2,6 +2,6 @@ set -e cd /usr/src/app -source .env.docker +source .env ftcli users update $1 --set-admin true diff --git a/docker/shell.sh b/docker/shell.sh index 241fa823..55fd7607 100755 --- a/docker/shell.sh +++ b/docker/shell.sh @@ -2,6 +2,6 @@ set -e cd /usr/src/app -source .env.docker +source .env /bin/bash \ No newline at end of file diff --git a/docker/test-e2e.sh b/docker/test-e2e.sh new file mode 100755 index 00000000..97e26e0c --- /dev/null +++ b/docker/test-e2e.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e +cd /usr/src/app + +source .env + +export TEST_APP_URL=http://$(hostname --ip-address):5000 +pytest e2e --driver Remote --capability browserName firefox --selenium-host selenium --selenium-port 4444 $* \ No newline at end of file diff --git a/docker/test-python.sh b/docker/test-python.sh new file mode 100755 index 00000000..8058b504 --- /dev/null +++ b/docker/test-python.sh @@ -0,0 +1,7 @@ +#!/bin/bash +set -e +cd /usr/src/app + +source .env + +pytest fittrackee $* \ No newline at end of file