Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions .github/workflows/shell-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,8 @@ jobs:
runs-on: ubuntu-latest
if: "!contains(github.event.pull_request.title, '[bot]')"
steps:
- name: Get checkout depth
run: |
echo "PR_FETCH_DEPTH=$(( ${{ github.event.pull_request.commits }} + 10 ))" >> $GITHUB_ENV

- name: Checkout code
uses: NVIDIA/spark-rapids-common/checkout@main
with:
fetch-depth: ${{ env.PR_FETCH_DEPTH }}

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master

uses: NVIDIA/spark-rapids-common/shell-check@main
84 changes: 84 additions & 0 deletions shell-check/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# Copyright (c) 2025, NVIDIA CORPORATION.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: 'Shell Check'
description: 'Check shell syntax'
inputs:
excluded_codes:
description: "Excluded issue codes (comma-separated). e.g. SC2086,SC2046"
required: false
type: string
default: ""

runs:
using: "composite"
steps:
- name: Configure ShellCheck Options
shell: bash
run: |
base_excludes=(
# Double quote to prevent globbing and word splitting.
"SC2086"
# Quote this to prevent word splitting.
"SC2046"
# Declare and assign separately to avoid masking return values.
"SC2155"
# Use $(...) notation instead of legacy backticks `...`.
"SC2006"
# Variable referenced but not assigned
"SC2154"
# Ranges can only match single chars (mentioned due to duplicates).
"SC2102"
# Prefer mapfile or read -a to split command output (or quote to avoid splitting).
"SC2207"
# Note that A && B || C is not if-then-else. C may run when A is true.
"SC2015"
# Argument mixes string and array. Use * or separate argument.
"SC2145"
# Variable appears unused. Verify use (or export if used externally).
"SC2034"
# Not following: File was not specified as input (see shellcheck -x).
"SC1091"
# Don't use ls | grep. Use a glob or a for loop with a condition to allow non-alphanumeric filenames.
"SC2010"
# This does not export 'VAR'. Remove $/${} for that, or use ${var?} to quiet.
"SC2163"
# See if you can use ${variable//search/replace} instead.
"SC2001"
# Use find instead of ls to better handle non-alphanumeric filenames.
"SC2012"
# Expressions don't expand in single quotes, use double quotes for that.
"SC2016"
)
final_excludes=("${base_excludes[@]}")
if [ -n "${{ inputs.excluded_codes }}" ]; then
IFS=',' read -r -a user_excludes <<< "${{ inputs.excluded_codes }}"
final_excludes+=("${user_excludes[@]}")
fi
SHELLCHECK_OPTS=""
for code in "${final_excludes[@]}"; do
SHELLCHECK_OPTS+=" -e $code"
done

SHELLCHECK_OPTS="${SHELLCHECK_OPTS# }"

echo "SHELLCHECK_OPTS=$SHELLCHECK_OPTS" >> $GITHUB_ENV
env:
GITHUB_ENV: ${{ github.env_path }}

- name: Run ShellCheck
uses: ludeeus/action-shellcheck@master
env:
SHELLCHECK_OPTS: ${{ env.SHELLCHECK_OPTS }}

Loading