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

Add ShellCheck to check-lints (for tools) #2532

Merged
merged 2 commits into from
Nov 3, 2022

Conversation

jpculp
Copy link
Member

@jpculp jpculp commented Oct 27, 2022

Description of changes:

During the check-lints stage of the build, ShellCheck will analyze any bash scripts under the tools directory and raise an error for any findings with a severity of warning or above.

For more targeted linting, check-lints was also split into check-clippy and check-shell which can be called individually.

Also addressed several warnings to avoid breaking the build.

Testing done:

Ran with and without the tools: fix ShellCheck warnings commit.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

Makefile.toml Outdated Show resolved Hide resolved
tools/start-local-vm Outdated Show resolved Hide resolved
Makefile.toml Outdated Show resolved Hide resolved
Makefile.toml Outdated Show resolved Hide resolved
@@ -1,4 +1,5 @@
#!/usr/bin/env bash
# shellcheck disable=SC2054 # Arrays are formatted for passing args to other tools
Copy link
Member

Choose a reason for hiding this comment

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

That shellcheck linter probably assumes the script is doing something dumb while assembling the QEMU invocation, where QEMU just needs commas in individual arguments. We could also quote those, but I think disabling the warning is the better choice for readability. 👍

tools/start-local-vm Outdated Show resolved Hide resolved
tools/docker-go Outdated Show resolved Hide resolved
@jpculp
Copy link
Member Author

jpculp commented Oct 28, 2022

  • Added improved logic for counting the scripts that contain warnings.
  • Expanded check-lints into check-clippy and check-shell so that linting can be more targeted in the future.
  • Fixed indentation inconsistency.
  • Declare and assign arch separately.
  • Replaced fix in docker-go with a TODO to address in Improve docker-go interface #2534.

@jpculp
Copy link
Member Author

jpculp commented Oct 28, 2022

Fixed a typo in one of the commit messages.

Copy link
Contributor

@bcressey bcressey left a comment

Choose a reason for hiding this comment

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

Some minor nits, but nothing blocking.

Makefile.toml Outdated Show resolved Hide resolved
Makefile.toml Outdated Show resolved Hide resolved
Makefile.toml Outdated Show resolved Hide resolved
This commit checks the bash scripts under tools during the `check-lints`
task. For more targeted linting, `check-lints` was also split into
`check-clippy` and `check-shell` which can be called individually.
@jpculp
Copy link
Member Author

jpculp commented Nov 3, 2022

  • Escaped ! in grep regex.
  • Added quotes to be more consistent with check-clippy.

@jpculp
Copy link
Member Author

jpculp commented Nov 3, 2022

I rebased locally and ran cargo make check-lints and there haven't been any new warnings.

@jpculp jpculp merged commit 978ee0c into bottlerocket-os:develop Nov 3, 2022
@jpculp jpculp deleted the shellcheck branch November 3, 2022 22:33
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.

5 participants