home-assistant / addons

:heavy_plus_sign: Docker add-ons for Home Assistant
https://home-assistant.io/hassio/
Apache License 2.0
1.57k stars 1.51k forks source link

Lint bash scripts with custom shebangs #3824

Open mislav opened 1 week ago

mislav commented 1 week ago

Many scripts in this repository have this shebang:

#!/usr/bin/with-contenv bashio

However, this doesn't match the shebang regex in action-shellcheck and therefore those files wouldn't get included in the linting check.

Supersedes https://github.com/home-assistant/addons/pull/3803 /cc @agners

This is the only mechanism to include additional scripts in the linting process. I'm not a fan of this approach, since new scripts with unique names added to this repository again won't be linted by default, but it's a start to ensure regressions like https://github.com/home-assistant/addons/issues/3801 are less likely to happen.

Summary by CodeRabbit

Release Notes

coderabbitai[bot] commented 1 week ago

[!NOTE]

Reviews paused

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.
📝 Walkthrough
📝 Walkthrough ## Walkthrough The changes include updates to multiple Bash scripts and a GitHub Actions workflow file. Key modifications involve the addition of an `additional_files` parameter in the ShellCheck job within `.github/workflows/lint.yml`, allowing for the linting of scripts with custom shebangs. Various scripts have been adjusted to improve exit code handling, variable usage, and logging practices, particularly in the context of managing service failures within the S6 supervision tree. New functionality has also been introduced in some scripts, such as enhanced DNS challenge handling and configuration for additional services. ## Changes | File | Change Summary | |---------------------------------------------------------|---------------------------------------------------------------------------------------------------------------| | .github/workflows/lint.yml | Added `additional_files` parameter to ShellCheck job for custom shebang scripts. | | assist_microphone/rootfs/etc/s6-overlay/s6-rc.d/assist_microphone/finish | Added shellcheck directive to disable warning SC2155; updated variable usage for `exit_code_signal`. | | configurator/rootfs/etc/s6-overlay/s6-rc.d/configurator/finish | Added shellcheck directive to disable warning SC2155; updated variable usage for `exit_code_signal`. | | duckdns/rootfs/etc/s6-overlay/s6-rc.d/duckdns/finish | Updated exit code calculation and logging for service termination; improved variable usage for `exit_code_signal`. | | letsencrypt/rootfs/etc/services.d/lets-encrypt/run | Enhanced handling of DNS challenges with new providers and credential checks; improved logging. | | nginx_proxy/rootfs/etc/s6-overlay/s6-rc.d/crond/finish | Updated variable usage for `exit_code_signal`; retained overall logic and error handling. | | nginx_proxy/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish | Improved exit code handling and logging; standardized variable usage for `exit_code_signal`. | | nginx_proxy/rootfs/etc/s6-overlay/s6-rc.d/nginx/run | Added JSON configuration handling; checks for Diffie-Hellman parameters; Cloudflare configuration support. | | openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/finish | Enhanced error handling and cleanup procedures; refined exit code handling and logging. | | openthread_border_router/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up | Enhanced functionality for firmware flashing; improved error handling and logging. | | openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/finish | Updated variable usage for `exit_code_signal`; clarified exit code handling logic. | | openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/run | Added execution command for Python module with configuration parameters. | | piper/rootfs/etc/s6-overlay/s6-rc.d/piper/finish | Updated variable usage for `exit_code_signal`; refined exit code handling. | | piper/rootfs/etc/s6-overlay/s6-rc.d/piper/run | Added shellcheck directive; executed Python module with command-line arguments based on configuration. | | silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/cpcd/finish | Added shellcheck directives; retained existing functionality for logging exit code and signals. | | silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run | Enhanced functionality and error handling; added new variable declarations and refined firewall setup. | | silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/zigbeed/run | Added shellcheck directives; ensured default port and interface settings for Zigbee daemon. | | silabs_flasher/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up | Enhanced functionality for firmware flashing; improved error handling and logging. | | whisper/rootfs/etc/s6-overlay/s6-rc.d/whisper/finish | Updated variable usage for `exit_code_signal`; clarified exit code handling logic. | | whisper/rootfs/etc/s6-overlay/s6-rc.d/whisper/run | Added architecture check and updated model handling; modified execution command for starting Whisper service. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant GitHub Actions participant ShellCheck User->>GitHub Actions: Trigger lint workflow GitHub Actions->>ShellCheck: Run ShellCheck with additional_files ShellCheck->>GitHub Actions: Return lint results GitHub Actions->>User: Provide lint results ```

Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media?

