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

CI: Add a bash linter to pre-submits #781

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

Conversation

mandre
Copy link
Contributor

@mandre mandre commented Sep 23, 2024

Add a new CI job that warns about shellcheck issues with severity error, and fix all such errors in existing bash files.

This should prevent errors such as the one fixed in #780 from entering the repo again.

Fixes the following shellcheck error:

    SC2068 (error): Double quote array expansions to avoid re-splitting elements.

https://www.shellcheck.net/wiki/SC2068
Fixes the following shellcheck error:

    SC2148 (error): Tips depend on target shell and yours is unknown. Add a shebang or a 'shell' directive.

https://www.shellcheck.net/wiki/SC2148
Fixes the following shellcheck errors:

    SC2145 (error): Argument mixes string and array. Use * or separate argument.
    SC2199 (error): Arrays implicitly concatenate in [[ ]]. Use a loop (or explicit * instead of @).

https://www.shellcheck.net/wiki/SC2145
https://www.shellcheck.net/wiki/SC2199

Also fixes a typo in SUPPORTED_INTERFACE_SWITCHER_MODES.
Fixes the following shellcheck error:

    SC2045 (error): Iterating over ls output is fragile. Use globs.

https://www.shellcheck.net/wiki/SC2045
Copy link

Thanks for your PR,
To run vendors CIs, Maintainers can use one of:

  • /test-all: To run all tests for all vendors.
  • /test-e2e-all: To run all E2E tests for all vendors.
  • /test-e2e-nvidia-all: To run all E2E tests for NVIDIA vendor.

To skip the vendors CIs, Maintainers can use one of:

  • /skip-all: To skip all tests for all vendors.
  • /skip-e2e-all: To skip all E2E tests for all vendors.
  • /skip-e2e-nvidia-all: To skip all E2E tests for NVIDIA vendor.
    Best regards.

@coveralls
Copy link

coveralls commented Sep 23, 2024

Pull Request Test Coverage Report for Build 11066086546

Details

  • 0 of 0 changed or added relevant lines in 0 files are covered.
  • 1 unchanged line in 1 file lost coverage.
  • Overall coverage decreased (-0.006%) to 45.028%

Files with Coverage Reduction New Missed Lines %
controllers/drain_controller.go 1 67.1%
Totals Coverage Status
Change from base Build 10979758277: -0.006%
Covered Lines: 6624
Relevant Lines: 14711

💛 - Coveralls

Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

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

Great work!

Thanks for the contribution!

Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

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

just a nit: can you put it inside the same test.yml file and not create a new one please

@mandre mandre force-pushed the shellcheck branch 3 times, most recently from a18bf43 to 452f4e7 Compare September 26, 2024 13:14
@@ -5,8 +5,8 @@
# Write invocation with arguments to a file to allow making assertion.
echo "$*" >> /rpm-ostree_calls

if [ "$*" != *"--append"* ]
then
# if [ "$*" != *"--append"* ]
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@SchSeba if it's fine with you, I'll just remove the conditional, as a test relies on the broken behavior as you can see in this run.

Copy link
Collaborator

Choose a reason for hiding this comment

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

@zeeke can you have a look at this please

Copy link
Contributor Author

Choose a reason for hiding this comment

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

With this change, the test fail with:

+ chroot /host/ rpm-ostree kargs
+ /usr/sbin/chroot /tmp/tmp.gOQJTP0gp3 rpm-ostree kargs
+ grep -vq X=Y
/usr/sbin/chroot: failed to run command ‘rpm-ostree’: No such file or directory

Which doesn't really make sense to me. I'll try changing the shebang back to #!/usr/bin/sh to see if it makes a difference.

https://github.com/k8snetworkplumbingwg/sriov-network-operator/actions/runs/11065756907/job/30745730017?pr=781#step:9:105

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, a5c53b5 worked.

I think this is ready for reviews now.

Fixes the following shellcheck error:

    SC2081 (error): [ .. ] can't match globs. Use a case statement.

https://www.shellcheck.net/wiki/SC2081
Warns about shellcheck issues with severity `error`.
Copy link
Collaborator

@SchSeba SchSeba left a comment

Choose a reason for hiding this comment

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

nice work!

LGTM

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