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 all shell scripts in this repository #3803

Closed mislav closed 1 month ago

mislav commented 1 month ago

Issue https://github.com/home-assistant/addons/issues/3801 describes a regression where a syntax error was introduced into a bash script that led to an addon startup issue. Because this repository has a linting step, I've looked into how it was that this syntax error wasn't caught by shellcheck. It turned out that a lot of script files in this repository—78 files, to be exact—were not linted due to Home Assistant's unusual shebang:

#!/usr/bin/with-contenv bashio

The "lint" workflow that runs for all pull requests in this repository used the ludeeus/action-shellcheck@2.0.0 action as a shellcheck wrapper. However, that wrapper only lints files with known extensions and known shebangs, leading to lots of of scripts in this repository not being subject to linting even though they are technically bash scripts.

Furthermore, there was no visibility into this linting problem, because the linting step neither printed the list of files processed nor was there a way to run the linter script locally.

This change:

  1. Replaces the usage of the ludeeus/action-shellcheck@2.0.0 action with an inline script that is runnable locally on both Linux and macOS;

  2. Ensures that all script files in the repository are subject to linting regardless of their shebang;

  3. Uses shellcheck that comes preinstalled in GitHub Actions runners rather than downloading it every time;

  4. Reformats shellcheck output with Actions "workflow commands" syntax, which should lead to nicer formatting of linting errors in GitHub pull requests view.

