Add linting workflow using Ruff for pull requests#40
Add linting workflow using Ruff for pull requests#40hmenager merged 4 commits intoresearch-software-ecosystem:mainfrom
Conversation
|
I like this proposition, but should we first lint all the python code before merging this PR? |
|
If possible, it would be great if the workflow would automatically propose fixes as a new PR. |
|
I like the idea, extended not only to pull requests but all the commits. Just as a proof of concept, I have cloned the repo and tested to run |
jmfernandez
left a comment
There was a problem hiding this comment.
Should checks also happen on push?
|
I think they should. Out of curiosity, to which extent do you think this should be enforced:
|
|
What we can do is auto-fix on push to main (including merged PRs) by creating a separate PR that lints and formats the code. However, that will create a lot of messy PRs. It would be better if we could force the PR authors to lint and format the code themselves. |
|
Answering @hmenager comment #40 (comment)
This is a must at the beginning.
This behaviour should be agreed at least for pull requests.
Once we are accepting the former (forbidding the merge of pull requests failing in the validation) we have to enforce this one to avoid false positives. But, the only effective way to do it is protecting the main branch, forbidding direct commits.
So, I recommend an adoption roadmap of better practices, taking into account that "best" practices are a moving target resembling a ghost. |
|
Answering @arash77 comment #40 (comment)
When I was thinking on automatic fixes, it was more about fixes to issues in the code itself (i.e. the fixes applied by |
|
@jmfernandez So should we do only auto format on push into the main by creating a separate PR? |
|
There is also another tool that could suggest the changes right in the PR if it is related to the changes in the PR. https://github.com/reviewdog/reviewdog |
It might be "a bit too much", but it is worth a try |
I would start with that, in case there is no error in the analysed code (it does not make sense to propose a PR for code with errors) |
It will look like this: arash77#4 |
|
The auto fix PR could look like this: arash77#5 |
|
But this PR doesn't include the auto fix, it is only to create the checks on PRs. Do we want it here? |
From my point of view, we should go step by step. First, the current purpose of this PR, which is to integrate the initial checks on every PR, should be initially accepted and then refined. In parallel, in order to avoid misleading fail checks, either one of utils author on behalf all of them, or each one of the utils authors, should manually apply the needed changes to improve the code quality of each hosted utility used for the Research Software Ecosystem. What do you think, @hmenager (and other readers of this dialogue)? |
|
I would go the other way around:
I would not make any PR comments about that. This is just noise, no one wants to go line by line through this, people should use the Makefile or the pre-commit hook. Overall we also need to keep the infrastructure simple. |
|
We could also use this pre-commit hook: https://github.com/astral-sh/ruff-pre-commit |
|
I have added the Makefile so you can use |
|
Code is fixed in #50 following advice from @bgruening , any review is appreciated 🙂 |
|
I will rebase this to see if the check is working correctly. |
fd3d3d6 to
1a8e066
Compare
No description provided.