Skip to content

Commit 689c1b0

Browse files
fix: handle undefined shell variables in GitHub workflows
This improves the robustness of workflow scripts by adding default values for undefined count variables and adds a check_issues script for monitoring workflow patterns.
1 parent b9ecaa9 commit 689c1b0

File tree

3 files changed

+27
-1
lines changed

3 files changed

+27
-1
lines changed

.github/workflows/auto-copilot-code-cleanliness-review.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ jobs:
6060
! -path "*/build/*" \
6161
! -path "*/.venv/*" \
6262
! -path "*/vendor/*" \
63-
-exec sh -c 'count=$(grep -c "$1" "$2" 2>/dev/null || echo 0); if [ "$count" -gt 20 ]; then echo "$count definitions in $2"; fi' _ "$pattern" {} \; \
63+
-exec sh -c 'count=$(grep -c "$1" "$2" 2>/dev/null || echo 0); count=${count:-0}; if [ "$count" -gt 20 ]; then echo "$count definitions in $2"; fi' _ "$pattern" {} \; \
6464
2>/dev/null || true
6565
done | sort -rn >> /tmp/analysis.md
6666

.github/workflows/auto-copilot-functionality-docs-review.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,11 @@ jobs:
181181
class_count=$(grep -c "^class " "$file" 2>/dev/null || echo 0)
182182
docstring_count=$(grep -c '"""' "$file" 2>/dev/null || echo 0)
183183
184+
# Ensure variables are numeric
185+
func_count=${func_count:-0}
186+
class_count=${class_count:-0}
187+
docstring_count=${docstring_count:-0}
188+
184189
total=$((func_count + class_count))
185190
if [ $total -gt 0 ] && [ $docstring_count -eq 0 ]; then
186191
echo "⚠️ $file: $total definitions, no docstrings" >> /tmp/doc-analysis.md
@@ -202,6 +207,11 @@ jobs:
202207
class_count=$(grep -c "^class " "$file" 2>/dev/null || echo 0)
203208
jsdoc_count=$(grep -c '/\*\*' "$file" 2>/dev/null || echo 0)
204209
210+
# Ensure variables are numeric
211+
func_count=${func_count:-0}
212+
class_count=${class_count:-0}
213+
jsdoc_count=${jsdoc_count:-0}
214+
205215
total=$((func_count + class_count))
206216
if [ $total -gt 5 ] && [ $jsdoc_count -eq 0 ]; then
207217
echo "⚠️ $file: ~$total definitions, no JSDoc comments" >> /tmp/doc-analysis.md

check_issues.sh

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
echo "=== Searching for remaining shell arithmetic operations ==="
4+
grep -r '\$((.*))' .github/workflows/ || echo "No shell arithmetic found"
5+
6+
echo ""
7+
echo "=== Searching for remaining GitHub Copilot actions ==="
8+
grep -r 'github/copilot' .github/workflows/ || echo "No GitHub Copilot actions found"
9+
10+
echo ""
11+
echo "=== Searching for remaining shell arithmetic patterns ==="
12+
grep -r '\$(' .github/workflows/ | grep -E '(count|total).*=' || echo "No problematic patterns found"
13+
14+
echo ""
15+
echo "=== Checking for any uses: statements with copilot ==="
16+
grep -r 'uses:.*copilot' .github/workflows/ || echo "No copilot uses statements found"

0 commit comments

Comments
 (0)