From de835fd2205a2e8d8c2b15eeef6132ac788f9794 Mon Sep 17 00:00:00 2001 From: Amrit Purshotam Date: Thu, 17 Mar 2022 20:26:55 +0100 Subject: [PATCH 1/5] Add attribute to use only LF line endings --- .gitattributes | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 .gitattributes diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 000000000..658066882 --- /dev/null +++ b/.gitattributes @@ -0,0 +1,3 @@ +text=auto eol=lf + +*.{png,pdf,ico,enc,jpg,jpeg,gif,webp,woff,woff2} binary \ No newline at end of file From e08e1bc6b8a8b91038921d81843fc3bbf63aa35d Mon Sep 17 00:00:00 2001 From: Amrit Purshotam Date: Thu, 17 Mar 2022 20:33:50 +0100 Subject: [PATCH 2/5] Tell editor to use LF line endings --- .editorconfig | 4 ++++ .gitignore | 4 ---- .vscode/extensions.json | 5 +++++ 3 files changed, 9 insertions(+), 4 deletions(-) create mode 100644 .editorconfig create mode 100644 .vscode/extensions.json diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 000000000..006bc2fc7 --- /dev/null +++ b/.editorconfig @@ -0,0 +1,4 @@ +root = true + +[*] +end_of_line = lf diff --git a/.gitignore b/.gitignore index a7c533b1a..306aeef57 100644 --- a/.gitignore +++ b/.gitignore @@ -103,10 +103,6 @@ venv.bak/ .spyderproject .spyproject -# VSCode project settings -.vscode - - # IntelliJ/Pycharm/Webstorm/etc. project settings .iml diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 000000000..189adec04 --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,5 @@ +{ + "recommendations": [ + "editorconfig.editorconfig" + ] +} \ No newline at end of file From 1c0ab5a43dee16639e1873be600e5422a17a5648 Mon Sep 17 00:00:00 2001 From: Amrit Purshotam Date: Thu, 17 Mar 2022 21:09:14 +0100 Subject: [PATCH 3/5] Add black and isort formatting settings --- .circleci/config.yml | 6 ++++++ .vscode/extensions.json | 3 ++- .vscode/settings.json | 10 ++++++++++ api/Dockerfile | 7 ++++--- api/requirements-dev.txt | 2 ++ api/setup.cfg | 2 ++ 6 files changed, 26 insertions(+), 4 deletions(-) create mode 100644 .vscode/settings.json create mode 100644 api/requirements-dev.txt create mode 100644 api/setup.cfg diff --git a/.circleci/config.yml b/.circleci/config.yml index 15dd8a01b..5f216c067 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,12 @@ jobs: gcloud --quiet config set compute/zone ${GOOGLE_COMPUTE_ZONE} openssl aes256 -md md5 -d -in docker-compose.circleci.yaml.enc -out docker-compose.yml -pass pass:$CONFIG_PASSWORD docker-compose up -d + - run: + name: Format with black + command: docker-compose run web black --check api + - run: + name: Format with isort + command: docker-compose run web isort --check --settings-path=api/setup.cfg api - run: name: Run migrations command: | diff --git a/.vscode/extensions.json b/.vscode/extensions.json index 189adec04..d2d1709fb 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,5 +1,6 @@ { "recommendations": [ - "editorconfig.editorconfig" + "editorconfig.editorconfig", + "ms-python.python" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..a99b1761d --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,10 @@ +{ + "python.formatting.provider": "black", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + "python.sortImports.args": [ + "--settings-path=${workspaceFolder}/api/setup.cfg" + ] +} \ No newline at end of file diff --git a/api/Dockerfile b/api/Dockerfile index 29470489b..efb56830a 100644 --- a/api/Dockerfile +++ b/api/Dockerfile @@ -9,14 +9,15 @@ ENV PATH /env/bin:$PATH RUN apt-get update -qq \ && apt-get install -y software-properties-common \ - && apt-get install -y libreoffice + && apt-get install -y libreoffice \ + && python3 -m pip install --upgrade pip # Upgrade pip RUN python -m pip install --upgrade pip # Add the application source code. -ADD requirements.txt /code/requirements.txt -RUN pip3 install -r /code/requirements.txt +COPY requirements.txt requirements-dev.txt /code/ +RUN pip3 install -r /code/requirements.txt -r /code/requirements-dev.txt ADD . /code/ WORKDIR /code diff --git a/api/requirements-dev.txt b/api/requirements-dev.txt new file mode 100644 index 000000000..1f1de0656 --- /dev/null +++ b/api/requirements-dev.txt @@ -0,0 +1,2 @@ +black==22.1.0 +isort==5.10.1 \ No newline at end of file diff --git a/api/setup.cfg b/api/setup.cfg new file mode 100644 index 000000000..841770380 --- /dev/null +++ b/api/setup.cfg @@ -0,0 +1,2 @@ +[isort] +profile = black \ No newline at end of file From 352089b28a72b9a2a722483b56052fd141b2b089 Mon Sep 17 00:00:00 2001 From: Amrit Purshotam Date: Thu, 17 Mar 2022 21:38:18 +0100 Subject: [PATCH 4/5] Add prettier formatting settings for webapp --- .circleci/config.yml | 5 ++++- .vscode/extensions.json | 3 ++- .vscode/settings.json | 20 +++++++++++++++++++- webapp/.prettierignore | 26 ++++++++++++++++++++++++++ webapp/.prettierrc.json | 3 +++ webapp/package.json | 4 +++- 6 files changed, 57 insertions(+), 4 deletions(-) create mode 100644 webapp/.prettierignore create mode 100644 webapp/.prettierrc.json diff --git a/.circleci/config.yml b/.circleci/config.yml index 5f216c067..cb8d50c4b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -20,6 +20,9 @@ jobs: - run: name: Format with isort command: docker-compose run web isort --check --settings-path=api/setup.cfg api + - run: + name: Format with prettier + command: docker-compose run webapp yarn prettier-ci - run: name: Run migrations command: | @@ -28,7 +31,7 @@ jobs: docker-compose run web python3 api/run.py db upgrade --directory api/migrations - run: name: Run unit tests - command: docker-compose run web nosetests -v + command: docker-compose run web nosetests -v integration-tests: machine: diff --git a/.vscode/extensions.json b/.vscode/extensions.json index d2d1709fb..3ba0ec6ad 100644 --- a/.vscode/extensions.json +++ b/.vscode/extensions.json @@ -1,6 +1,7 @@ { "recommendations": [ "editorconfig.editorconfig", - "ms-python.python" + "ms-python.python", + "esbenp.prettier-vscode" ] } \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index a99b1761d..29c46224f 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -6,5 +6,23 @@ }, "python.sortImports.args": [ "--settings-path=${workspaceFolder}/api/setup.cfg" - ] + ], + "[javascript]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + }, + "[json]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + }, + "[css]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + }, + "[html]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + }, + "[jsx-tags]": { + "editor.defaultFormatter": "esbenp.prettier-vscode", + }, + "prettier.configPath": "./webapp/.prettierrc.json", + "prettier.ignorePath": "./webapp/.prettierignore", + "prettier.prettierPath": "./webapp/node_modules/prettier" } \ No newline at end of file diff --git a/webapp/.prettierignore b/webapp/.prettierignore new file mode 100644 index 000000000..ab09e01cf --- /dev/null +++ b/webapp/.prettierignore @@ -0,0 +1,26 @@ +# See https://prettier.io/docs/en/ignore.html for more about ignoring files. + +# dependencies +/node_modules +/.pnp +.pnp.js + +# testing +/coverage + +# production +/build + +# misc +.DS_Store +.env.local +.env.development.local +.env.test.local +.env.production.local + +npm-debug.log* +yarn-debug.log* +yarn-error.log* + +# Ignore md files +*.md \ No newline at end of file diff --git a/webapp/.prettierrc.json b/webapp/.prettierrc.json new file mode 100644 index 000000000..217acaf3b --- /dev/null +++ b/webapp/.prettierrc.json @@ -0,0 +1,3 @@ +{ + "endOfLine": "lf" +} \ No newline at end of file diff --git a/webapp/package.json b/webapp/package.json index 35640871b..8fad4baf0 100644 --- a/webapp/package.json +++ b/webapp/package.json @@ -50,7 +50,8 @@ "test": "react-scripts test", "eject": "react-scripts eject", "test-ci": "react-scripts test --env=jsdom --ci --coverage -u", - "cypress": "cypress open" + "cypress": "cypress open", + "prettier-ci": "prettier --check ." }, "eslintConfig": { "extends": "react-app" @@ -64,6 +65,7 @@ "devDependencies": { "@babel/runtime": "^7.12.5", "cypress": "^4.0.2", + "prettier": "2.6.0", "react-test-renderer": "^16.14.0" } } From 15bc335a53a68c1d4bbb2cdfd6bec0b2a5204372 Mon Sep 17 00:00:00 2001 From: Amrit Purshotam Date: Thu, 17 Mar 2022 21:56:44 +0100 Subject: [PATCH 5/5] Update lock file --- webapp/yarn.lock | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/webapp/yarn.lock b/webapp/yarn.lock index a96bb66dd..73db06e0f 100644 --- a/webapp/yarn.lock +++ b/webapp/yarn.lock @@ -9162,6 +9162,11 @@ preserve@^0.2.0: resolved "https://registry.yarnpkg.com/preserve/-/preserve-0.2.0.tgz#815ed1f6ebc65926f865b310c0713bcb3315ce4b" integrity sha1-gV7R9uvGWSb4ZbMQwHE7yzMVzks= +prettier@2.6.0: + version "2.6.0" + resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.6.0.tgz#12f8f504c4d8ddb76475f441337542fa799207d4" + integrity sha512-m2FgJibYrBGGgQXNzfd0PuDGShJgRavjUoRCw1mZERIWVSXF0iLzLm+aOqTAbLnC3n6JzUhAA8uZnFVghHJ86A== + prettier@^1.14.2: version "1.16.4" resolved "https://registry.yarnpkg.com/prettier/-/prettier-1.16.4.tgz#73e37e73e018ad2db9c76742e2647e21790c9717"