Skip to content

Commit

Permalink
Tech - Ajoute quelques commandes au Makefile (#3552)
Browse files Browse the repository at this point in the history
## Linked issues

None

----

- [ ] Tests E2E (Cypress)
  • Loading branch information
ivangabriele authored Aug 19, 2024
2 parents b1f2322 + 47b57c5 commit d0763f1
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 16 deletions.
44 changes: 29 additions & 15 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,25 @@ docker-env:
################################################################################
# Local Development

install:
cd ./frontend && npm i
check-clean-archi:
cd backend/tools && ./check-clean-architecture.sh

run-front:
cd ./frontend && npm run dev
clean: docker-env
rm -Rf ./backend/target
docker compose down -v
docker compose --env-file ./infra/docker/.env -f ./infra/docker/docker-compose.monitorenv.dev.yml down -v
docker compose --env-file ./infra/docker/.env -f ./infra/docker/docker-compose.cypress.yml down -v
docker compose -f ./infra/docker/docker-compose.puppeteer.yml down -v

compile-back:
cd backend && ./gradlew assemble

init-local-sig:
./infra/local/postgis_insert_layers.sh && ./infra/init/geoserver_init_layers.sh

install-front:
cd ./frontend && npm i

run-back: run-stubbed-apis
docker compose up -d --quiet-pull --wait db keycloak
cd backend && ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=$(INFRA_FOLDER)'
Expand All @@ -31,6 +41,9 @@ run-back-with-monitorenv: run-monitorenv
docker compose up -d --quiet-pull --wait db
cd backend && MONITORENV_URL=http://localhost:9880 ./gradlew bootRun --args='--spring.profiles.active=local --spring.config.additional-location=$(INFRA_FOLDER)'

run-front:
cd ./frontend && npm run dev

run-monitorenv: docker-env
docker compose \
--project-directory ./infra/docker \
Expand All @@ -45,16 +58,6 @@ run-stubbed-apis:
stop-stubbed-apis:
docker stop cypress-geoserver-1

clean: docker-env
rm -Rf ./backend/target
docker compose down -v
docker compose --env-file ./infra/docker/.env -f ./infra/docker/docker-compose.monitorenv.dev.yml down -v
docker compose --env-file ./infra/docker/.env -f ./infra/docker/docker-compose.cypress.yml down -v
docker compose -f ./infra/docker/docker-compose.puppeteer.yml down -v

check-clean-archi:
cd backend/tools && ./check-clean-architecture.sh

update-test-data:
cd frontend && node ./scripts/generate_test_data_seeds.mjs

Expand All @@ -71,6 +74,7 @@ dev-restore-db:

################################################################################
# Database upgrade

check-database-extensions-versions:
docker exec -i monitorfish_database bash < infra/remote/database_upgrade/check_extensions_versions.sh

Expand Down Expand Up @@ -108,14 +112,24 @@ add_timescaledb_to_shared_preload_libraries:
debian:buster \
bash -c "echo \"shared_preload_libraries = 'timescaledb'\" >> /var/lib/postgresql/data/postgresql.conf";


################################################################################
# Testing

test: test-back
cd frontend && CI=true npm run test:unit -- --coverage

test-back: check-clean-archi
cd backend && ./gradlew clean test
@if [ -z "$(class)" ]; then \
echo "Running all Backend tests..."; \
cd backend && ./gradlew clean test; \
else \
echo "Running single Backend test class $(class)..."; \
cd backend && ./gradlew test --tests "$(class)"; \
fi

test-back-watch:
./backend/scripts/test-watch.sh

lint-back:
cd ./backend && ./gradlew ktlintFormat | grep -v \
Expand Down
26 changes: 26 additions & 0 deletions backend/scripts/test-watch.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/bin/bash

while true; do
echo "Listing Git dirty .kt files..."
GIT_CHANGED_KT_FILES=$(git status --porcelain | grep '\.kt$' | awk '{print $2}')
GIT_UNTRACKED_KT_FILES=$(git ls-files --others --exclude-standard | grep '\.kt$')
GIT_DIRTY_KT_FILES=$(echo -e "$GIT_CHANGED_KT_FILES\n$GIT_UNTRACKED_KT_FILES" | grep '\.kt$')

if [ ! -z "$GIT_DIRTY_KT_FILES" ]; then
echo "Found Git dirty .kt files: $GIT_DIRTY_KT_FILES"

TEST_COMMAND_ARGS=""
for FILE in $GIT_DIRTY_KT_FILES; do
# Extract test pathed class name
TEST_CLASS=$(echo $FILE | sed -e 's#backend/src/test/kotlin/##' -e 's#/#.#g' -e 's/.kt$//')
TEST_COMMAND_ARGS="$TEST_COMMAND_ARGS --tests $TEST_CLASS"
done
echo "Running tests for: $TEST_COMMAND_ARGS..."
(cd backend && ./gradlew test $TEST_COMMAND_ARGS)
else
echo "No Git dirty .kt file detected."
fi

echo "Watching for .kt file changes..."
inotifywait -e create -e modify -e move -e delete -r backend/src/main/kotlin backend/src/test/kotlin || echo "No files specified to watch!"
done
2 changes: 1 addition & 1 deletion datascience/docs/source/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ To install front end dependencies, execute:

.. code-block:: shell
make install
make install-front
Run
---
Expand Down

0 comments on commit d0763f1

Please sign in to comment.