diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..7a5d818 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,17 @@ +name: tests +on: + push: + pull_request: + +jobs: + precommit: + name: pre-commit + runs-on: ubuntu-20.04 + timeout-minutes: 8 + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-python@v4 + with: + python-version: '3.8' + - run: 'pip install pre-commit' + - run: 'pre-commit run --all' diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 1aafbd6..fda2a04 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,11 +1,38 @@ repos: +- repo: meta + hooks: + - id: check-hooks-apply + - id: check-useless-excludes - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.0.1 + rev: v4.3.0 hooks: - id: check-ast - exclude: tools + exclude: '^(tools)/' - id: check-json - id: check-xml - id: check-yaml - id: check-merge-conflict - id: check-symlinks + - id: check-added-large-files + args: ['--maxkb=100'] +- repo: https://github.com/codespell-project/codespell + rev: v2.2.2 + hooks: + - id: codespell + exclude: '^(userspace/files/serviceproviders.xml)|(tools/)' + args: + # if you've got a short variable name that's getting flagged, add it here + - -L bu,ro,te,ue,alo,hda,ois,nam,nams,ned,som,parm,setts,inout,warmup + - --builtins clear,rare,informal,usage,code,names,en-GB_to_en-US +- repo: https://github.com/PyCQA/flake8 + rev: 5.0.4 + hooks: + - id: flake8 + exclude: '^(tools/)' + additional_dependencies: ['flake8-no-implicit-concat'] + args: + - --indent-size=2 + - --enable-extensions=NIC + - --select=F,E112,E113,E304,E502,E701,E702,E703,E71,E72,E731,W191,W6 + - --statistics + - -j4 diff --git a/userspace/base_setup.sh b/userspace/base_setup.sh index fdc66b4..f7780eb 100755 --- a/userspace/base_setup.sh +++ b/userspace/base_setup.sh @@ -129,7 +129,7 @@ echo "" >> /etc/apt/sources.list echo "deb http://ports.ubuntu.com/ubuntu-ports/ bionic main restricted" >> /etc/apt/sources.list echo "deb http://ports.ubuntu.com/ubuntu-ports/ bionic universe" >> /etc/apt/sources.list -# Install neccesary libs +# Install necessary libs apt-get update -yq apt-get install --no-install-recommends -yq \ libacl1:armhf \ diff --git a/userspace/openpilot_dependencies.sh b/userspace/openpilot_dependencies.sh index 6f39398..f9b972a 100755 --- a/userspace/openpilot_dependencies.sh +++ b/userspace/openpilot_dependencies.sh @@ -2,7 +2,7 @@ echo "Installing openpilot dependencies" -# Install neccesary libs +# Install necessary libs apt-get update apt-get install --no-install-recommends -yq \ autoconf \ diff --git a/userspace/usr/comma/power_drop_monitor.py b/userspace/usr/comma/power_drop_monitor.py index 2745f02..9499caf 100755 --- a/userspace/usr/comma/power_drop_monitor.py +++ b/userspace/usr/comma/power_drop_monitor.py @@ -15,7 +15,7 @@ INA231_MASK_REG = 0x06 INA231_LIMIT_REG = 0x07 INA231_MASK_CONFIG = (1 << 12) # Bus undervoltage, not latching INA231_BUS_VOLTAGE_LSB_mV = 1.25 -VOLTAGE_FILE = f"/sys/class/hwmon/hwmon1/in1_input" +VOLTAGE_FILE = "/sys/class/hwmon/hwmon1/in1_input" PARAM_FILE = "/data/params/d/LastPowerDropDetected" alert_pin_base = f"/sys/class/gpio/gpio{POWER_ALERT_GPIO_PIN}/" @@ -118,6 +118,6 @@ if __name__ == '__main__': state_last = f.read().strip() if int(state_last) == 0: perform_controlled_shutdown() - except: + except Exception: pass diff --git a/userspace/usr/comma/sound/adsp-start.sh b/userspace/usr/comma/sound/adsp-start.sh index e96bae6..675dbf9 100755 --- a/userspace/usr/comma/sound/adsp-start.sh +++ b/userspace/usr/comma/sound/adsp-start.sh @@ -18,7 +18,7 @@ echo -n "/firmware/image" > /sys/module/firmware_class/parameters/path count=0 while [ ! -s /firmware/image/adsp.mdt ]; do sleep 0.1 - # wait 10s for /firmare mounted + # wait 10s for /firmware mounted count=$(( $count + 1 )) if [ $count -ge 100 ]; then echo "[ERROR] Can not find the adsp's firmware"