Skip to content
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

Draft: README updates #50

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
15 changes: 7 additions & 8 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down Expand Up @@ -154,7 +154,6 @@ jobs:
```

# pre-commit

## Python Linting

The python3 linting pre-commit hook uses `black`, `flake8`, `pylint`
Expand All @@ -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
```
Expand Down
30 changes: 17 additions & 13 deletions linting-config-examples/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 .`

Expand All @@ -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
Expand All @@ -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).

Expand Down Expand Up @@ -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.

Expand All @@ -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
```

Expand Down
Loading