diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 4ee18b0..f44f4b2 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -12,7 +12,7 @@ test: stage: test image: docker/compose:latest variables: - DOCKER_TLS_CERTDIR: "" + DOCKER_TLS_CERTDIR: '' services: - docker:dind script: @@ -22,7 +22,7 @@ test: - docker exec -t v3-territory-api sh -c "npm run test:integration:ci" coverage: /All files[^|]*\|[^|]*\s+([\d\.]+)/ rules: - - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' + - if: '$CI_MERGE_REQUEST_TARGET_BRANCH_NAME == $CI_DEFAULT_BRANCH || $CI_COMMIT_MESSAGE =~ /--check/ || $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH' when: always ############### @@ -33,7 +33,7 @@ build: stage: build image: docker:20.10.22 variables: - DOCKER_TLS_CERTDIR: "" + DOCKER_TLS_CERTDIR: '' services: - docker:dind before_script: diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 0000000..192c132 --- /dev/null +++ b/.prettierignore @@ -0,0 +1,6 @@ +node_modules +*.log* +.env +dist +coverage +.prettierrc.json diff --git a/.prettierrc b/.prettierrc.json similarity index 100% rename from .prettierrc rename to .prettierrc.json diff --git a/README.md b/README.md index 440fb8c..25afc5a 100644 --- a/README.md +++ b/README.md @@ -56,21 +56,21 @@ The app exposes the following [gRPC](https://grpc.io/) services : "lat": 46.143376 } ``` + - **FindForPoints** : find all territories that include a list of given points (represented by their longitude and latitude) ```json { "points": [ { - "lon": 5.493345, + "lon": 5.493345, "lat": 46.143376 }, { - "lon": 6.493345, + "lon": 6.493345, "lat": 47.143376 } ] - } ``` @@ -134,7 +134,7 @@ As mentionned earlier, RabbitMQ messages are sent after these events : Various messages are also sent for logging purpose. -## Tests +## Tests / ESLint / Prettier Tests are run outside the container for ease of use (switching between different environments inside containers using prisma is complicated and error prone). The integration tests use a dedicated database (see _db-test_ section of _docker-compose.yml_). @@ -151,6 +151,12 @@ npm run test:integration # coverage npm run test:cov + +# ESLint +npm run lint + +# Prettier +npm run pretty ``` ## License diff --git a/ci/Dockerfile b/ci/Dockerfile index 4b2a20c..26b388a 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -25,5 +25,9 @@ RUN npm run build # Run unit tests RUN npm run test:unit:ci +# ESLint / Prettier +RUN npm run lint:check +RUN npm run pretty:check + # Start the server CMD [ "node", "dist/main.js" ] diff --git a/package.json b/package.json index 941c1bc..79e349a 100644 --- a/package.json +++ b/package.json @@ -14,6 +14,9 @@ "start:debug": "nest start --debug --watch", "start:prod": "node dist/main", "lint": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix", + "lint:check": "eslint \"{src,apps,libs,test}/**/*.ts\" --fix-dry-run --ignore-path .gitignore", + "pretty:check": "./node_modules/.bin/prettier --check .", + "pretty": "./node_modules/.bin/prettier --write .", "test": "npm run migrate:test && dotenv -e .env.test jest", "test:unit": "jest --testPathPattern 'tests/unit/' --verbose", "test:unit:ci": "jest --testPathPattern 'tests/unit/' --coverage",