diff --git a/.github/workflows/.tests-python.yml b/.github/workflows/.tests-python.yml index 29785733..136c03f1 100644 --- a/.github/workflows/.tests-python.yml +++ b/.github/workflows/.tests-python.yml @@ -95,4 +95,4 @@ jobs: export TEST_APP_URL=http://$(hostname --ip-address):5000 sleep 5 nohup flask worker --processes=1 >> nohup.out 2>&1 & - pytest e2e --driver Remote --capability browserName firefox --host selenium --port 4444 + pytest e2e --driver Remote --capability browserName firefox --selenium-host selenium --selenium-port 4444 diff --git a/Makefile b/Makefile index 680a6351..004ce6a4 100644 --- a/Makefile +++ b/Makefile @@ -50,11 +50,18 @@ docker-build-all: docker-build docker-build-client docker-build-client: docker-compose -f docker-compose-dev.yml build fittrackee_client -docker-init: docker-init-db docker-restart docker-run-workers +docker-init: docker-run 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..4eed8d1c 100644 --- a/docker-compose-dev.yml +++ b/docker-compose-dev.yml @@ -12,6 +12,8 @@ services: - POSTGRES_PASSWORD=postgres volumes: - ./data/db:/var/lib/postgresql/data + networks: + - fittrackee-net fittrackee: container_name: fittrackee @@ -24,14 +26,12 @@ services: - fittrackee-db - redis - mail - links: - - fittrackee-db - - redis - - mail volumes: - .:/usr/src/app - ./data/workouts:/usr/src/app/workouts - ./data/uploads:/usr/src/app/uploads + networks: + - fittrackee-net fittrackee_client: container_name: fittrackee_client @@ -57,6 +57,8 @@ services: hostname: redis ports: - "6379:6379" + networks: + - fittrackee-net mail: container_name: fittrackee-mailhog @@ -64,3 +66,14 @@ services: ports: - "1025:1025" - "8025:8025" + networks: + - fittrackee-net + + selenium: + image: selenium/standalone-firefox:latest + hostname: selenium + privileged: true + shm_size: 2g + +networks: + fittrackee-net: \ 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..b2425d53 --- /dev/null +++ b/docker/lint-python.sh @@ -0,0 +1,8 @@ +#!/bin/bash +set -e +cd /usr/src/app + +source .env + +mypy fittrackee +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 diff --git a/docs/_sources/installation.rst.txt b/docs/_sources/installation.rst.txt index 7cc2ae1a..1e88243f 100644 --- a/docs/_sources/installation.rst.txt +++ b/docs/_sources/installation.rst.txt @@ -710,16 +710,22 @@ Installation For evaluation purposes, docker files are available, installing **FitTrackee** from **sources**. -- To install **FitTrackee** with database initialisation and run the application and dramatiq workers: +- To install **FitTrackee**: .. code-block:: bash $ git clone https://github.com/SamR1/FitTrackee.git $ cd FitTrackee $ cp .env.docker .env - $ make docker-build docker-run docker-init + $ make docker-build -Open http://localhost:5000 and register. +- To initialise database: + +.. code-block:: bash + + $ docker-init + +- Open http://localhost:5000 and register. Open http://localhost:8025 to access `MailHog interface `_ (email testing tool) @@ -772,4 +778,13 @@ Development Open http://localhost:3000 .. note:: - Some environment variables need to be updated like `UI_URL` \ No newline at end of file + Some environment variables need to be updated like `UI_URL` + +- to run lint or tests: + +.. code-block:: bash + + $ make lint-client # run lint on javascript files + $ make test-client # run unit tests on Client + $ make lint-python # run type check and lint on python files + $ make test-python # run unit tests on API \ No newline at end of file diff --git a/docs/installation.html b/docs/installation.html index cdf45628..6e955415 100644 --- a/docs/installation.html +++ b/docs/installation.html @@ -996,15 +996,23 @@ server {

For evaluation purposes, docker files are available, installing FitTrackee from sources.

$ git clone https://github.com/SamR1/FitTrackee.git
 $ cd FitTrackee
 $ cp .env.docker .env
-$ make docker-build docker-run docker-init
+$ make docker-build
 
-

Open http://localhost:5000 and register.

+ +
$ docker-init
+
+
+

Open http://localhost:8025 to access MailHog interface (email testing tool)