Skip to content

Commit ded7355

Browse files
GeneAIclaude
authored andcommitted
fix(ci): Fix tier pattern analysis workflow shell errors
Resolves bash conditional errors in tier-pattern-analysis.yml: - Fixed "[: too many arguments" error by removing bc dependency - Use awk for floating point comparison instead of bc - Add head -n1 to ensure single value extraction - Add regex validation for SAVINGS variable - Properly quote $GITHUB_OUTPUT variable references - Add fallback to 0 if extraction fails This fixes the workflow errors: - "Error: Unable to process file command 'output' successfully" - "Error: Invalid format '81.2'" - "[: too many arguments" on line 55 Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
1 parent 9d0cf20 commit ded7355

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

.github/workflows/tier-pattern-analysis.yml

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -47,16 +47,23 @@ jobs:
4747
id: check
4848
run: |
4949
# Extract savings percentage from report
50-
SAVINGS=$(grep "Savings percentage:" pattern_analysis_report.txt | awk '{print $3}' | tr -d '%')
50+
SAVINGS=$(grep "Savings percentage:" pattern_analysis_report.txt | awk '{print $3}' | tr -d '%' | head -n1)
51+
52+
# Validate SAVINGS is a number
53+
if ! [[ "$SAVINGS" =~ ^[0-9]+\.?[0-9]*$ ]]; then
54+
echo "Warning: Could not extract valid savings percentage, defaulting to 0"
55+
SAVINGS="0"
56+
fi
57+
5158
echo "Current savings: $SAVINGS%"
52-
echo "savings=$SAVINGS" >> $GITHUB_OUTPUT
59+
echo "savings=$SAVINGS" >> "$GITHUB_OUTPUT"
5360
54-
# Set alert if savings drop below 85%
55-
if [ $(echo "$SAVINGS < 85" | bc) -eq 1 ]; then
56-
echo "alert=true" >> $GITHUB_OUTPUT
61+
# Set alert if savings drop below 85% (using awk for floating point comparison)
62+
if awk "BEGIN {exit !($SAVINGS < 85)}"; then
63+
echo "alert=true" >> "$GITHUB_OUTPUT"
5764
echo "⚠️ Savings dropped below 85%!"
5865
else
59-
echo "alert=false" >> $GITHUB_OUTPUT
66+
echo "alert=false" >> "$GITHUB_OUTPUT"
6067
echo "✅ Savings healthy at $SAVINGS%"
6168
fi
6269

0 commit comments

Comments
 (0)