diff --git a/.github/workflows/ci-shell-validation.yaml b/.github/workflows/ci-shell-validation.yaml new file mode 100644 index 000000000..783d1b03c --- /dev/null +++ b/.github/workflows/ci-shell-validation.yaml @@ -0,0 +1,26 @@ +# Description: Runs shellcheck on tracked shell scripts when they change +name: "CI: Shell Validation" + +on: + push: + branches: + - main + paths: + - '**/*.sh' + pull_request: + paths: + - '**/*.sh' + +jobs: + shell-lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - name: Install shellcheck + run: | + sudo apt-get update + sudo apt-get install -y shellcheck + + - name: Run shellcheck + run: bash ./scripts/cicd/check-shell.sh diff --git a/scripts/cicd/check-shell.sh b/scripts/cicd/check-shell.sh new file mode 100755 index 000000000..a95bcde28 --- /dev/null +++ b/scripts/cicd/check-shell.sh @@ -0,0 +1,19 @@ +#!/usr/bin/env bash +set -euo pipefail + +ROOT_DIR="$(git rev-parse --show-toplevel)" +cd "$ROOT_DIR" + +if ! command -v shellcheck >/dev/null 2>&1; then + echo "Error: shellcheck is required but not installed" >&2 + exit 127 +fi + +mapfile -t shell_files < <(git ls-files -- '*.sh') + +if [[ ${#shell_files[@]} -eq 0 ]]; then + echo 'No shell scripts found.' + exit 0 +fi + +shellcheck --format=gcc "${shell_files[@]}" diff --git a/scripts/cicd/pr-playwright-deploy-and-comment.sh b/scripts/cicd/pr-playwright-deploy-and-comment.sh index aeab37c8e..840203f44 100755 --- a/scripts/cicd/pr-playwright-deploy-and-comment.sh +++ b/scripts/cicd/pr-playwright-deploy-and-comment.sh @@ -74,7 +74,7 @@ deploy_report() { # Project name with dots converted to dashes for Cloudflare - sanitized_browser=$(echo "$browser" | sed 's/\./-/g') + sanitized_browser="${browser//./-}" project="comfyui-playwright-${sanitized_browser}" echo "Deploying $browser to project $project on branch $branch..." >&2 @@ -208,7 +208,7 @@ else # Wait for all deployments to complete for pid in $pids; do - wait $pid + wait "$pid" done # Collect URLs and counts in order @@ -254,9 +254,9 @@ else total_tests=0 # Parse counts and calculate totals - IFS='|' - set -- $all_counts - for counts_json; do + IFS='|' read -r -a counts_array <<< "$all_counts" + for counts_json in "${counts_array[@]}"; do + [ -z "$counts_json" ] && continue if [ "$counts_json" != "{}" ] && [ -n "$counts_json" ]; then # Parse JSON counts using simple grep/sed if jq is not available if command -v jq > /dev/null 2>&1; then @@ -324,13 +324,12 @@ $status_icon **$status_text** # Add browser results with individual counts i=0 - IFS='|' - set -- $all_counts - for counts_json; do - # Get browser name - browser=$(echo "$BROWSERS" | cut -d' ' -f$((i + 1))) - # Get URL at position i - url=$(echo "$urls" | cut -d' ' -f$((i + 1))) + IFS=' ' read -r -a browser_array <<< "$BROWSERS" + IFS=' ' read -r -a url_array <<< "$urls" + for counts_json in "${counts_array[@]}"; do + [ -z "$counts_json" ] && { i=$((i + 1)); continue; } + browser="${browser_array[$i]:-}" + url="${url_array[$i]:-}" if [ "$url" != "failed" ] && [ -n "$url" ]; then # Parse individual browser counts @@ -374,4 +373,4 @@ $status_icon **$status_text** 🎉 Click on the links above to view detailed test results for each browser configuration." post_comment "$comment" -fi \ No newline at end of file +fi