mirror of
https://github.com/tiny-pilot/tinypilot.git
synced 2023-10-01 22:58:29 +03:00
Add checks for whitespace consistency (#405)
* Add checks for whitespace consistency * Fix name of check_whitespace job * Fix paths
This commit is contained in:
@@ -1,5 +1,16 @@
|
||||
version: 2.1
|
||||
jobs:
|
||||
check_whitespace:
|
||||
docker:
|
||||
- image: cimg/base:2020.01
|
||||
steps:
|
||||
- checkout
|
||||
- run:
|
||||
name: Check for trailing whitespace
|
||||
command: ./dev-scripts/check-trailing-whitespace
|
||||
- run:
|
||||
name: Check that all text files end in a trailing newline
|
||||
command: ./dev-scripts/check-trailing-newline
|
||||
build_python:
|
||||
docker:
|
||||
- image: circleci/python:3.7.3
|
||||
@@ -37,6 +48,7 @@ jobs:
|
||||
workflows:
|
||||
test:
|
||||
jobs:
|
||||
- check_whitespace
|
||||
- build_python
|
||||
- format_frontend
|
||||
- e2e
|
||||
|
||||
@@ -7,4 +7,4 @@ update_configs:
|
||||
- match:
|
||||
# We need to use a specific pylint version that's compatible with
|
||||
# DocStringChecker.
|
||||
dependency_name: "pylint"
|
||||
dependency_name: "pylint"
|
||||
|
||||
@@ -18,4 +18,4 @@ def index_get():
|
||||
def stream_get():
|
||||
if flask.current_app.debug:
|
||||
return flask.send_file('tests/data/test-remote-screen.jpg')
|
||||
return flask.abort(404)
|
||||
return flask.abort(404)
|
||||
|
||||
@@ -9,5 +9,7 @@ set -x
|
||||
# Exit on unset variable.
|
||||
set -u
|
||||
|
||||
./dev-scripts/check-trailing-whitespace
|
||||
./dev-scripts/check-trailing-newline
|
||||
./dev-scripts/build-python
|
||||
./dev-scripts/check-frontend-format
|
||||
./dev-scripts/check-frontend-format
|
||||
|
||||
@@ -9,4 +9,4 @@ set -x
|
||||
# Exit on unset variable.
|
||||
set -u
|
||||
|
||||
./node_modules/.bin/prettier --check app/static
|
||||
./node_modules/.bin/prettier --check app/static
|
||||
|
||||
33
dev-scripts/check-trailing-newline
Executable file
33
dev-scripts/check-trailing-newline
Executable file
@@ -0,0 +1,33 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Verify that all text files end in a trailing newline.
|
||||
|
||||
# Exit on first failing command.
|
||||
set -e
|
||||
# Exit on unset variable.
|
||||
set -u
|
||||
|
||||
FILES=$(find . \
|
||||
-type f \
|
||||
-not -path "./.git/*" \
|
||||
-not -path "./venv/*" \
|
||||
-not -path "./node_modules/*" \
|
||||
-not -path "*/third_party/*" \
|
||||
-not -path "*/third-party/*" \
|
||||
-not -path "*.svg" \
|
||||
-exec grep \
|
||||
--binary-files=without-match \
|
||||
--quiet \
|
||||
. {} \; -print)
|
||||
|
||||
SUCCESS=0
|
||||
|
||||
for F in ${FILES[*]}
|
||||
do
|
||||
if ! [[ -s "$F" && -z "$(tail -c 1 "$F")" ]]; then
|
||||
printf "File must end in a trailing newline: $F\n"
|
||||
SUCCESS=-1
|
||||
fi
|
||||
done
|
||||
|
||||
exit "$SUCCESS"
|
||||
21
dev-scripts/check-trailing-whitespace
Executable file
21
dev-scripts/check-trailing-whitespace
Executable file
@@ -0,0 +1,21 @@
|
||||
#!/bin/bash
|
||||
|
||||
# Check for trailing whitespace
|
||||
|
||||
# Echo commands to console.
|
||||
set -x
|
||||
# Exit on first failing command.
|
||||
set -e
|
||||
# Exit on unset variable.
|
||||
set -u
|
||||
|
||||
if egrep \
|
||||
"\s$" \
|
||||
--line-number \
|
||||
--binary-files=without-match \
|
||||
--dereference-recursive \
|
||||
--exclude-dir={.git,venv,node_modules} \
|
||||
./ ; then
|
||||
echo "ERROR: Found trailing whitespace";
|
||||
exit 1;
|
||||
fi
|
||||
@@ -17,4 +17,4 @@ then
|
||||
rm -rf .git/hooks
|
||||
fi
|
||||
|
||||
ln -s -f ../hooks .git/hooks
|
||||
ln -s -f ../hooks .git/hooks
|
||||
|
||||
@@ -9,4 +9,4 @@ set -x
|
||||
# Exit on unset variable.
|
||||
set -u
|
||||
|
||||
./dev-scripts/build
|
||||
./dev-scripts/build
|
||||
|
||||
Reference in New Issue
Block a user