-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Add zizmor to pre-commit; address GH workflow issues raised #7662
Conversation
@stefanv do you maybe want to update the description to add some more info?
|
(cd .github/workflows && zizmor *)
|
In our case, I don't think these issues are serious, but they are also easy enough to work around. |
I added zizmor as a pre-commit hook, otherwise we'd have no way of catching these problems as they occur. We could also / alternatively enforce it in CI. I also noticed that we don't currently enforce pre-commit hooks in our CI? |
I'm not sure how helpful vs. confusing it would be to (new) contributors. Some contributors expect it (based on other projects?), but the remote branch would then diverge from the local one... more often than just from edits by maintainers when allowed. |
Sorry, I'm not following. All code in the repo has to be compliant with the linters. This can be enforced locally, by running pre-commit (typically as a hook). But we should definitely not commit code that fails the linter. The linter will not modify code, just report that there's a problem—which would have been noticed locally, if the committer had pre-commit enabled, as requested in the development guide. |
@mkcor is referencing the fact that some projects, including napari (against my wishes but it turned out to save my butt a couple of times 😂), configure pre-commit.ci to push automatic fixes when the PR fails the linter. |
Yes, that's exactly what I meant; thank you, @jni!
I thought that's what you meant, @stefanv, by enforcing pre-commit hooks in our CI. I guess I didn't get your original question ("we don't currently enforce pre-commit hooks in our CI?").
Of course; currently, we do this by policy: We refrain from merging a PR for which the lint check fails (and we fix the PR until it passes the link check, as we should), but technically we could merge it (so we could, hypothetically, have non-compliant code land in Personally, I find that our current policy is good enough, safe enough, and well enforced, but I'm open to further steps (especially if that's becoming a standard in the ecosystem).
In my understanding, this is exactly / already the current situation. |
Got it, thanks for the clarification, Juan: I don't mean to reformat PRs automatically, simply to check that they are compliant. We are currently in the (bad) situation that our CI is failing almost constantly, so we have to merge with CI failing. This makes it very easy for lint failures to slip through, if we're not careful. This is just an extra safety net. |
That's right, and I admit I'm always uncomfortable merging PRs with some CI failing even when it's unrelated (including when it's patently unrelated, i.e., investigating literally took 30 seconds).
In my experience, it's not 'very easy.' First of all, we are careful. Whenever CI is failing, we look into the list of checks (we click all the failing checks and read the error messages and troubleshoot and so on) and, honestly, the [edit:
Whether all CI checks are passing: or some are failing: we don't miss that "P
Sorry, I'm missing what the safety net is here exactly. To be an extra safety net, shouldn't the zizmor block go under |
@mkcor Not sure I follow, the ci section has the following:
This pre-commit check will only affect people modifying the CI workflows, which won't be new contributors. |
Oh, I get it now! I apologize for the confusion, @stefanv. The 'zizmor block' I was referring to is adding zizmor to our pre-commit hooks, period. |
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.
I could reproduce successfully. Note that, before pip installing zizmor==1.1.1, I casually pip installed zizmor, so I got version 1.2.2, which resulted in:
$ cd .github/workflows && zizmor .
2025-01-28T14:11:59.938385Z WARN collect_inputs:collect_from_repo_dir{top_dir="." current_dir="."}: zizmor: ./.github/workflows not found while collecting workflows
no inputs collected
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.
When checking with zizmor v1.2.2 I get additional warnings relating to this file and label-check.yaml:16:3
.
Details
warning[excessive-permissions]: overly broad permissions
--> milestone-merged-prs.yaml:11:3
|
11 | / milestone_pr:
12 | | name: attach to PR
... |
17 | | token: ${{ secrets.MILESTONE_LABELER_TOKEN }}
18 | | force: true
| | -
| |______________________|
| this job
| default permissions used due to no permissions: block
|
= note: audit confidence → Medium
warning[excessive-permissions]: overly broad permissions
--> label-check.yaml:16:3
|
16 | / check-type-label:
17 | | name: ensure type label
... |
24 | | exit 1
25 | | fi
| | -
| |_____________|
| this job
| default permissions used due to no permissions: block
|
= note: audit confidence → Medium
38 findings (1 ignored, 35 suppressed): 0 unknown, 0 informational, 0 low, 2 medium, 0 high
Do we care about addressing these?
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.
Also I don't really understand the warning. GitHub's worflow syntax doesn't mention block
as a valid value for permissions
.
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.
I think it means the permissions block is missing.
e507127
to
eb1d543
Compare
.pre-commit-config.yaml
Outdated
@@ -43,6 +43,11 @@ repos: | |||
entry: python tools/generate_requirements.py | |||
files: "pyproject.toml|requirements/.*\\.txt|tools/generate_requirements.py" | |||
|
|||
- repo: https://github.com/woodruffw/zizmor-pre-commit | |||
rev: 4dcc98ccce605605fd6d5202bf803a8c8bc34e8d # v1.1.1 |
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.
Any value in already updating to most recent v1.3.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.
Yes, let me do that.
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 otherwise.
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.
Thanks! It looks like there is one or two minor pending changes (e.g., updating to 1.3), so I will let Stefan merge once he's finished.
Darn, forgot to push |
@jarrodmillman Did I mess up the permissions for the milestone labeler? I was worried I might, so I checked :) The action ran successfully, but the milestone is not set, which is a problem in itself. |
…ailure * origin/main: Add zizmor to pre-commit; address GH workflow issues raised (scikit-image#7662) Reenable test marked as flaky on Azure. (scikit-image#7694) Simultaneously resolve all dependencies; add pip caching (scikit-image#7690) Copy keypoints if necessary to preserve contiguity (scikit-image#7692) CI cleanup (scikit-image#7693) Port CI testing from Azure to GitHub (scikit-image#7687) Lower CI build verbosity Use pytest config in pyproject.toml in CI (scikit-image#7555) Improve docstring for rolling_ball function. (scikit-image#7682)
No description provided.