diff --git a/.circleci/config.yml b/.circleci/config.yml index 3a3e619c3..7e2471eec 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -1,6 +1,6 @@ version: 2.1 jobs: - build: + build_python: docker: - image: circleci/python:3.7.3 steps: @@ -14,7 +14,18 @@ jobs: . venv/bin/activate pip install --requirement requirements.txt pip install --requirement dev_requirements.txt - ./run_build + ./dev-scripts/build-python + format_frontend: + docker: + - image: circleci/node:13.2.0-stretch + steps: + - checkout + - run: + name: Install prettier globally + command: npm install prettier@2.0.5 + - run: + name: Check frontend formatting + command: ./dev-scripts/check-frontend-format e2e: machine: # A Debian image would be better, as it matches Raspberry Pi OS more @@ -33,5 +44,6 @@ jobs: workflows: test: jobs: - - build + - build_python + - format_frontend - e2e diff --git a/.gitignore b/.gitignore index a67663c9d..53f0894c4 100644 --- a/.gitignore +++ b/.gitignore @@ -63,6 +63,10 @@ venv/ *~ *.sw? +# Node +node_modules +package-lock.json + # Mac OS *.DS_Store *.xcworkspace diff --git a/.prettierignore b/.prettierignore new file mode 100644 index 000000000..fe37977b4 --- /dev/null +++ b/.prettierignore @@ -0,0 +1 @@ +app/static/third-party diff --git a/README.md b/README.md index 8f90cc220..886559c93 100644 --- a/README.md +++ b/README.md @@ -93,20 +93,21 @@ After running these commands, you should be able to access TinyPilot through a w ## Developer installation -If you're interesting in contributing to TinyPilot, follow these instructions to install the required developer packages in your development environment: +If you're interested in contributing to TinyPilot, follow these instructions to install the required developer packages in your development environment: ```bash python3.7 -m venv venv . venv/bin/activate pip install --requirement requirements.txt pip install --requirement dev_requirements.txt -hooks/enable_hooks + +npm install prettier@2.0.5 ``` To run TinyPilot's build scripts, run: ```bash -./run_build +./dev-scripts/build ``` To enable TinyPilot's Git hooks, run: diff --git a/dev-scripts/build b/dev-scripts/build new file mode 100755 index 000000000..556ad106c --- /dev/null +++ b/dev-scripts/build @@ -0,0 +1,13 @@ +#!/bin/bash + +# Exit build script on first failure. +set -e + +# Echo commands to stdout. +set -x + +# Exit on unset variable. +set -u + +./dev-scripts/build-python +./dev-scripts/check-frontend-format \ No newline at end of file diff --git a/run_build b/dev-scripts/build-python similarity index 100% rename from run_build rename to dev-scripts/build-python diff --git a/dev-scripts/check-frontend-format b/dev-scripts/check-frontend-format new file mode 100755 index 000000000..79cba3846 --- /dev/null +++ b/dev-scripts/check-frontend-format @@ -0,0 +1,12 @@ +#!/bin/bash + +# Exit build script on first failure. +set -e + +# Echo commands to stdout. +set -x + +# Exit on unset variable. +set -u + +./node_modules/.bin/prettier --check app/static \ No newline at end of file diff --git a/hooks/pre-commit b/hooks/pre-commit index 0b81e79b3..246287cd7 100755 --- a/hooks/pre-commit +++ b/hooks/pre-commit @@ -1,5 +1,12 @@ #!/bin/bash -set -xue +# Exit build script on first failure. +set -e -./run_build \ No newline at end of file +# Echo commands to stdout. +set -x + +# Exit on unset variable. +set -u + +./dev-scripts/build \ No newline at end of file