diff --git a/.circleci/config.yml b/.circleci/config.yml index 15dd8a01b..cb8d50c4b 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -14,6 +14,15 @@ 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: Format with prettier + command: docker-compose run webapp yarn prettier-ci - run: name: Run migrations command: | @@ -22,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/.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/.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 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..3ba0ec6ad --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + "recommendations": [ + "editorconfig.editorconfig", + "ms-python.python", + "esbenp.prettier-vscode" + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 000000000..29c46224f --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,28 @@ +{ + "python.formatting.provider": "black", + "editor.formatOnSave": true, + "editor.codeActionsOnSave": { + "source.organizeImports": true + }, + "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/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 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" } } 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"