Skip to content

Commit

Permalink
Revert "pre-commit: bring back some checks (commaai#33196)" (commaai#…
Browse files Browse the repository at this point in the history
…33216)

This reverts commit 30467b4.
  • Loading branch information
maxime-desroches authored Aug 7, 2024
1 parent 30467b4 commit 3af7747
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 133 deletions.
26 changes: 9 additions & 17 deletions .github/workflows/selfdrive_tests.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -61,20 +61,13 @@ jobs:
cd $STRIPPED_DIR
${{ env.RUN }} "release/check-dirty.sh && \
MAX_EXAMPLES=5 $PYTEST -m 'not slow' selfdrive/car"
- name: Getting modified files
timeout-minutes: 1
run: |
cd $GITHUB_WORKSPACE
git fetch --unshallow --recurse-submodules=no origin master:master
ALL_FILES=$(git diff --name-only --cached --diff-filter=AM $(git merge-base HEAD master))
echo FILES=$(echo $ALL_FILES) >> $GITHUB_ENV
- name: Static analysis
- name: static analysis
timeout-minutes: 1
run: |
cd $GITHUB_WORKSPACE
cp pyproject.toml $STRIPPED_DIR
cd $STRIPPED_DIR
${{ env.RUN }} "scripts/lint.sh $FILES"
${{ env.RUN }} "scripts/lint.sh"
build:
strategy:
Expand Down Expand Up @@ -147,17 +140,16 @@ jobs:
runs-on: ${{ ((github.repository == 'commaai/openpilot') &&
((github.event_name != 'pull_request') ||
(github.event.pull_request.head.repo.full_name == 'commaai/openpilot'))) && 'namespace-profile-amd64-8x16' || 'ubuntu-latest' }}
env:
PYTHONWARNINGS: default
steps:
- uses: actions/checkout@v4
- name: Setup
run: tools/op.sh setup
- name: Get ancestor commit
run: git fetch --unshallow --recurse-submodules=no origin master:master
- name: Static analysis
with:
submodules: true
- uses: ./.github/workflows/setup-with-retry
- name: Build openpilot
run: ${{ env.RUN }} "scons -j$(nproc)"
- name: static analysis
timeout-minutes: 1
run: tools/op.sh lint
run: ${{ env.RUN }} "scripts/lint.sh"

unit_tests:
name: unit tests
Expand Down
8 changes: 1 addition & 7 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,6 @@ testing = [
"pytest-repeat",
"ruff",
"codespell",
"pre-commit-hooks",
]

dev = [
Expand Down Expand Up @@ -178,11 +177,9 @@ plugins = [
"numpy.typing.mypy_plugin",
]
exclude = [
"body/",
"cereal/",
"msgq/",
"msgq_repo/",
"opendbc/",
"opendbc_repo/",
"panda/",
"rednose/",
"rednose_repo/",
Expand All @@ -207,9 +204,6 @@ warn_return_any=true
# allow implicit optionals for default args
implicit_optional = true

local_partial_types=true
explicit_package_bases=true

# https://beta.ruff.rs/docs/configuration/#using-pyprojecttoml
[tool.ruff]
indent-width = 2
Expand Down
64 changes: 4 additions & 60 deletions scripts/lint.sh
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
49 changes: 0 additions & 49 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 3af7747

Please sign in to comment.