From 2699011cdb37bb8d89cb85a48257dfca7acb03b7 Mon Sep 17 00:00:00 2001 From: Julia Haas Date: Fri, 20 Dec 2024 15:20:47 +0100 Subject: [PATCH 1/2] update READMEs --- README.md | 18 ++++++++---------- linting-config-examples/README.md | 30 +++++++++++++++++------------- 2 files changed, 25 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 3ff0202..d3bb540 100644 --- a/README.md +++ b/README.md @@ -27,13 +27,13 @@ jobs: ``` -or use e.g. ` pylint-version: ''` to skip checks with pylint. (If one of the versions is set to an empty string the code quality check will be -skipped.) +or use e.g. ` pylint-version: ''` to skip checks with pylint. (If one of +the versions is set to an empty string the code quality check will be skipped.) -Examples how `flake8`, `pylint`, `markdownlint`, `shellcheck` and `ruff` can be configured are in the -[linting-config-examples](linting-config-examples) -folder. The `pylint` and `ruff` configuration files do not need to be created if they -are not to be customized, since they will be copied by the workflow if they +Examples how `flake8`, `pylint`, `markdownlint`, `shellcheck` and `ruff` can be +configured are in the [linting-config-examples](linting-config-examples) +folder. The `pylint` and `ruff` configuration files do not need to be created if +they are not to be customized, since they will be copied by the workflow if they do not exists, although an additional `ruff.toml` file will be merged. See [linting-config-examples](linting-config-examples/README.md) for more details on how to configure the individual linters. @@ -154,7 +154,6 @@ jobs: ``` # pre-commit - ## Python Linting The python3 linting pre-commit hook uses `black`, `flake8`, `pylint` @@ -165,7 +164,7 @@ You can use it by adding a `.pre-commit-config.yml` file to the repo containing ``` repos: - repo: https://github.com/mundialis/github-workflows - rev: 1.3.1 + rev: 1.4.0 hooks: - id: linting ``` @@ -278,8 +277,7 @@ alias black="black --check --diff --line-length 79 ." alias pylint="pylint ." ruff () { - wget --continue https://raw.githubusercontent.com/mundialis/github-workflows/refs/heads/main/linting-config-examples/ruff.toml -O /tmp/ruff.toml -q - toml-union ruff.toml /tmp/ruff.toml -o ruff-merged.toml + toml-union ruff.toml ~/repos/github-workflows/linting-config-examples/ruff.toml -o ruff-merged.toml /home/`whoami`/.local/bin/ruff check --config ruff-merged.toml --output-format=concise . --preview --unsafe-fixes } diff --git a/linting-config-examples/README.md b/linting-config-examples/README.md index 3fa0a8e..8e8ddf1 100644 --- a/linting-config-examples/README.md +++ b/linting-config-examples/README.md @@ -2,10 +2,10 @@ The reusable linting workflow tries to be as strict as possible. It is up to the repositories using it to define reasonable exceptions. -Here are some ways described how this can be done. +Here, some ways are described how this can be done. ## flake8 -Simply add a .flake8 config file to the root of your repository +Simply add a `.flake8` config file to the root of your repository. See example here or visit [official documentation](https://flake8.pycqa.org/en/latest/user/configuration.html). `flake8 --config=.flake8 --count --statistics --show-source .` @@ -15,18 +15,21 @@ See https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.h `black --check --diff --line-length 79 .` ## pylint -There are two different configs - one which must be followed and one which is more strict -but allowed to fail. Both are contained in this repository and used for the reusable linting -workflow. If that fits, all is good. If you need more specific adjustments, name them the -same way and place them in your directory root to adjust. +There are two different configs - one which must be followed and one which is +more strict but allowed to fail. Both are contained in this repository and used +also by other repositories for the reusable linting workflow. If that works, you +do not have to do anything. If you need more specific adjustments, copy them +(with same name) to your root directory to adjust. `pylint .` `pylint --rc-file=.pylintrc_allowed_to_fail .` +# TODO: possible to change workflow so that standard config from this repo and additional config from repo where the workflow is used are both used ## ruff -ruff contains rules inspired by black, flake8, pylint and more and is extremely fast in linting and formatting Python code. -The linting config is aligned to the [one from GRASS GIS](https://github.com/OSGeo/grass/blob/main/pyproject.toml). -Per default, a lot of linting rules are active. If needed, add a `ruff.toml` config file to the root of your repository -and add rules which to ignore. +ruff contains rules inspired by black, flake8, pylint and more and is extremely +fast in linting and formatting Python code. +The linting config is aligned to the [config from GRASS GIS](https://github.com/OSGeo/grass/blob/main/pyproject.toml). +Per default, a lot of linting rules are active. If needed, add a `ruff.toml` +config file to the root of your repository and add rules to ignore. See example here or visit [official documentation](https://docs.astral.sh/ruff/). ``` ruff check --config ruff-merged.toml --output-format=full . --preview --unsafe-fixes @@ -44,7 +47,8 @@ ruff check --config ruff-merged.toml . --preview --unsafe-fixes --output-format (Need to add `,` at the end of each line). ## superlinter -Superlinter is a wrapper for many different linters. Each has a different way to be configured. +Superlinter is a wrapper for many different linters. Each has a different way to +be configured. Configs can be used in own repo to define rules of what to ignore. Example config files exist for [markdownlint](https://github.com/DavidAnson/markdownlint) and [shellcheck](https://github.com/koalaman/shellcheck). @@ -84,7 +88,7 @@ Or more sophisticated ## Run locally When not using pre-commit, all files can be checked locally via docker command. -This way, all used linters don't need to be installed locally individually. +This way, the used linters don't need to be installed locally individually. As linters might change, check in `.github/workflows/linting.yml` around L160 which environmental variables can to be used. @@ -108,7 +112,7 @@ docker run \ -e VALIDATE_RENOVATE=true \ -e VALIDATE_XML=true \ -e VALIDATE_YAML=true \ - -v /home/ctawalika/repos/actinia/actinia-core/:/tmp/lint \ + -v ${HOME}/repos/actinia/actinia-core/:/tmp/lint \ ghcr.io/super-linter/super-linter:latest ``` From deedebb073b545ae4105251f116c01e2d0f5768c Mon Sep 17 00:00:00 2001 From: Julia Haas Date: Fri, 20 Dec 2024 15:23:21 +0100 Subject: [PATCH 2/2] readd wget for ruff --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index d3bb540..b2c0e2c 100644 --- a/README.md +++ b/README.md @@ -277,7 +277,8 @@ alias black="black --check --diff --line-length 79 ." alias pylint="pylint ." ruff () { - toml-union ruff.toml ~/repos/github-workflows/linting-config-examples/ruff.toml -o ruff-merged.toml + wget --continue https://raw.githubusercontent.com/mundialis/github-workflows/refs/heads/main/linting-config-examples/ruff.toml -O /tmp/ruff.toml -q + toml-union ruff.toml /tmp/ruff.toml -o ruff-merged.toml /home/`whoami`/.local/bin/ruff check --config ruff-merged.toml --output-format=concise . --preview --unsafe-fixes }