Skip to content

Commit 11b22b7

Browse files
committed
fix(ci): address actionlint genuine findings surfaced by the new lint job
Six small, independent fixes for real issues that the newly-added actionlint/shellcheck job flagged in pre-existing workflow files. None of these are regressions from the recent refactor -- they've been latent for a while. Grouped because they're all the same class of work: "make lint pass green on meaningful findings." * gcp-publish.yml: drop `default: ''` from the `version_major` and `arch` `type: choice` inputs. An empty default isn't in either options list, so actionlint 'events' rejects it; GitHub's UI already pre-selects the first option regardless. * gcp-test.yml (Determine image to test): replace `elif [ "${{ inputs.arch == 'ALL' }}" ]; then` with `elif [ "${{ inputs.arch }}" = "ALL" ]; then`. The original has the GHA expression engine evaluate `arch == 'ALL'` to the literal string 'true' or 'false' before bash runs; bash's `[ "true" ]` and `[ "false" ]` are both non-empty-string tests (i.e. always true), so the elif always fired and the else branch was unreachable. No production impact today (both arms computed the same image_path), but it's a correctness trap waiting to bite a future edit. * gcp-test.yml (Run Google cloud-image-testing tests): drop the unreachable `${{ matrix.zone && format('-zone {0}', matrix.zone) || '' }}` line from the x86_64 per-shape job. That matrix only declares `shape:` -- the `include:` block that would carry `zone:` overrides is commented out (L218-222) with 'disabled, never any capacity available'. `matrix.zone` evaluated to null and the expression collapsed to an empty arg. The aarch64 matrix still carries and uses `zone:` entries unchanged. * azure-to-gallery.yml (Read the image info, Release the image to a Gallery): bind the GHA expressions `${{ env.IMAGE_FILE }}`, `${{ inputs.url_type }}`, `${{ inputs.dry-run-mode }}`, `${{ inputs.public_gallery }}`, `${{ env.RELEASE_VERSION }}` to local bash variables before using them in `[[ ... == ... ]]` and `case $var in` tests. actionlint's shellcheck integration sees the raw `${{ ... }}` template and trips SC2193 ('arguments can never be equal'); binding to shell variables gives shellcheck a real string to track and also eliminates a class of quoting/escaping foot-guns. * vagrant-publish.yml (Construct tag name): drop the unreachable `continue` after `echo "[Error]..." && exit 1`. Dead code; `exit 1` always runs. * ami-to-marketplace.yml (Get corresponded Product ID): add a scoped `# shellcheck disable=SC2195` with an explanatory comment. shellcheck can't track the two-step parameter expansion `${short_name% * *}` on the AMI `Name` field (e.g. 'AlmaLinux OS 9.6.20240619 x86_64' -> 'AlmaLinux OS') and mis-reports every case arm as 'pattern will never match the word.'
1 parent 0a79276 commit 11b22b7

5 files changed

Lines changed: 26 additions & 15 deletions

File tree

.github/workflows/ami-to-marketplace.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,12 @@ jobs:
6868
short_name="${{ fromJSON(env.AMI_JSON).Images[0].Name }}" && short_name="${short_name% * *}"
6969
version_major="${{ env.OS_VERSION }}" && version_major="${version_major%%.*}"
7070
71-
# List of AlmaLinux public products and their IDs
71+
# List of AlmaLinux public products and their IDs.
72+
# shellcheck can't track the '${short_name% * *}' expansion above and
73+
# incorrectly flags all arms as SC2195 'pattern will never match'.
74+
# The composed word is always 'AlmaLinux OS <major> <arch>' in practice
75+
# (verified by the AWS AMI Name field format for AlmaLinux images).
76+
# shellcheck disable=SC2195
7277
case "${short_name} ${version_major} ${{ env.AMI_ARCH }}" in
7378
"AlmaLinux OS 8 x86_64") PRODUCT_ID="c076b20a-2305-4771-823f-944909847a05" ;;
7479
"AlmaLinux OS 8 arm64") PRODUCT_ID="744775f7-4efd-4c75-ac32-eb2540b4030c" ;;

