[PR #1423] [MERGED] GitHub Actions: Fix Shellsheck workflow to only run on changes *.sh files #3022

Closed
opened 2025-11-20 05:33:03 -05:00 by saavagebueno · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/community-scripts/ProxmoxVE/pull/1423
Author: @andygrunwald
Created: 1/11/2025
Status: Merged
Merged: 1/13/2025
Merged by: @MickLesk

Base: mainHead: fix-shellcheck-ci-changed-files


📝 Commits (1)

  • 7e98388 GitHub Actions: Fix Shellsheck workflow to only run on changes *.sh files

📊 Changes

1 file changed (+36 additions, -6 deletions)

View changed files

📝 .github/workflows/shellcheck.yml (+36 -6)

📄 Description

✍️ Description

The Shellcheck GitHub Action workflow is not running. It throws an error in the "Get changed files" step:

Run if true; then
fatal: ambiguous argument 'HEAD^1': unknown revision or path not in the working tree.
Use '--' to separate paths from revisions, like this:
'git <command> [<revision>...] -- [<file>...]'

See https://github.com/community-scripts/ProxmoxVE/actions/runs/12724031265/job/35469760341

This Pull Request is using the same "Get changes files" logic from another workflow: cc40b5957d/.github/workflows/validate-filenames.yml (L36-L43)

Why this change?

The current way can't work. E.g. in a119a27b4f (diff-549859aac5bcaebdf605d3ffd525377f2b314b5cc6eb4ebad490bd2cc52617a7L21), the action ludeeus/action-shellcheck was removed and shellcheck was executed directly. But shellcheck was never installed. This was never caught, as we never entered this step (due to the error above).

Right now, we don't use ludeeus/action-shellcheck as this repository requires to only run Shellcheck on changed files (due to the amount of warnings). The ludeeus/action-shellcheck action doesn't support an "only run on those files" input.
We mitigate this by using the same code as the ludeeus/action-shellcheck action to install shellcheck. Then, we run it ourselves. This is a (temp) workaround until this repo is shellcheck warning free.

Additionally we introduce https://github.com/marketplace/actions/changed-files to detect changed-files. The latest change (see b8671b97af) on the changed files detection also proved that this doesn't seem to be straightforward.
As Github action is used only in the Github env and not locally, I think it make sense to use an existing codebase that is proven.

⚠️ See the testing note below - The action tj-actions/changed-files need to be approved by Repo admins.


🛠️ Type of Change

  • 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

  • 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)

⚠️ A note on testing

Testing is / was partially possible.
The github action "" needs to be approved by Repository admins:

tj-actions/changed-files@v45 is not allowed to be used in community-scripts/ProxmoxVE. Actions in this workflow must be: within a repository owned by community-scripts, created by GitHub, or matching the following: ludeeus/action-shellcheck@*.


📋 Additional Information (optional)


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/community-scripts/ProxmoxVE/pull/1423 **Author:** [@andygrunwald](https://github.com/andygrunwald) **Created:** 1/11/2025 **Status:** ✅ Merged **Merged:** 1/13/2025 **Merged by:** [@MickLesk](https://github.com/MickLesk) **Base:** `main` ← **Head:** `fix-shellcheck-ci-changed-files` --- ### 📝 Commits (1) - [`7e98388`](https://github.com/community-scripts/ProxmoxVE/commit/7e98388ae1a9f25aa155755377e44cf2b2f5ecab) GitHub Actions: Fix Shellsheck workflow to only run on changes `*.sh` files ### 📊 Changes **1 file changed** (+36 additions, -6 deletions) <details> <summary>View changed files</summary> 📝 `.github/workflows/shellcheck.yml` (+36 -6) </details> ### 📄 Description ## ✍️ Description The Shellcheck GitHub Action workflow is not running. It throws an error in the "Get changed files" step: ```sh Run if true; then fatal: ambiguous argument 'HEAD^1': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' ``` See https://github.com/community-scripts/ProxmoxVE/actions/runs/12724031265/job/35469760341 This Pull Request is using the same "Get changes files" logic from another workflow: https://github.com/community-scripts/ProxmoxVE/blob/cc40b5957d6fc96441875b9c61b4d116a4825b49/.github/workflows/validate-filenames.yml#L36-L43 ### Why this change? The current way can't work. E.g. in https://github.com/community-scripts/ProxmoxVE/commit/a119a27b4f969d192dfcb66b4b0e034bf38e1a99#diff-549859aac5bcaebdf605d3ffd525377f2b314b5cc6eb4ebad490bd2cc52617a7L21, the action `ludeeus/action-shellcheck` was removed and `shellcheck` was executed directly. But `shellcheck` was never installed. This was never caught, as we never entered this step (due to the error above). Right now, we don't use `ludeeus/action-shellcheck` as this repository requires to only run Shellcheck on changed files (due to the amount of warnings). The `ludeeus/action-shellcheck` action doesn't support an "only run on those files" input. We mitigate this by using the same code as the `ludeeus/action-shellcheck` action to install shellcheck. Then, we run it ourselves. This is a (temp) workaround until this repo is shellcheck warning free. Additionally we introduce https://github.com/marketplace/actions/changed-files to detect changed-files. The latest change (see https://github.com/community-scripts/ProxmoxVE/commit/b8671b97af2b6070f840ac8e719c80c0d4d5dda3) on the changed files detection also proved that this doesn't seem to be straightforward. As Github action is used only in the Github env and not locally, I think it make sense to use an existing codebase that is proven. ⚠️ See the testing note below - The action `tj-actions/changed-files` need to be approved by Repo admins. --- ## 🛠️ Type of Change - [X] 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 - [X] 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) ### ⚠️ A note on testing Testing is / was partially possible. The github action "" needs to be approved by Repository admins: > tj-actions/changed-files@v45 is not allowed to be used in community-scripts/ProxmoxVE. Actions in this workflow must be: within a repository owned by community-scripts, created by GitHub, or matching the following: ludeeus/action-shellcheck@*. --- ## 📋 Additional Information (optional) - --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
saavagebueno added the pull-request label 2025-11-20 05:33:03 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: SVI/ProxmoxVE#3022