Run shellcheck on build_linux.sh and add it to workflows (#10317)

* Shellcheck on build_linux.sh and tiny refactor

`shellcheck -e SC1090 build_linux.sh` and fixed the issues.

Also fixed the usage command to return an error, simplify directory
creation to use `mkdir -p`, and made printing of the cmake commands
consistent instead of having three different ways of doing it.

* Reorder functions in more pleasing way

* Add shellcheck to workflows

This is the beginning of adding some safety nets for making
changes. Currently it just runs shellcheck against `build_linux.sh`.

You can see it working at
https://github.com/coryrc/OrcaSlicer/actions/workflows/shellcheck.yml
I forked and tested it running in PRs and against pushes to HEAD.

* Rerun shellcheck

Missed quotes on the merge
This commit is contained in:
coryrc 2025-08-24 07:26:14 -04:00 committed by GitHub
parent 7dfce56fbb
commit 09034d87b7
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 85 additions and 45 deletions

38
.github/workflows/shellcheck.yml vendored Normal file
View file

@ -0,0 +1,38 @@
on:
push:
paths:
- build_linux.sh
pull_request:
paths:
- build_linux.sh
workflow_dispatch: # allows for manual dispatch
name: "Shellcheck"
permissions: {}
jobs:
shellcheck:
name: Shellcheck
runs-on: ubuntu-latest
steps:
- name: Cache shellcheck download
id: cache-shellcheck-v0_11
uses: actions/cache@v4
with:
path: ~/shellcheck
key: ${{ runner.os }}-shellcheck-v0_11
- name: Download shellcheck
if: steps.cache-shellcheck-v0_11.outputs.cache-hit != 'true'
shell: bash
env:
INPUT_VERSION: "v0.11.0"
run: |
curl -L#o ~/sc.tar.xz "https://github.com/koalaman/shellcheck/releases/download/${INPUT_VERSION}/shellcheck-${INPUT_VERSION}.linux.x86_64.tar.xz"
tar -xvf ~/sc.tar.xz -C ~
mv ~/shellcheck-"${INPUT_VERSION}"/shellcheck ~/shellcheck
- uses: actions/checkout@v4
- name: Shellcheck build_linux.sh
run: ~/shellcheck -e SC1090 build_linux.sh