diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 68d8c2036732822feb0a083fc8b3f040e81ff128..10c9bb5631d418aedb4c000084dfafef9d6fc5a9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -1,9 +1,8 @@ # In CI we use the latest docker images. stages: - - check + - check_and_lint - test - - lint - svg-gen-docu # required to be done before documentation and in separate stages - documentation @@ -15,7 +14,7 @@ stages: check_back: <<: *only-default - stage: check + stage: check_and_lint image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.2.1 before_script: - sh ./backend/init_logs.sh @@ -35,7 +34,7 @@ check_back: check_front: <<: *only-default - stage: check + stage: check_and_lint image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.1.0 before_script: - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/ @@ -48,6 +47,29 @@ check_front: tags: - docker +lint_backend: + <<: *only-default + stage: check_and_lint + image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.2.1 + script: + - cd backend + - black --check . + - flake8 + tags: + - docker + +lint_frontend_and_documentation: + <<: *only-default + stage: check_and_lint + image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.1.0 + before_script: + - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/ + script: + - yarn lint + - yarn lint-doc + tags: + - docker + test_back: <<: *only-default stage: test @@ -86,26 +108,6 @@ test_frontend: tags: - docker -flake8: - <<: *only-default - stage: lint - image: registry.gitlab.utc.fr/rex-dri/rex-dri/backend:v0.2.1 - script: - - cd backend && flake8 - tags: - - docker - -eslint: - <<: *only-default - stage: lint - image: registry.gitlab.utc.fr/rex-dri/rex-dri/frontend:v2.1.0 - before_script: - - cd frontend && mkdir -p node_modules && mv -f /usr/src/deps/node_modules/* /usr/src/deps/node_modules/.bin ./node_modules/ - script: - - yarn lint - tags: - - docker - generate_UML_svg: <<: *only-default stage: svg-gen-docu diff --git a/CHANGELOG.md b/CHANGELOG.md index affba45590254c16835ed983f4b72c44c9208b43..d3693969b9a5995f1996968316721f32d4e0d5f1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## Next +- [feat] ci: run black and prettier in ci + ###### _TBD_ - [chore] front: updated wording and information regarding previous exchanges and offers diff --git a/Makefile b/Makefile index 73b679ce5c0c99d101a872c9af08dea1897f88e8..04810b1eb3d6d1435fad60b5795362cde22d73ba 100644 --- a/Makefile +++ b/Makefile @@ -27,6 +27,12 @@ docker-pull: reformat_backend: docker-compose exec backend sh -c "cd backend && black ." +reformat_frontend: + docker-compose exec frontend sh -c "cd frontend && yarn reformat" + +reformat_documentation: + docker-compose exec frontend sh -c "cd frontend && yarn reformat-doc" + test_backend: docker-compose exec backend sh -c "cd backend && pytest --cov --cov-config .coveragerc --cov-report term base_app/ backend_app/ stats_app/" @@ -37,11 +43,14 @@ check_backend: docker-compose exec backend sh -c "cd backend && ./manage.py check" lint_backend: - docker-compose exec backend sh -c "cd backend && flake8" + docker-compose exec backend sh -c "cd backend && black --check . && flake8" lint_frontend: docker-compose exec frontend sh -c "cd frontend && yarn lint" +lint_documentation: + docker-compose exec frontend sh -c "cd frontend && yarn lint-doc" + build_frontend: docker-compose exec frontend sh -c "cd frontend && yarn build" diff --git a/backend/base_app/views.py b/backend/base_app/views.py index 50e6642c4060a53bf385a21586e9838b49f86d70..bad53215fa4c3ff5e9b8c8afe6b5c482feec8bfe 100644 --- a/backend/base_app/views.py +++ b/backend/base_app/views.py @@ -60,14 +60,10 @@ def stats(request): if dataset == "daily_connections": daily_connections = DailyConnections.objects.filter( - date__gte=now_minus_365_days, - date__lt=now, + date__gte=now_minus_365_days, date__lt=now ) raw_data = [ - { - "date": dc.date.strftime("%Y-%m-%d"), - "nb_connections": dc.nb_connections - } + {"date": dc.date.strftime("%Y-%m-%d"), "nb_connections": dc.nb_connections} for dc in daily_connections ] @@ -75,8 +71,7 @@ def stats(request): elif dataset == "daily_exchange_contributions": daily_contributions = DailyExchangeContributionsInfo.objects.filter( - date__gte=now_minus_365_days, - date__lt=now, + date__gte=now_minus_365_days, date__lt=now ).prefetch_related("university") raw_data = [ diff --git a/documentation/ProdRelated/maintenance/update_major_minor.md b/documentation/ProdRelated/maintenance/update_major_minor.md index 1f0040e078dd9b6e931996e513cbacb17dcc5a20..c5a4f1dbbf89974e1455a0571c4243da3a403160 100644 --- a/documentation/ProdRelated/maintenance/update_major_minor.md +++ b/documentation/ProdRelated/maintenance/update_major_minor.md @@ -6,12 +6,12 @@ In `frontend/src/utils/majorMinorMappings.js`, each change has to be added as a ```js export const majorMapping = { - oldMajorName: "newMajorName" + oldMajorName: "newMajorName", }; export const minorMapping = { majorName: { - oldMinorName: "newMinorName" - } + oldMinorName: "newMinorName", + }, }; ``` diff --git a/frontend/.prettierignore b/frontend/.prettierignore new file mode 100644 index 0000000000000000000000000000000000000000..b7a13d98004a152f5970e9d21877e7751bf2a386 --- /dev/null +++ b/frontend/.prettierignore @@ -0,0 +1 @@ +/webpack-stats.json diff --git a/frontend/package.json b/frontend/package.json index 7d8494e09463220a50b4c5645a5debc759e65fa0..ce365f3cc67727356df17ccf0344c275fc740e50 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -4,8 +4,11 @@ "description": "[![build](/../badges/master/build.svg)](https://gitlab.utc.fr/chehabfl/outgoing_rex/pipelines) [![coverage](/../badges/master/coverage.svg)](https://chehabfl.gitlab.utc.fr/outgoing_rex/) [![License](https://img.shields.io/badge/License-BSD%202--Clause-green.svg)](https://opensource.org/licenses/BSD-2-Clause)", "main": "manage.py", "scripts": { - "lint": "eslint src --ext js --ext jsx", + "lint": "prettier --check . && eslint src --ext js --ext jsx", + "reformat": "prettier --write .", "lint-fix": "eslint src --ext js --ext jsx --fix", + "lint-doc": "prettier --check ../documentation", + "reformat-doc": "prettier --write ../documentation", "dev": "node server.js", "build": "webpack --config webpack.config.build.js", "test": "jest",