forked from commaai/openpilot
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revert "pre-commit: bring back some checks (commaai#33196)" (commaai#…
- Loading branch information
1 parent
30467b4
commit 3af7747
Showing
4 changed files
with
14 additions
and
133 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,67 +1,11 @@ | ||
#!/bin/bash | ||
set -e | ||
|
||
RED='\033[0;31m' | ||
GREEN='\033[0;32m' | ||
NC='\033[0m' | ||
|
||
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" | ||
cd $DIR/../ | ||
|
||
FAILED=0 | ||
|
||
IGNORED_FILES="uv\.lock|docs\/CARS.md" | ||
|
||
function run() { | ||
echo -en "$1" | ||
|
||
for ((i=0; i<$((50 - ${#1})); i++)); do | ||
echo -n "." | ||
done | ||
|
||
shift 1; | ||
CMD="$@" | ||
|
||
set +e | ||
log="$((eval "$CMD" ) 2>&1)" | ||
if [[ $? -eq 0 ]]; then | ||
echo -e "[${GREEN}✔${NC}]" | ||
else | ||
echo -e "[${RED}✗${NC}]" | ||
echo "$log" | ||
FAILED=1 | ||
fi | ||
set -e | ||
} | ||
function run_tests() { | ||
ALL_FILES=$(echo "$@" | sed -E "s/$IGNORED_FILES//g") | ||
PYTHON_FILES=$(echo "$ALL_FILES" | grep --color=never '.py$' || true) | ||
if [[ -n "$PYTHON_FILES" ]]; then | ||
run "ruff" ruff check $PYTHON_FILES --quiet | ||
run "mypy" mypy $PYTHON_FILES | ||
run "Import check" lint-imports | ||
fi | ||
if [[ -n "$ALL_FILES" ]]; then | ||
run "Codespell" codespell $ALL_FILES | ||
run "Large files check" python3 -m pre_commit_hooks.check_added_large_files --enforce-all $ALL_FILES --maxkb=120 | ||
run "Shebang check" python3 -m pre_commit_hooks.check_shebang_scripts_are_executable $ALL_FILES | ||
fi | ||
return $FAILED | ||
} | ||
# TODO: bring back rest of pre-commit checks: | ||
# https://github.com/commaai/openpilot/blob/4b11c9e914707df9def598616995be2a5d355a6a/.pre-commit-config.yaml#L2 | ||
|
||
if [[ -n $@ ]]; then | ||
VALID_FILES="" | ||
for f in $@; do | ||
if [[ -f "$f" ]]; then | ||
VALID_FILES+="$f"$'\n' | ||
fi | ||
done | ||
run_tests "$VALID_FILES" | ||
else | ||
run_tests "$(git diff --name-only --cached --diff-filter=AM $(git merge-base HEAD master))" | ||
fi | ||
ruff check . | ||
lint-imports |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.