-
-
Notifications
You must be signed in to change notification settings - Fork 14.5k
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
workflows/check-nixf-tidy.yml: init #330066
Conversation
Well i did't knew about |
2323b7e
to
1c24741
Compare
name: Check changed Nix files with nixf-tidy (experimental) | ||
|
||
on: | ||
pull_request_target: |
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.
Do we really need to run on the pull_request_target
? Would pull_request
not also work?
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.
GitHub Actions is a fickle beast: https://github.com/NixOS/nixpkgs/blob/d2a2dbc06347b4c5e30dd258743f6b3cae30d985/.github/workflows/check-by-name.yml#L8C1-L8C103
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.
Looking good overall!
for the CI output, maybe printing the line in question would be wanted? As an example:
would become
|
Ohh! GitHub Actions can actually do this very nicely with a workflow command:
This should highlight the problematic lines in the file view of PRs! |
Yeah that would be even better |
b482882
to
e2bea1c
Compare
Great idea! It works now: https://github.com/Aleksanaa/nixpkgs/pull/1/files |
This comment was marked as resolved.
This comment was marked as resolved.
Still another problem, it looks like the old error message is not cleared when the new error message appears. If you change the title or the like, multiple error messages may be generated |
will an empty maintainer list |
Yes, it's unused with. But I want it to report this error because we don't really need that |
This is getting more messy, but I believe you should be able to only conditionally output the errors using something like if [[ "${{github.event_name}}" == 'edited' ]]; then
echo "Edited the PR"
if [[ -z "${{github.event.edited.changes.base}}" ]]; then
echo "But didn't change the base branch, only the description/title"
# Don't output errors
else
# Do output errors, rare case of changing the base branch, which might cause different errors. Can't void the old ones unfortunately though, but should happen rarely.
fi
else
# Do output errors
fi |
c47df3c
to
621f8db
Compare
This works now |
b79bf7c
to
365b08c
Compare
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.
This looks ready to me, nice work! While this is a rather fresh PR, I don't think we need to wait for anything else, let's just try out and see how well it works 🚀
This pull request has been mentioned on NixOS Discourse. There might be relevant details there: https://discourse.nixos.org/t/we-added-a-linter-to-nixpkgs-checking-workflows/49722/2 |
Description of changes
CC @inclyc @Sigmanificient (I saw you were working on such clean-ups) @rhendric (#313981 (comment))
Here is an example test: https://github.com/Aleksanaa/nixpkgs/pull/1/files
This check will fail on:
rec
,with
, etc). This addresses Tracking issue: Removal of uneeded argument #313981with
(reference variables outside ofwith
expression). This also partially addresses Tracking issue: remove overuses ofwith lib;
#208242It uses
nixf-tidy
innixf
package. The json output is processed byjq
to form GitHub workflow messages, which will be rendered in PR's 'Files changed' overview.Like the workflow of nixfmt check, this workflow only fails when regression occurs (that is, the old file has no errors, but errors occur after the change; or the new file has errors). This is to avoid some larger files that cannot pass nixf-tidy (such as all-packages.nix). A feature that filters errors based on the lines affected (in git diff) may be implemented, but may require nixf improvements and more testing to work well.
Add a 👍 reaction to pull requests you find important.