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

maintainers/scripts: Lint check-maintainer-github-handles.sh #147424

Merged
merged 5 commits into from
Dec 17, 2021

Conversation

l0b0
Copy link
Contributor

@l0b0 l0b0 commented Nov 25, 2021

Motivation for this change

ShellCheck compliance and detecting errors earlier, see #133088, #21166.

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 21.11 Release Notes (or backporting 21.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

@Artturin

@@ -62,5 +61,3 @@ export -f checkUser
nix-instantiate -A lib.maintainers --eval --strict --json \
| jq -r '.[]|.github|select(.)' \
| parallel -j5 checkUser

# parallel -j100 checkUser ::: "eelco" "profpatsch" "Profpatsch" "a"
Copy link
Member

Choose a reason for hiding this comment

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

That should probably be kept.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If you can explain why, I could include that in the comment. As it stands, I feel like that just looks like accidentally committed test code.

Copy link
Member

Choose a reason for hiding this comment

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

I think that is when you want to manually check only a few users.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Documented, cheers.


# nixpkgs='<nixpkgs>'
# if [ -n "$1" ]; then
set -o errexit -o noclobber -o nounset -o pipefail
Copy link
Member

Choose a reason for hiding this comment

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

That is so explicit that most people will not know what this means. I guess:

errexit is -e and nounset is -u?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That is so explicit that most people will not know what this means.

That sentence doesn't make sense to me:

  • How can something more explicit be harder to understand, unless you've only ever seen the abbreviation?
  • Someone with no experience of either is going to find the longer option easier to read than the abbreviation, and might even get an inkling of what it actually means when seeing more than a single character.
  • It is easy to search for the long version using a search engine or man bash. The single character abbreviation, not so much.

Copy link
Member

Choose a reason for hiding this comment

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

How can something more explicit be harder to understand, unless you've only ever seen the abbreviation?

That answers itself. If you only ever have seen the short variant you don't know it.

Someone with no experience of either is going to find the longer option easier to read than the abbreviation, and might even get an inkling of what it actually means when seeing more than a single character.

The bash options are not self describing and someone having no experience will not understand either.

It is easy to search for the long version using a search engine

Since I am not the only person using the short options you will find a lot of results when searching https://www.google.com/search?q=set+-euo+pipefail

or man bash. The single character abbreviation, not so much.

Thats true. The bash man page is just to long.

Copy link
Member

@Artturin Artturin left a comment

Choose a reason for hiding this comment

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

let it run for 11 minutes and no issues
had to do this though

diff --git a/maintainers/scripts/check-maintainer-github-handles.sh b/maintainers/scripts/check-maintainer-github-handles.sh
index a5555ca9e90..b7007ecc6a5 100755
--- a/maintainers/scripts/check-maintainer-github-handles.sh
+++ b/maintainers/scripts/check-maintainer-github-handles.sh
@@ -11,7 +11,7 @@ function checkCommits {
     local ret status tmp user
     user="$1"
     tmp=$(mktemp)
-    curl --silent -w "%{http_code}" \
+    curl --silent -u artturin:${GITHUB_TOKEN} -w "%{http_code}" \
          "https://github.com/NixOS/nixpkgs/commits?author=$user" \
          > "$tmp"
     # the last line of tmp contains the http status
@@ -42,7 +42,7 @@ export -f checkCommits
 function checkUser {
     local user="$1"
     local status=
-    status="$(curl --silent --head "https://github.com/${user}" | grep Status)"
+    status="$(curl --silent -u artturin:${GITHUB_TOKEN} --head "https://github.com/${user}" | grep Status)"
     # checks whether a user handle can be found on github
     if [[ "$status" =~ 404 ]]; then
         printf "%s\t\t\t\t%s\n" "$status" "$user"

the script has some pre-existing though such as not properly catching non-existant user handles

@Artturin Artturin merged commit de125e2 into NixOS:master Dec 17, 2021
@SuperSandro2000
Copy link
Member

Can you do a PR to add that to the script? Having the GITHUB_TOKEN is far more important. Also you don't need to input your username, -u ":$GITHUB_TOKEN" will just work fine.

@l0b0 l0b0 deleted the lint-maintainers-scripts branch December 19, 2021 19:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants