-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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: Move formatting and linting checks out of tests.yml #4046
Conversation
Stopped checks as am waiting for #4043 to fix |
Tests were depending on linting by design, to avoid wasting CI time in case the code isn't even well formatted. What's the strategy here? |
I was completely disregarding the runtime to be fair. I don't even have access to our consumptions as of now. I would trust most people to run those tools locally with hooks or some other ways. Am I too hopeful? What do you think if any failure in this workflow stops the tests one? |
Being an OSS project we have plenty of CI time for free but it's not about the money, it's about good engineering practice and environmental awareness
Maybe I'm old but I would not trust people :)
7 minutes for linting are too much, I agree. What if we remove mypy and find a way to make pylint faster? |
Nevermind I was wrong, it takes ~7 minutes if the cache is invalid and it must reinstall dependencies. It should be no more than 2 minutes if cache is valid. My idea was splitting tests workflows depending on when they should run. Formatting and linting checks don't make much sense to me when run in If the code is merged I assume it's formatted and checked correctly already, I don't see the value of checking in We could skip them in Also one of my concerns is the If you feel that the dependency is a necessity I can ditch this solution with no issues, I'll find a different way. |
I strongly prefer to keep the dependency. I am sure not every community member has the precommit checks installed. And if CI runs all the tests again and again while someone tries to fix mypy issues it's a waste of compute resources. To give another example when it's useful: For very small changes, one might edit files in the browser and there are no precommit checks in this case. |
Regarding having the checks on main or not, I find your arguments convincing. 🙂 Every change we commit to main is checked already on the feature branch before merging into main. |
@julian-risch I had a discussion with @masci and @ZanSara on this and we decided to keep the Instead we're still gonna move
That wouldn't be an issue I think, if merging causes linting or formatting issues probably there are also conflicts so tests won't run preventing the merge. Also it would be a pretty rare occurence. In the end the important thing is that unit and integration tests are green. |
Alright then, let me know, when you need another review. |
by the way, feel free to re-assign the reviewer(s) if the others have more context. 👍 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good! Black should be a sufficient gatekeeping mechanism at preventing the CI to start on PRs with syntax errors and other "obvious" mistakes. Let's try this strategy out!
run: | | ||
pip install --upgrade pip | ||
pip install .[dev] | ||
pip install black==22.6.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering here: how could we keep in sync this version, the dev
version, and the pre-commit hooks version? I imagine black to be fairly stable, so not a big issue right now. It's just a "theoretical" problem that maybe we'll need to address in the future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably we could have a [linting]
or [formatting]
section in pyproject.toml
that is installed with [dev]
too and install only that.
But as you said it's pretty stable, I wouldn't be much concerned by this.
@@ -0,0 +1,21 @@ | |||
# If you change this name also do it in linting.yml |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Really cool to see how you handle skipping required workflows! We should apply this technique to many more cases 👀
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We will. 👀
Proposed Changes:
Move
mypy
andpylint
out oftests.yml
into a separatelinting.yml
workflow.This also remove the dependency in
unit-tests
,unit-tests-linux
,unit-tests-windows
andrest_api
jobs, so they're going to run only ifblack
passes.tests.yml
has not been modified further.A
linting-skipped.yml
has been added too that is run when the jobs inlinting.yml
are skipped, this is done to handle the requiredmypy
andpylint
checks as specified by the official Github documentation.How did you test it?
I statically checked the workflow using
actionlint
.Notes for the reviewer
I chose to run
mypy
andpylint
only on PRs and not onmain
since it's a protected branch.It should never happen that unformatted code is pushed directly to
main
so it shouldn't be necessary to run checks on it too.Checklist
I have updated the related issue with new insights and changesI added tests that demonstrate the correct behavior of the changefix:
,feat:
,build:
,chore:
,ci:
,docs:
,style:
,refactor:
,perf:
,test:
.I documented my code