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

ci: Add format check workflow #766

Merged
merged 4 commits into from
Nov 19, 2024

Conversation

pdgendt
Copy link
Collaborator

@pdgendt pdgendt commented Nov 4, 2024

Add a CI workflow to report formatting issues on changed files. This is to gradually update files in the repository to be conform with PEP8 formatting.

Copy link
Collaborator

@marc-hb marc-hb left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can this check be easily overriden ignored when needed? For instance we don't want one-line fix PRs to be drowned in whitespace changes.

Add setting for the ruff formatter to check during CI.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
@pdgendt
Copy link
Collaborator Author

pdgendt commented Nov 6, 2024

Went a step further, new files are always fully checked, changed chunks now also need to be formatted.

Experimenting shown here: https://github.com/pdgendt/west/actions/workflows/format.yml with annotations

@pdgendt pdgendt force-pushed the ci-ruff-format branch 2 times, most recently from edd1648 to c9c21a7 Compare November 6, 2024 09:55
@pdgendt pdgendt marked this pull request as ready for review November 6, 2024 10:02
@pdgendt pdgendt force-pushed the ci-ruff-format branch 3 times, most recently from cc4530a to a487d53 Compare November 6, 2024 13:30
@marc-hb
Copy link
Collaborator

marc-hb commented Nov 6, 2024

Checking only modified chunks sounds great in theory but I'm concerned that the code of the Github workflow is getting too complicated and hard to maintain. It's not like west has had an oversupply of maintainers :-/

As long as this check does not block merges, I think checking only new and modified files (the entire file each time) is a good enough trade-off. For sure that trade-off has been working well for years with pylint and shellcheck in thesofproject/sof-test@336094b

@pdgendt
Copy link
Collaborator Author

pdgendt commented Nov 8, 2024

Checking only modified chunks sounds great in theory but I'm concerned that the code of the Github workflow is getting too complicated and hard to maintain. It's not like west has had an oversupply of maintainers :-/

As long as this check does not block merges, I think checking only new and modified files (the entire file each time) is a good enough trade-off. For sure that trade-off has been working well for years with pylint and shellcheck in thesofproject/sof-test@336094b

Updated the PR accordingly:

  • Ignore deleted python files
  • Run ruff format --check --diff on entire files
  • Add continue-on-error: true to make the workflow pass if the format job fails (making it non-blocking)
  • Add a warning annotation instead of an error

@pdgendt pdgendt force-pushed the ci-ruff-format branch 2 times, most recently from 4a9c26e to c9af293 Compare November 8, 2024 14:13
.github/workflows/format.yml Outdated Show resolved Hide resolved
.github/workflows/format.yml Outdated Show resolved Hide resolved
.github/workflows/format.yml Outdated Show resolved Hide resolved
.github/workflows/format.yml Outdated Show resolved Hide resolved
.github/workflows/format.yml Outdated Show resolved Hide resolved
.github/workflows/format.yml Show resolved Hide resolved
.github/workflows/format.yml Outdated Show resolved Hide resolved
.github/workflows/format.yml Show resolved Hide resolved
@pdgendt pdgendt force-pushed the ci-ruff-format branch 2 times, most recently from 4c6bf3f to 7d39f6c Compare November 19, 2024 14:10
@marc-hb marc-hb dismissed their stale review November 19, 2024 17:13

Most concerns addressed

Add a CI workflow to report formatting issues on changed files. This is
to gradually update files in the repository to be conform with PEP8
formatting.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Formatting test_alias.py is trivial.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
Formatting test_commands.py is trivial.

Signed-off-by: Pieter De Gendt <pieter.degendt@basalte.be>
.github/workflows/format.yml Show resolved Hide resolved
@pdgendt pdgendt merged commit 2b18ae4 into zephyrproject-rtos:main Nov 19, 2024
19 checks passed
@pdgendt pdgendt deleted the ci-ruff-format branch November 19, 2024 18:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants