mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-01-26 19:09:52 +00:00
ci: add shellcheck linter for ci scripts (#7331)
## Summary Adds [shellcheck](https://www.shellcheck.net/) to the PR linting CI steps -- when a PR has changed a `*.sh` file. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7331-ci-add-shellcheck-linter-for-ci-scripts-2c66d73d365081be889bf256cde92281) by [Unito](https://www.unito.io)
This commit is contained in:
26
.github/workflows/ci-shell-validation.yaml
vendored
Normal file
26
.github/workflows/ci-shell-validation.yaml
vendored
Normal file
@@ -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
|
||||||
19
scripts/cicd/check-shell.sh
Executable file
19
scripts/cicd/check-shell.sh
Executable file
@@ -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[@]}"
|
||||||
@@ -74,7 +74,7 @@ deploy_report() {
|
|||||||
|
|
||||||
|
|
||||||
# Project name with dots converted to dashes for Cloudflare
|
# Project name with dots converted to dashes for Cloudflare
|
||||||
sanitized_browser=$(echo "$browser" | sed 's/\./-/g')
|
sanitized_browser="${browser//./-}"
|
||||||
project="comfyui-playwright-${sanitized_browser}"
|
project="comfyui-playwright-${sanitized_browser}"
|
||||||
|
|
||||||
echo "Deploying $browser to project $project on branch $branch..." >&2
|
echo "Deploying $browser to project $project on branch $branch..." >&2
|
||||||
@@ -208,7 +208,7 @@ else
|
|||||||
|
|
||||||
# Wait for all deployments to complete
|
# Wait for all deployments to complete
|
||||||
for pid in $pids; do
|
for pid in $pids; do
|
||||||
wait $pid
|
wait "$pid"
|
||||||
done
|
done
|
||||||
|
|
||||||
# Collect URLs and counts in order
|
# Collect URLs and counts in order
|
||||||
@@ -254,9 +254,9 @@ else
|
|||||||
total_tests=0
|
total_tests=0
|
||||||
|
|
||||||
# Parse counts and calculate totals
|
# Parse counts and calculate totals
|
||||||
IFS='|'
|
IFS='|' read -r -a counts_array <<< "$all_counts"
|
||||||
set -- $all_counts
|
for counts_json in "${counts_array[@]}"; do
|
||||||
for counts_json; do
|
[ -z "$counts_json" ] && continue
|
||||||
if [ "$counts_json" != "{}" ] && [ -n "$counts_json" ]; then
|
if [ "$counts_json" != "{}" ] && [ -n "$counts_json" ]; then
|
||||||
# Parse JSON counts using simple grep/sed if jq is not available
|
# Parse JSON counts using simple grep/sed if jq is not available
|
||||||
if command -v jq > /dev/null 2>&1; then
|
if command -v jq > /dev/null 2>&1; then
|
||||||
@@ -324,13 +324,12 @@ $status_icon **$status_text**
|
|||||||
|
|
||||||
# Add browser results with individual counts
|
# Add browser results with individual counts
|
||||||
i=0
|
i=0
|
||||||
IFS='|'
|
IFS=' ' read -r -a browser_array <<< "$BROWSERS"
|
||||||
set -- $all_counts
|
IFS=' ' read -r -a url_array <<< "$urls"
|
||||||
for counts_json; do
|
for counts_json in "${counts_array[@]}"; do
|
||||||
# Get browser name
|
[ -z "$counts_json" ] && { i=$((i + 1)); continue; }
|
||||||
browser=$(echo "$BROWSERS" | cut -d' ' -f$((i + 1)))
|
browser="${browser_array[$i]:-}"
|
||||||
# Get URL at position i
|
url="${url_array[$i]:-}"
|
||||||
url=$(echo "$urls" | cut -d' ' -f$((i + 1)))
|
|
||||||
|
|
||||||
if [ "$url" != "failed" ] && [ -n "$url" ]; then
|
if [ "$url" != "failed" ] && [ -n "$url" ]; then
|
||||||
# Parse individual browser counts
|
# 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."
|
🎉 Click on the links above to view detailed test results for each browser configuration."
|
||||||
|
|
||||||
post_comment "$comment"
|
post_comment "$comment"
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user