diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f68a3f..6cfc302 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -165,6 +165,12 @@ jobs: RUN_TYPE: ${{ steps.set-run-type.outputs.result }} run: | make check + - name: Run ruff + env: + PACKAGE_LEVEL: ${{ matrix.package_level }} + RUN_TYPE: ${{ steps.set-run-type.outputs.result }} + run: | + make ruff - name: Run pylint env: PACKAGE_LEVEL: ${{ matrix.package_level }} diff --git a/.ruff.toml b/.ruff.toml new file mode 100644 index 0000000..1e8d377 --- /dev/null +++ b/.ruff.toml @@ -0,0 +1,27 @@ +# Ruff configuration file + +# Exclude a variety of commonly ignored directories. +exclude = [ + "build", + "dist", +] + +# Keep in sync with flake8 +line-length = 80 + +indent-width = 4 + +# Assume a particular minimum Python version +target-version = "py38" + +[lint] + +# Keep in sync with flake8 +ignore = [] + +# Allow fix for all enabled rules (when `--fix`) is provided. +# fixable = ["ALL"] +# unfixable = [] + +# Allow unused variables when underscore-prefixed. +# dummy-variable-rgx = "^(_+|(_+[a-zA-Z0-9_]*[a-zA-Z0-9]+?))$" diff --git a/Makefile b/Makefile index aa4dd3e..49057a4 100644 --- a/Makefile +++ b/Makefile @@ -183,11 +183,14 @@ safety_develop_policy_file := .safety-policy-develop.yml # Flake8 config file flake8_rc_file := .flake8 +# Ruff config file +ruff_rc_file := .ruff.toml + # PyLint config file pylint_rc_file := .pylintrc # Packages whose dependencies are checked using pip-missing-reqs -check_reqs_packages := pip_check_reqs pipdeptree build pytest coverage coveralls flake8 pylint safety twine towncrier +check_reqs_packages := pip_check_reqs pipdeptree build pytest coverage coveralls flake8 ruff pylint safety twine towncrier ifdef TESTCASES pytest_opts := $(TESTOPTS) -k $(TESTCASES) @@ -208,6 +211,7 @@ help: @echo ' develop - Prepare the development environment by installing prerequisites' @echo " check_reqs - Perform missing dependency checks" @echo ' check - Run Flake8 on sources' + @echo " ruff - Run ruff on sources (an alternate lint tool)" @echo ' pylint - Run PyLint on sources' @echo " safety - Run Safety tool" @echo ' test - Run tests (and test coverage)' @@ -243,6 +247,10 @@ install: $(done_dir)/install_$(pymn)_$(PACKAGE_LEVEL).done check: $(done_dir)/flake8_$(pymn)_$(PACKAGE_LEVEL).done @echo '$@ done.' +.PHONY: ruff +ruff: $(done_dir)/ruff_$(pymn)_$(PACKAGE_LEVEL).done + @echo '$@ done.' + .PHONY: pylint pylint: $(done_dir)/pylint_$(pymn)_$(PACKAGE_LEVEL).done @echo '$@ done.' @@ -379,6 +387,13 @@ $(done_dir)/flake8_$(pymn)_$(PACKAGE_LEVEL).done: $(done_dir)/develop_$(pymn)_$( flake8 $(check_py_files) echo "done" >$@ +$(done_dir)/ruff_$(pymn)_$(PACKAGE_LEVEL).done: $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done $(ruff_rc_file) $(check_py_files) + @echo "Makefile: Performing ruff checks with PACKAGE_LEVEL=$(PACKAGE_LEVEL)" + -$(call RM_FUNC,$@) + ruff check --unsafe-fixes --config $(ruff_rc_file) $(check_py_files) + echo "done" >$@ + @echo "Makefile: Done performing ruff checks" + $(done_dir)/safety_develop_$(pymn)_$(PACKAGE_LEVEL).done: $(done_dir)/develop_$(pymn)_$(PACKAGE_LEVEL).done Makefile $(safety_develop_policy_file) minimum-constraints-develop.txt @echo "Makefile: Running Safety for development packages (and tolerate safety issues when RUN_TYPE is normal or scheduled)" -$(call RM_FUNC,$@) diff --git a/changes/58.feature.rst b/changes/58.feature.rst new file mode 100644 index 0000000..fbf61b7 --- /dev/null +++ b/changes/58.feature.rst @@ -0,0 +1,2 @@ +Added support for running the 'ruff' checker via "make ruff" and added that +to the test workflow. diff --git a/minimum-constraints-develop.txt b/minimum-constraints-develop.txt index 72af419..7407322 100644 --- a/minimum-constraints-develop.txt +++ b/minimum-constraints-develop.txt @@ -66,6 +66,9 @@ pycodestyle==2.11.0 pyflakes==3.1.0 entrypoints==0.3.0 +# Ruff checker (no imports, invoked via ruff script): +ruff==0.3.5 + # Change log towncrier==22.8.0 incremental==22.10.0 diff --git a/requirements-develop.txt b/requirements-develop.txt index 4622724..a3b81fc 100644 --- a/requirements-develop.txt +++ b/requirements-develop.txt @@ -74,6 +74,9 @@ pycodestyle>=2.11.0 pyflakes>=3.1.0 entrypoints>=0.3.0 +# Ruff checker (no imports, invoked via ruff script): +ruff>=0.3.5 + # Change log towncrier>=22.8.0