❤️ Share - [X](https://twitter.com/intent/tweet?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A&url=https%3A//coderabbit.ai) - [Mastodon](https://mastodon.social/share?text=I%20just%20used%20%40coderabbitai%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20the%20proprietary%20code.%20Check%20it%20out%3A%20https%3A%2F%2Fcoderabbit.ai) - [Reddit](https://www.reddit.com/submit?title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&text=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code.%20Check%20it%20out%3A%20https%3A//coderabbit.ai) - [LinkedIn](https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fcoderabbit.ai&mini=true&title=Great%20tool%20for%20code%20review%20-%20CodeRabbit&summary=I%20just%20used%20CodeRabbit%20for%20my%20code%20review%2C%20and%20it%27s%20fantastic%21%20It%27s%20free%20for%20OSS%20and%20offers%20a%20free%20trial%20for%20proprietary%20code)
🪧 Tips ### Chat There are 3 ways to chat with [CodeRabbit](https://coderabbit.ai): - Review comments: Directly reply to a review comment made by CodeRabbit. Example: - `I pushed a fix in commit , please review it.` - `Generate unit testing code for this file.` - `Open a follow-up GitHub issue for this discussion.` - Files and specific lines of code (under the "Files changed" tab): Tag `@coderabbitai` in a new review comment at the desired location with your query. Examples: - `@coderabbitai generate unit testing code for this file.` - `@coderabbitai modularize this function.` - PR comments: Tag `@coderabbitai` in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples: - `@coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.` - `@coderabbitai read src/utils.ts and generate unit testing code.` - `@coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.` - `@coderabbitai help me debug CodeRabbit configuration file.` Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. ### CodeRabbit Commands (Invoked using PR comments) - `@coderabbitai pause` to pause the reviews on a PR. - `@coderabbitai resume` to resume the paused reviews. - `@coderabbitai review` to trigger an incremental review. This is useful when automatic reviews are disabled for the repository. - `@coderabbitai full review` to do a full review from scratch and review all the files again. - `@coderabbitai summary` to regenerate the summary of the PR. - `@coderabbitai resolve` resolve all the CodeRabbit review comments. - `@coderabbitai configuration` to show the current CodeRabbit configuration for the repository. - `@coderabbitai help` to get help. ### Other keywords and placeholders - Add `@coderabbitai ignore` anywhere in the PR description to prevent this PR from being reviewed. - Add `@coderabbitai summary` to generate the high-level summary at a specific location in the PR description. - Add `@coderabbitai` or `@coderabbitai title` anywhere in the PR title to generate the title automatically. ### CodeRabbit Configuration File (`.coderabbit.yaml`) - You can programmatically configure CodeRabbit by adding a `.coderabbit.yaml` file to the root of your repository. - Please see the [configuration documentation](https://docs.coderabbit.ai/guides/configure-coderabbit) for more information. - If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: `# yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json` ### Documentation and Community - Visit our [Documentation](https://docs.coderabbit.ai) for detailed information on how to use CodeRabbit. - Join our [Discord Community](http://discord.gg/coderabbit) to get help, request features, and share feedback. - Follow us on [X/Twitter](https://twitter.com/coderabbitai) for updates and announcements.
mislav commented 4 days ago

Update: pushed a commit that fixes/allowlists all the shellcheck violations in scripts that are now newly included in the linting process.

mislav commented 2 days ago

Note that I'm ignoring most of Coderabbit suggestions because it doesn't understand that I'm merely trying to make CI pass with minimum impact to the codebase. Sure, its suggestions are legitimate, but even such an innocuous change as adding double quotes around an argument passed to a command can have negative consequences if the previous code relied (intentionally or accidentally) on word-splitting, for example. Because I'd rather avoid making code changes across dozens of scripts in this repository, I've opted to pepper # shellcheck disable directives throughout.

agners commented 1 day ago

@coderabbitai resolve

This PR doesn't try to fix shellcheck issues, it tries to enable along with minimal fixes.

@coderabbitai pause

coderabbitai[bot] commented 1 day ago

@agners: Understood, I will resolve the comments and pause the automatic reviews for this PR.

:white_check_mark: Actions performed Comments resolved. --- Reviews paused.