.github/workflows/azure-to-gallery.yml

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,16 +74,23 @@ jobs:
7474
7575
- name: Read the image info
7676
run: |
77+
# Bind the GHA expressions to local shell variables up front so the
78+
# later bash [[ ... ]] and case tests operate on real string values
79+
# rather than literal '${{ ... }}' templates (keeps shellcheck happy
80+
# and avoids surprises if anyone ever pokes the RHS through set -x).
81+
image_file='${{ env.IMAGE_FILE }}'
82+
url_type='${{ inputs.url_type }}'
83+
7784
# Capture version, timestamp and architecture
78-
case '${{ inputs.url_type }}' in
85+
case "$url_type" in
7986
RAW*)
8087
regex='-([0-9]+\.?[0-9]*)-([0-9]{8,9}(\.[0-9])?).*\.(x86_64|aarch64)'
81-
if [[ ${{ env.IMAGE_FILE }} =~ $regex ]]; then
88+
if [[ $image_file =~ $regex ]]; then
8289
release_version="${BASH_REMATCH[1]}"
8390
timestamp="${BASH_REMATCH[2]}"
8491
arch="${BASH_REMATCH[4]}"
8592
else
86-
echo "[Error] Could not parse '${{ env.IMAGE_FILE }}' file name!"
93+
echo "[Error] Could not parse '${image_file}' file name!"
8794
exit 1
8895
fi
8996
;;
@@ -93,19 +100,19 @@ jobs:
93100
regex_simple='almalinux-([0-9]+\.[0-9]+)-(x86_64|aarch64|arm64)\.([0-9]{8})'
94101
95102
# Modern .vhd files like AlmaLinux-10-Azure-10.0-20250529.0-64k.aarch64.vhd
96-
if [[ ${{ env.IMAGE_FILE }} =~ $regex_azure ]]; then
103+
if [[ $image_file =~ $regex_azure ]]; then
97104
release_version="${BASH_REMATCH[1]}"
98105
timestamp="${BASH_REMATCH[2]}"
99106
arch="${BASH_REMATCH[4]}"
100107
101108
# Legacy .vhd files like almalinux-9.6-arm64.20250522-01.vhd
102-
elif [[ ${{ env.IMAGE_FILE }} =~ $regex_simple ]]; then
109+
elif [[ $image_file =~ $regex_simple ]]; then
103110
release_version="${BASH_REMATCH[1]}"
104111
arch="${BASH_REMATCH[2]}"
105112
timestamp="${BASH_REMATCH[3]}"
106113
107114
else
108-
echo "[Error] Could not parse '${{ env.IMAGE_FILE }}' file name!"
115+
echo "[Error] Could not parse '${image_file}' file name!"
109116
exit 1
110117
fi
111118
;;
@@ -122,7 +129,7 @@ jobs:
122129
x86_64) image_type="default" ;;
123130
aarch64|arm64)
124131
image_type="arm64"
125-
[[ ${{ env.IMAGE_FILE }} == *-64k* ]] && image_type="arm64-64k"
132+
[[ $image_file == *-64k* ]] && image_type="arm64-64k"
126133
;;
127134
*) echo "[Error] Unknown architecture: $arch" ; exit 1 ;;
128135
esac
@@ -155,12 +162,15 @@ jobs:
155162
esac
156163
157164
# If dry-run-mode is false, then pass the -f option to upload to the Gallery
158-
[[ ${{ inputs.dry-run-mode }} == false ]] && \
165+
dry_run='${{ inputs.dry-run-mode }}'
166+
[[ "$dry_run" == false ]] && \
159167
release_options+=' -f'
160168
161169
# If public_gallery is true, then upload to 'almalinux' public Gallery
162170
# TODO: AlmaLinux 10 and Kitten are not released to the public Gallery
163-
[[ ${{ inputs.public_gallery }} == true ]] && [[ ${{ env.RELEASE_VERSION }} != "10"* ]] && \
171+
public_gallery='${{ inputs.public_gallery }}'
172+
release_version='${{ env.RELEASE_VERSION }}'
173+
[[ "$public_gallery" == true && "$release_version" != "10"* ]] && \
164174
release_options+=' -g almalinux'
165175
166176
./azure_uploader.sh ${release_options} \

.github/workflows/gcp-publish.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ on:
66
version_major:
77
description: 'AlmaLinux major version'
88
required: true
9-
default: ''
109
type: choice
1110
options:
1211
- 10-kitten
@@ -16,7 +15,6 @@ on:
1615
arch:
1716
description: 'Architecture we are publishing'
1817
required: true
19-
default: ''
2018
type: choice
2119
options:
2220
- x86_64

.github/workflows/gcp-test.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ jobs:
4444
if [ -n "${{ inputs.image_override }}" ]; then
4545
echo "Using image override: ${{ inputs.image_override }}"
4646
image_path="${{ inputs.image_override }}"
47-
elif [ "${{ inputs.arch == 'ALL' }}" ]; then
47+
elif [ "${{ inputs.arch }}" = "ALL" ]; then
4848
echo "Using version major: ${{ inputs.version_major }}"
4949
echo "Using all architectures"
5050
image_path="projects/almalinux-dev-images-469421/global/images/family/almalinux-${{ inputs.version_major }}"
@@ -262,7 +262,6 @@ jobs:
262262
-project almalinux-image-testing-469421 \
263263
-x86_shape ${{ matrix.shape }} \
264264
-parallel_count ${{ github.run_attempt > 1 && '1' || '1' }} \
265-
${{ matrix.zone && format('-zone {0}', matrix.zone) || '' }} \
266265
-filter '^(cvm|livemigrate|suspendresume|loadbalancer|guestagent|hostnamevalidation|imageboot|licensevalidation|network|security|hotattach|packagevalidation|ssh|metadata)$' \
267266
-images '${{ needs.init-data.outputs.image_path || inputs.image_override }}${{ inputs.image_override == '' && matrix.arch == 'aarch64' && '-arm64' || ''}}'
268267

.github/workflows/vagrant-publish.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ jobs:
7979
8080
else
8181
echo "[Error]: No pattern matched for '$image_file'" && exit 1
82-
continue
8382
fi
8483
8584
# Remap "vmware" to the correct Vagrant provider name "vmware_desktop"

0 commit comments

Comments
 (0)