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

shellcheck.yml: add new tests using shellcheck #492

Open
wants to merge 16 commits into
base: master
Choose a base branch
from

Conversation

Nowa-Ammerlaan
Copy link
Contributor

I propose to add this new github action using shellcheck, it should hopefully avoid issues such as #488 occurring in a release.

Note this will cause the CI to fail until all existing issues are either fixed or ignored.

@scaronni
Copy link
Collaborator

Woah. Thanks!

Can you also add the actual commits that fix the shellcheck errors? :)

@Nowa-Ammerlaan
Copy link
Contributor Author

Can you also add the actual commits that fix the shellcheck errors? :)

Yes, but that is a bit more work and will take some time.

@scaronni
Copy link
Collaborator

Can you also add the actual commits that fix the shellcheck errors? :)

Yes, but that is a bit more work and will take some time.

No pressure! Many thanks.

@Nowa-Ammerlaan Nowa-Ammerlaan force-pushed the master branch 7 times, most recently from 6d0ab82 to 42f8805 Compare February 13, 2025 09:28
@anbe42 anbe42 marked this pull request as draft February 13, 2025 09:42
@anbe42 anbe42 self-requested a review February 13, 2025 09:42
@anbe42
Copy link
Collaborator

anbe42 commented Feb 13, 2025

Thanks for your effort. Please clear the draft flag once it is ready for review.

@Nowa-Ammerlaan
Copy link
Contributor Author

Nowa-Ammerlaan commented Feb 13, 2025

Done! CI is green again.

90% of this was just missing quotes. Other common issues were:

  • read without -r
  • expanding an array without any index, and array<->string mismatches
  • missing failure conditions for cd
  • calling rm on a variable without :?

There were some more complex issues which I marked as todo for later in a comment. Specifically a couple of cases where ls is used, but find (+ -exec) would be better.

There were also two obvious typos which got flagged as a variable unused warning. found_original (versus found_orginal) in the do_install function. And symlink_modules (versus symlink_module) for the --symlink-modules option. Fixed both of those issues. I think this specifically proves the usefulness of this new github action.

Copy link
Collaborator

@anbe42 anbe42 left a comment

Choose a reason for hiding this comment

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

Now that this is working, can we split up the huge dkms.in commit into a few smaller ones? While reading, the following categories came into my mind:

bugfix: misspelled variable names

bugfix: cd $dest || exit $some-unused-error-code see the list at the beginning, add it there, in order to clean up error code usage some day I don't want to add even more uses of the heavily overloaded ones

reindent - there is at least one big hunk being reindented, please do this separately (git diff -w should be empty on such a change) without any other changes hidden in it

the complex change w.r.t. parameter passing for safe_source() including the changes f
for list splitting, including all the (transitive) calls
(If I got it right, this is the only change where multiple lines at different places need to change together, while all other changes only affect that single line

missing quoting for scalars

array vs scalar misuse

shellcheck ignore without todo

shellcheck ignore with todo

removal of unused variables

lets see what is left over ;-)

what does shellcheck think about [[ $var ]] vs. [[ -n "$var" ]]? I'd prefer the first, but currently both are used inconsistently.

@anbe42
Copy link
Collaborator

anbe42 commented Feb 13, 2025

the complex change w.r.t. parameter passing for safe_source() including the changes f
for list splitting, including all the (transitive) calls
(If I got it right, this is the only change where multiple lines at different places need to change together, while all other changes only affect that single line

While cleaning that up, would it be helpful if dkms_conf_variables etc were arrays instead of strings that needs to be split on whitespace into separate tokens? Not sure what implications that would have ...

@Nowa-Ammerlaan
Copy link
Contributor Author

While cleaning that up, would it be helpful if dkms_conf_variables etc were arrays instead of strings that needs to be split on whitespace into separate tokens? Not sure what implications that would have ...

Technically this would be better indeed, but since we know that none of these variables contain whitespaces we can safely split the string into an array in the sourcing function. I am not sure if changing this now could have unintended side effects, so I'd rather not do it now and focus instead purely on introducing the new check and making it (mostly) happy with the current code without changing it too much.

@scaronni
Copy link
Collaborator

I think we can wait until this pull request is finished and make a new release, we have already a few fixes worth releasing.
@anbe42 ?

@scaronni
Copy link
Collaborator

Also, personal experience so far, unfortunately nobody tests or gives any feedback until code is tagged in a release. When people see a new release and start updating it's where you start getting feedback. So no candiates/betas etc.

I propose to add this new github action using shellcheck, it should
hopefully avoid issues such as [1] occurring in a release.

[1]: dell#488

Signed-off-by: Nowa Ammerlaan <[email protected]>
@Nowa-Ammerlaan Nowa-Ammerlaan force-pushed the master branch 4 times, most recently from 479f682 to 3a2a43b Compare February 14, 2025 11:27
Signed-off-by: Nowa Ammerlaan <[email protected]>
Signed-off-by: Nowa Ammerlaan <[email protected]>
Signed-off-by: Nowa Ammerlaan <[email protected]>
Signed-off-by: Nowa Ammerlaan <[email protected]>
Signed-off-by: Nowa Ammerlaan <[email protected]>
@Nowa-Ammerlaan
Copy link
Contributor Author

Now that this is working, can we split up the huge dkms.in commit into a few smaller ones?

Done!

what does shellcheck think about [[ $var ]] vs. [[ -n "$var" ]]? I'd prefer the first, but currently both are used inconsistently.

AFAIK it doesn't complain about either.

Copy link
Collaborator

@anbe42 anbe42 left a comment

Choose a reason for hiding this comment

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

Thanks for splitting it up. Improves readability of the changes a lot.

Nothing obvious that I've spotted, will give it some testing in my module test setup soon.

Let's get this in, as it will change the base for other pending changes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants