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

[GitHub Actions] Introduce Shellcheck to check bash code #1018

Merged

Conversation

andygrunwald
Copy link
Contributor

@andygrunwald andygrunwald commented Dec 26, 2024

✍️ Description

ShellCheck finds bugs in your shell scripts. It is an open source tool (https://github.com/koalaman/shellcheck) that runs analysis on your shell scripts.

As this project uses shell and bash intensively, automated checks that help humans avoid bugs may be helpful.


🛠️ Type of Change

Please check the relevant options:

  • Bug fix (non-breaking change that resolves an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change unexpectedly)
  • New script (a fully functional and thoroughly tested script or set of scripts)

✅ Prerequisites

The following steps must be completed for the pull request to be considered:

  • Self-review performed (I have reviewed my code to ensure it follows established patterns and conventions.)
  • Testing performed (I have thoroughly tested my changes and verified expected functionality.)
  • Documentation updated (I have updated any relevant documentation)

📋 Additional Information (optional)

This PR might not be mergable from the get go as shellcheck throws a lot of errors on the repository itself.

Sometimes it throws "false positives" due to the way the scripts are written.
E.g. DISK${i}_REF vs. DISK1_REF:

In vm/ubuntu2404-vm.sh line 400:
  -scsi0 ${DISK1_REF},${DISK_CACHE}${THIN}size=2G \
         ^----------^ SC2086 (info): Double quote to prevent globbing and word splitting.
         ^----------^ SC2153 (info): Possible misspelling: DISK1_REF may not be assigned. Did you mean DISK_REF?

--
A full list of error codes and descriptions can be found here: https://www.shellcheck.net/wiki/

Those can be disables via

env:
    SHELLCHECK_OPTS: -e SC2059 -e SC2034 -e SC1090

@andygrunwald andygrunwald requested a review from a team as a code owner December 26, 2024 10:32
@github-actions github-actions bot added the maintenance Code maintenance or general upkeep of the project label Dec 26, 2024
@andygrunwald
Copy link
Contributor Author

Shellcheck itself can't run right now here, due to https://github.com/community-scripts/ProxmoxVE/actions/runs/12502825499

ludeeus/action-shellcheck@master is not allowed to be used in community-scripts/ProxmoxVE. Actions in this workflow must be: within a repository owned by community-scripts or created by GitHub.

@MickLesk MickLesk merged commit ff3d202 into community-scripts:main Dec 26, 2024
2 checks passed
dsiebel pushed a commit to dsiebel/ProxmoxVE that referenced this pull request Dec 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
maintenance Code maintenance or general upkeep of the project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants