Skip to content

all: Run pre-commit tests in GitHub Actions. #16778

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: pre-commit

on: [push, pull_request]

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

jobs:
hook:
strategy:
fail-fast: false
matrix:
# codeformat generates too many changes
# ruff-format is blocked by micropython/micropython#16774
# hook: [codeformat, codespell, ruff, ruff-format]
hook: [codespell, ruff]
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
- uses: pre-commit/action@v3.0.1
with:
extra_args: ${{ matrix.hook }} --all-files
33 changes: 22 additions & 11 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ ignore-words-list = "ans,asend,deques,dout,emac,extint,hsi,iput,mis,numer,shft,s
quiet-level = 3
skip = """
*/build*,\
./.git,\
./drivers/cc3100,\
./lib,\
./ports/cc3200/FreeRTOS,\
./ports/cc3200/bootmgr/sl,\
./ports/cc3200/hal,\
./ports/cc3200/simplelink,\
./ports/cc3200/telnet,\
./ports/esp32/managed_components,\
./.git/*,\
./drivers/cc3100/*,\
./lib/*,\
./ports/cc3200/FreeRTOS/*,\
./ports/cc3200/bootmgr/sl/*,\
./ports/cc3200/hal/*,\
./ports/cc3200/simplelink/*,\
./ports/cc3200/telnet/*,\
./ports/esp32/managed_components/*,\
./ports/nrf/drivers/bluetooth/s1*,\
./ports/stm32/usbhost,\
./tests,\
./ports/stm32/usbhost/*,\
./tests/*,\
ACKNOWLEDGEMENTS,\
"""

Expand All @@ -27,6 +27,17 @@ line-length = 99
target-version = "py37"

[tool.ruff.lint]
exclude = [ # Ruff finds Python SyntaxError in these files
"tests/cmdline/repl_autocomplete.py",
"tests/cmdline/repl_autoindent.py",
"tests/cmdline/repl_basic.py",
"tests/cmdline/repl_cont.py",
"tests/cmdline/repl_emacs_keys.py",
"tests/cmdline/repl_words_move.py",
"tests/feature_check/repl_emacs_check.py",
"tests/feature_check/repl_words_move_check.py",
"tests/micropython/viper_args.py",
]
extend-select = ["C9", "PLC"]
ignore = [
"E401",
Expand Down
2 changes: 1 addition & 1 deletion tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ target platform and run the appropriate set of tests for that platform. For exa

That will run tests on the `/dev/ttyACM0` serial port. You can also use shortcut
device names like `a<n>` for `/dev/ttyACM<n>` and `c<n>` for `COM<n>`. Use
`./run-tests.py --help` to see all of the device possibilites, and other options.
`./run-tests.py --help` to see all of the device possibilities, and other options.

There are three kinds of tests:

Expand Down
2 changes: 1 addition & 1 deletion tests/extmod_hardware/machine_pwm.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Test machine.PWM, frequncy and duty cycle (using machine.time_pulse_us).
# Test machine.PWM, frequency and duty cycle (using machine.time_pulse_us).
#
# IMPORTANT: This test requires hardware connections: the PWM-output and pulse-input
# pins must be wired together (see the variable `pwm_pulse_pins`).
Expand Down
2 changes: 1 addition & 1 deletion tests/ports/esp32/esp32_nvs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

nvs = NVS("mp-test")

# test setting and gettin an integer kv
# test setting and getting an integer kv
nvs.set_i32("key1", 1234)
print(nvs.get_i32("key1"))
nvs.set_i32("key2", -503)
Expand Down
2 changes: 1 addition & 1 deletion tests/run-tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,7 +848,7 @@ def run_one_test(test_file):
test_file_abspath = os.path.abspath(test_file).replace("\\", "/")

if args.filters:
# Default verdict is the opposit of the first action
# Default verdict is the opposite of the first action
verdict = "include" if args.filters[0][0] == "exclude" else "exclude"
for action, pat in args.filters:
if pat.search(test_file):
Expand Down
Loading