Here is the diff of the list of all filenames linted before vs after this change ```diff --- scan-before.txt 2024-10-17 16:53:17 +++ scan-after.txt 2024-10-17 16:52:15 @@ -1,0 +2,3 @@ +./assist_microphone/rootfs/etc/s6-overlay/s6-rc.d/assist_microphone/finish +./assist_microphone/rootfs/etc/s6-overlay/s6-rc.d/assist_microphone/run +./assist_microphone/rootfs/etc/s6-overlay/s6-rc.d/discovery/run @@ -2,0 +6,3 @@ +./cec_scan/rootfs/etc/services.d/cec-scan/run +./configurator/rootfs/etc/s6-overlay/s6-rc.d/configurator/finish +./configurator/rootfs/etc/s6-overlay/s6-rc.d/configurator/run @@ -5,0 +12 @@ +./deconz/rootfs/etc/services.d/deconz/discovery @@ -6,0 +14 @@ +./deconz/rootfs/etc/services.d/deconz/run @@ -7,0 +16,4 @@ +./deconz/rootfs/etc/services.d/nginx/run +./deconz/rootfs/etc/services.d/otau-ikea/run +./deconz/rootfs/etc/services.d/otau-ledvance/run +./deconz/rootfs/etc/services.d/websockify/run @@ -10,0 +23,3 @@ +./dnsmasq/rootfs/etc/services.d/dnsmasq/run +./duckdns/rootfs/etc/s6-overlay/s6-rc.d/duckdns/finish +./duckdns/rootfs/etc/s6-overlay/s6-rc.d/duckdns/run @@ -13,0 +29 @@ +./google_assistant/rootfs/etc/services.d/google-assistant/run @@ -15,0 +32,12 @@ +./letsencrypt/rootfs/etc/services.d/lets-encrypt/run +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/finish +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-core/run +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-lock-core/finish +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-lock-core/run +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-lock-post/finish +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-lock-post/run +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-post/finish +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-post/run +./mariadb/rootfs/etc/s6-overlay/s6-rc.d/mariadb-pre/run +./mariadb/rootfs/usr/bin/lock-tables-for-backup +./mariadb/rootfs/usr/bin/unlock-tables-for-backup @@ -16,0 +45 @@ +./matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run @@ -17,0 +47 @@ +./matter_server/rootfs/etc/s6-overlay/scripts/matter-server-discovery @@ -20,0 +51 @@ +./mosquitto/rootfs/etc/services.d/mosquitto/discovery @@ -21,0 +53 @@ +./mosquitto/rootfs/etc/services.d/mosquitto/run @@ -22,0 +55,4 @@ +./mosquitto/rootfs/etc/services.d/nginx/run +./nginx_proxy/rootfs/etc/periodic/daily/check_certificate_renewal +./openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/mdns/finish +./openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/mdns/run @@ -23,0 +60,4 @@ +./openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/finish +./openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run +./openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/finish +./openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/run @@ -24,0 +65 @@ +./openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/run @@ -28,0 +70,7 @@ +./openthread_border_router/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up +./openwakeword/rootfs/etc/s6-overlay/s6-rc.d/discovery/run +./openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/finish +./openwakeword/rootfs/etc/s6-overlay/s6-rc.d/openwakeword/run +./piper/rootfs/etc/s6-overlay/s6-rc.d/discovery/run +./piper/rootfs/etc/s6-overlay/s6-rc.d/piper/finish +./piper/rootfs/etc/s6-overlay/s6-rc.d/piper/run @@ -29,0 +78,5 @@ +./samba/rootfs/etc/s6-overlay/s6-rc.d/init-smbd/run +./samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/finish +./samba/rootfs/etc/s6-overlay/s6-rc.d/nmbd/run +./samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/finish +./samba/rootfs/etc/s6-overlay/s6-rc.d/smbd/run @@ -31,0 +85,4 @@ +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/cpcd/finish +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/cpcd/run +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/mdns/finish +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/mdns/run @@ -32,0 +90,4 @@ +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/finish +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/finish +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/run @@ -33,0 +95,3 @@ +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/socat-cpcd-tcp/run +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/zigbeed/finish +./silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/zigbeed/run @@ -34,0 +99 @@ +./silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/cpcd-config-up @@ -38,0 +104 @@ +./silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up @@ -39,0 +106 @@ +./silabs_flasher/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up @@ -44,0 +112 @@ +./ssh/rootfs/etc/services.d/sshd/run @@ -45,0 +114 @@ +./ssh/rootfs/etc/services.d/ttyd/run @@ -46,0 +116,2 @@ +./ssh/rootfs/usr/local/bin/reboot +./ssh/rootfs/usr/local/bin/shutdown @@ -49,0 +121,8 @@ +./vlc/rootfs/etc/s6-overlay/s6-rc.d/nginx/finish +./vlc/rootfs/etc/s6-overlay/s6-rc.d/nginx/run +./vlc/rootfs/etc/s6-overlay/s6-rc.d/vlc/finish +./vlc/rootfs/etc/s6-overlay/s6-rc.d/vlc/run +./vlc/rootfs/etc/s6-overlay/scripts/vlc-discovery +./whisper/rootfs/etc/s6-overlay/s6-rc.d/discovery/run +./whisper/rootfs/etc/s6-overlay/s6-rc.d/whisper/finish +./whisper/rootfs/etc/s6-overlay/s6-rc.d/whisper/run @@ -51,0 +131 @@ +./zwave_js/rootfs/etc/services.d/zwave_js/discovery @@ -52,0 +133 @@ +./zwave_js/rootfs/etc/services.d/zwave_js/run ```

TODO:

Summary by CodeRabbit

coderabbitai[bot] commented 1 month ago
📝 Walkthrough
📝 Walkthrough ## Walkthrough The changes in this pull request primarily introduce new shellcheck directives across various shell scripts to enhance compatibility with static analysis tools. Additionally, a new Bash script for linting shell scripts is added, replacing an existing GitHub Action in the workflow configuration. Several existing scripts are updated to improve logging, exit code handling, and user configurations without altering their core functionalities. ## Changes | File Path | Change Summary | |---------------------------------------------------------------------------|---------------------------------------------------------------------------------------------------| | `.github/workflows/lint.sh` | New Bash script for scanning shell scripts using `shellcheck`. | | `.github/workflows/lint.yml` | Modified to run the new linting script instead of a pre-defined action. | | `cec_scan/rootfs/etc/services.d/cec-scan/finish` | Added shellcheck directive for Bash. | | `cec_scan/rootfs/etc/services.d/cec-scan/run` | Added shellcheck directive for Bash. | | `configurator/rootfs/etc/s6-overlay/s6-rc.d/configurator/run` | Added shellcheck directive for Bash. | | `deconz/rootfs/etc/cont-init.d/firmware.sh` | Added shellcheck directive for Bash. | | `deconz/rootfs/etc/cont-init.d/nginx.sh` | Added shellcheck directive for Bash. | | `deconz/rootfs/etc/cont-init.d/novnc.sh` | Added shellcheck directive for Bash and declared `ingress_entry` variable. | | `deconz/rootfs/etc/services.d/deconz/discovery` | Updated discovery logic and removed old data storage mechanism. | | `deconz/rootfs/etc/services.d/deconz/finish` | Added shellcheck directive for Bash and updated exit status check. | | `deconz/rootfs/etc/services.d/deconz/run` | Added shellcheck directive for Bash and updated architecture checks. | | `deconz/rootfs/etc/services.d/nginx/finish` | Added shellcheck directive for Bash. | | `deconz/rootfs/etc/services.d/nginx/run` | Added shellcheck directive for Bash. | | `deconz/rootfs/etc/services.d/otau-ikea/run` | Added shellcheck directive for Bash. | | `deconz/rootfs/etc/services.d/otau-ledvance/run` | Added shellcheck directive for Bash. | | `deconz/rootfs/etc/services.d/websockify/run` | Added shellcheck directive for Bash. | | `dhcp_server/data/run.sh` | Added shellcheck directive for Bash. | | `dnsmasq/rootfs/etc/cont-init.d/config.sh` | Added shellcheck directive for Bash. | | `dnsmasq/rootfs/etc/services.d/dnsmasq/finish` | Added shellcheck directive for Bash and updated exit status check. | | `dnsmasq/rootfs/etc/services.d/dnsmasq/run` | Added shellcheck directive for Bash. | | `duckdns/rootfs/etc/s6-overlay/s6-rc.d/duckdns/run` | Added shellcheck directive for Bash and introduced `le_renew` function for certificate renewal. | | `google_assistant/rootfs/etc/services.d/google-assistant/finish` | Added shellcheck directive for Bash and updated exit status check. | | `google_assistant/rootfs/etc/services.d/google-assistant/run` | Added shellcheck directive for Bash and improved credential handling. | | `letsencrypt/rootfs/etc/cont-init.d/file-structure.sh` | Added shellcheck directive for Bash. | | `letsencrypt/rootfs/etc/services.d/lets-encrypt/finish` | Added shellcheck directive for Bash. | | `letsencrypt/rootfs/etc/services.d/lets-encrypt/run` | Improved DNS provider handling and corrected syntax error. | | `matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/finish` | Added shellcheck directive for Bash and refined exit code handling. | | `matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run` | Added shellcheck directive for Bash and improved network interface detection. | | `matter_server/rootfs/etc/s6-overlay/scripts/banner.sh` | Added shellcheck directive for Bash. | | `matter_server/rootfs/etc/s6-overlay/scripts/matter-server-discovery` | Added shellcheck directive for Bash. | | `mosquitto/rootfs/etc/cont-init.d/mosquitto.sh` | Enhanced user management and SSL configuration. | | `mosquitto/rootfs/etc/services.d/mosquitto/discovery` | Added shellcheck directive for Bash. | | `mosquitto/rootfs/etc/services.d/mosquitto/finish` | Added shellcheck directive for Bash and updated exit status check. | | `mosquitto/rootfs/etc/services.d/mosquitto/run` | Added shellcheck directive for Bash. | | `nginx_proxy/rootfs/etc/periodic/daily/check_certificate_renewal` | Added shellcheck directive for Bash. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/mdns/finish` | Added shellcheck directive for Bash. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/mdns/run` | Added shellcheck directive for Bash. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/finish` | Added shellcheck directive for Bash and refined exit code handling. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run` | Enhanced functionality and configuration handling. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/finish` | Added shellcheck directive for Bash. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/run` | Added shellcheck directive for Bash and improved logging. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/cpcd/finish` | Added shellcheck directive for Bash. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/cpcd/run` | Added shellcheck directive for Bash. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/mdns/finish` | Added shellcheck directive for Bash. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/mdns/run` | Added shellcheck directive for Bash. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/zigbeed/finish` | Added shellcheck directive for Bash. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/zigbeed/run` | Added shellcheck directive for Bash. | | `ssh/rootfs/etc/cont-init.d/apks.sh` | Added shellcheck directive for Bash. | | `ssh/rootfs/etc/cont-init.d/keygen.sh` | Added shellcheck directive for Bash. | | `ssh/rootfs/etc/cont-init.d/profile.sh` | Added shellcheck directive for Bash. | | `ssh/rootfs/etc/cont-init.d/ssh.sh` | Added shellcheck directive for Bash and improved SSH configuration. | | `ssh/rootfs/etc/services.d/sshd/finish` | Added shellcheck directive for Bash and updated exit status check. | | `ssh/rootfs/etc/services.d/sshd/run` | Added shellcheck directive for Bash. | | `ssh/rootfs/etc/services.d/ttyd/finish` | Added shellcheck directive for Bash and updated exit status check. | | `ssh/rootfs/etc/services.d/ttyd/run` | Added shellcheck directive for Bash. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant GitHub Actions participant Linter participant Shell Scripts User->>GitHub Actions: Trigger Linting Workflow GitHub Actions->>Linter: Execute .github/workflows/lint.sh Linter->>Shell Scripts: Scan for Issues Shell Scripts-->>Linter: Return Results Linter-->>GitHub Actions: Report Results GitHub Actions-->>User: Display Linting 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://coderabbit.ai/docs) 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.
coderabbitai[bot] commented 1 month ago
📝 Walkthrough ## Walkthrough The changes in this pull request introduce a new shell script, `lint.sh`, for linting shell scripts using `shellcheck`, and modify the existing GitHub Actions workflow to utilize this script instead of a predefined action. Additionally, multiple scripts across various directories have been updated to include shellcheck directives for improved linting support. These updates enhance script compatibility with shellcheck without altering their core functionalities. ## Changes | File Path | Change Summary | |-----------------------------------------------------------------------------------------------|-----------------------------------------------------------------------------------------------------| | `.github/workflows/lint.sh` | New script added for linting shell scripts using `shellcheck`. | | `.github/workflows/lint.yml` | Modified to run the new `lint.sh` script instead of using `ludeeus/action-shellcheck@2.0.0`. | | `cec_scan/rootfs/etc/services.d/cec-scan/finish` | Added shellcheck directive to specify the script as Bash. | | `cec_scan/rootfs/etc/services.d/cec-scan/run` | Added shellcheck directive to specify the script as Bash. | | `configurator/rootfs/etc/s6-overlay/s6-rc.d/configurator/run` | Added shellcheck directive for compatibility. | | `deconz/rootfs/etc/cont-init.d/firmware.sh` | Added shellcheck directive for compatibility. | | `deconz/rootfs/etc/cont-init.d/nginx.sh` | Added shellcheck directive for compatibility. | | `deconz/rootfs/etc/cont-init.d/novnc.sh` | Added shellcheck directive for compatibility. | | `deconz/rootfs/etc/services.d/deconz/discovery` | Removed old discovery data storage and refined logic for obtaining bridge ID. | | `deconz/rootfs/etc/services.d/deconz/finish` | Added shellcheck directive and updated service failure checks. | | `deconz/rootfs/etc/services.d/deconz/run` | Added shellcheck directive and enhanced startup logic. | | `deconz/rootfs/etc/services.d/nginx/finish` | Added shellcheck directive and updated service failure checks. | | `deconz/rootfs/etc/services.d/nginx/run` | Added shellcheck directive for compatibility. | | `deconz/rootfs/etc/services.d/otau-ikea/run` | Added shellcheck directive for compatibility. | | `deconz/rootfs/etc/services.d/otau-ledvance/run` | New script added for downloading firmware updates for OSRAM Ledvance devices. | | `deconz/rootfs/etc/services.d/websockify/run` | Added shellcheck directive for compatibility. | | `dhcp_server/data/run.sh` | Added shellcheck directive for compatibility. | | `dnsmasq/rootfs/etc/cont-init.d/config.sh` | Added shellcheck directive for compatibility. | | `dnsmasq/rootfs/etc/services.d/dnsmasq/finish` | Added shellcheck directive and updated service failure checks. | | `dnsmasq/rootfs/etc/services.d/dnsmasq/run` | Added shellcheck directive for compatibility. | | `duckdns/rootfs/etc/s6-overlay/s6-rc.d/duckdns/run` | Added shellcheck directive and enhanced functionality for Let's Encrypt renewal. | | `google_assistant/rootfs/etc/services.d/google-assistant/finish` | Added shellcheck directive and updated service failure checks. | | `google_assistant/rootfs/etc/services.d/google-assistant/run` | Enhanced initialization and error handling for Google Assistant service. | | `letsencrypt/rootfs/etc/cont-init.d/file-structure.sh` | Enhanced configuration setup for various DNS providers. | | `letsencrypt/rootfs/etc/services.d/lets-encrypt/finish` | Added shellcheck directive for compatibility. | | `letsencrypt/rootfs/etc/services.d/lets-encrypt/run` | Corrected syntax error in appending arguments for DNS provider. | | `matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/finish` | Added shellcheck directive and updated exit code handling. | | `matter_server/rootfs/etc/s6-overlay/s6-rc.d/matter-server/run` | Enhanced startup process and configuration handling for Matter service. | | `matter_server/rootfs/etc/s6-overlay/scripts/banner.sh` | Added shellcheck directive for compatibility. | | `matter_server/rootfs/etc/s6-overlay/scripts/matter-server-discovery` | Added shellcheck directive for compatibility. | | `mosquitto/rootfs/etc/cont-init.d/mosquitto.sh` | Added shellcheck directive for compatibility. | | `mosquitto/rootfs/etc/cont-init.d/nginx.sh` | Added shellcheck directive for compatibility. | | `mosquitto/rootfs/etc/services.d/mosquitto/discovery` | Added shellcheck directive for compatibility. | | `mosquitto/rootfs/etc/services.d/mosquitto/finish` | Added shellcheck directive and updated service failure checks. | | `mosquitto/rootfs/etc/services.d/mosquitto/run` | Added shellcheck directive for compatibility. | | `nginx_proxy/rootfs/etc/periodic/daily/check_certificate_renewal` | Added shellcheck directive for improved linting. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/mdns/finish` | Added shellcheck directive for compatibility. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/mdns/run` | Added shellcheck directive for compatibility. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/finish` | Enhanced exit code handling and logging for the OTBR agent. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run` | Enhanced functionality and configuration handling for the OTBR agent. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/finish` | Added shellcheck directive for compatibility. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/run` | Enhanced startup process for the OTBR web interface. | | `openthread_border_router/rootfs/etc/s6-overlay/s6-rc.d/socat-otbr-tcp/run` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/cont-init.d/check-cpcd-shm.sh` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/cpcd/finish` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/cpcd/run` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/mdns/finish` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/mdns/run` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/finish` | Enhanced exit code handling and logging for the OTBR agent. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-agent/run` | Enhanced functionality and configuration handling for the OTBR agent. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/finish` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/otbr-web/run` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/socat-cpcd-tcp/run` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/zigbeed/finish` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/s6-rc.d/zigbeed/run` | Enhanced startup process for the Zigbee daemon. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/banner.sh` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/cpcd-config-up` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/otbr-agent-rest-discovery.sh` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/otbr-enable-check.sh` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/socat-cpcd-tcp-enable-check.sh` | Added shellcheck directive for compatibility. | | `silabs-multiprotocol/rootfs/etc/s6-overlay/scripts/universal-silabs-flasher-up` | Enhanced functionality for firmware flashing processes. | | `ssh/rootfs/etc/cont-init.d/apks.sh` | Added shellcheck directive for compatibility. | | `ssh/rootfs/etc/cont-init.d/keygen.sh` | Added shellcheck directive for compatibility. | | `ssh/rootfs/etc/cont-init.d/profile.sh` | Enhanced user environment setup and file management. | | `ssh/rootfs/etc/cont-init.d/ssh.sh` | Enhanced SSH setup and user management functionality. | | `ssh/rootfs/etc/services.d/sshd/finish` | Added shellcheck directive for compatibility. | | `ssh/rootfs/etc/services.d/sshd/run` | Added shellcheck directive for compatibility. | ## Sequence Diagram(s) ```mermaid sequenceDiagram participant User participant GitHub Actions participant lint.sh participant shellcheck User->>GitHub Actions: Trigger Workflow GitHub Actions->>lint.sh: Execute lint.sh lint.sh->>shellcheck: Run shellcheck on scripts shellcheck-->>lint.sh: Return linting results lint.sh-->>GitHub Actions: Output results GitHub Actions-->>User: Display 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://coderabbit.ai/docs) 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.
agners commented 1 month ago

I've actually just considered this as well. However, introducing scripts here seems a bit too heavy, also since there are other repositories which could profit from linting the s6 run scripts (e.g. addons-development). Maybe this could be a separate GitHub action at https://github.com/home-assistant/actions.

I've also seen that the current action supports this:

     ...
     with:
       additional_files: 'run finish'

that might be a easy start.

mislav commented 1 month ago

Maybe this could be a separate GitHub action at https://github.com/home-assistant/actions.

I'm up for extracting this (or something else that achieves the same) as an action. It's a good idea.

I've also seen that the current action supports this:

I've also seen the additional_files feature during my dive into ludeeus/action-shellcheck, but I decided against using it. First of all, it only takes a list of basenames, not full file paths, which I found odd, and matches the names as suffixes to the file name rather than the full name, which is either a bug or a bizarre choice. Second, with this approach we'd have to explicitly allow-list future scripts with unique file names into the linting process, which would be easy to forget. The main point of my PR is that any existing and new scripts in this repository would automatically get linted.

Lastly, the ludeeus/action-shellcheck actions offers barely any features that are useful to this project, and in my opinion it just places a level of indirection over the linting process that makes it harder to check what's going on. If it offered a way to change its arcane shebang regex as an option rather than list additional basenames to be checked, it would have been more useful, but here I'm proposing to stop using that action in favor of an in-house approach.

agners commented 1 month ago

but here I'm proposing to stop using that action in favor of an in-house approach.

I must say, ludeeus started hacs, and is quite active in the community, so it semi in-house :smile:

I've just checked, we have at least 4 repos which use ludeeus' shellcheck action right now, we definitely want to share the logic in some way or another. I think I'd prefer to extend his action if it is not too far off from what we need. :thinking:

His shellcheck GH action seems to have quite some traction also outside of the HA community, so your improvements might be beneficial to more people (and vise-versa, other people's improvement might benefit us).

mislav commented 1 month ago

I must say, ludeeus started hacs, and is quite active in the community, so it semi in-house 😄

Ah okay, that is useful context! Thanks for the feedback. I am going to open an alternative PR to this one but that sticks with the same action.