Skip to content

Commit 7e8a892

Browse files
justin808claude
andcommitted
Address PR review feedback for precompile check workflow
Changes based on CodeRabbit review comments: 1. Capture rake exit code with PIPESTATUS to detect silent failures - Added set -o pipefail to propagate pipe failures - Check PIPESTATUS[0] after tee to catch rake failures 2. Improved duplicate webpack compilation detection - Changed pattern from generic "Compiled" to "Compiled successfully" - Simplified logic to count successful compilations directly - Added line numbers to matching output for debugging 3. Improved webpack error pattern detection - Changed from overly broad "error in" to more specific patterns - Now matches: webpack.*error, failed to compile, compilation failed, ERROR in 4. Better Ruby error detection - Pattern now matches error class format with colon (e.g., "NameError:") - Reduces false positives from log messages 5. Fixed asset pipeline error pattern - Use proper casing for Sprockets::FileNotFound 6. Added sample output for all error patterns - Each error now shows the first few matching lines for easier debugging 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent dc4c429 commit 7e8a892

File tree

1 file changed

+35
-13
lines changed

1 file changed

+35
-13
lines changed

.github/workflows/precompile-check.yml

Lines changed: 35 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,10 @@ jobs:
140140
echo "=========================================="
141141
142142
# Run precompile and capture both stdout and stderr
143+
# Use pipefail to catch rake failures even when piped through tee
144+
set -o pipefail
143145
RAILS_ENV=production bin/rake assets:precompile 2>&1 | tee precompile_output.txt
146+
PRECOMPILE_EXIT=${PIPESTATUS[0]}
144147
145148
echo "=========================================="
146149
echo "Precompile finished. Checking output for known issues..."
@@ -149,15 +152,20 @@ jobs:
149152
# Check for known failure patterns
150153
FAILURES_FOUND=0
151154
155+
# Check if rake command itself failed
156+
if [ "$PRECOMPILE_EXIT" -ne 0 ]; then
157+
echo "::error::Precompile command failed with exit code $PRECOMPILE_EXIT"
158+
FAILURES_FOUND=1
159+
fi
160+
152161
# Pattern 1: Duplicate webpack compilation (indicates rake tasks running twice)
153-
WEBPACK_COMPILE_COUNT=$(grep -c "Compiled" precompile_output.txt || true)
154-
if [ "$WEBPACK_COMPILE_COUNT" -gt 1 ]; then
155-
# Check if these are genuinely different compilations or duplicates
156-
# If the same "Compiled" message appears multiple times for the same bundle, it's a problem
157-
DUPLICATE_COMPILES=$(sort precompile_output.txt | uniq -d | grep -c "Compiled" || true)
158-
if [ "$DUPLICATE_COMPILES" -gt 0 ]; then
159-
echo "::error::FAILURE: Detected duplicate webpack compilations. Tasks may be running twice."
160-
echo " Found $DUPLICATE_COMPILES duplicate compilation messages."
162+
# Look for webpack's "Compiled successfully" message which appears once per compilation
163+
if grep -q "Compiled successfully" precompile_output.txt; then
164+
COMPILE_SUCCESS_COUNT=$(grep -c "Compiled successfully" precompile_output.txt || true)
165+
if [ "$COMPILE_SUCCESS_COUNT" -gt 1 ]; then
166+
echo "::error::FAILURE: Detected $COMPILE_SUCCESS_COUNT webpack compilations (expected 1). Tasks may be running twice."
167+
echo " Matching lines:"
168+
grep -n "Compiled successfully" precompile_output.txt | head -5
161169
FAILURES_FOUND=1
162170
fi
163171
fi
@@ -167,44 +175,58 @@ jobs:
167175
GENERATE_PACKS_COUNT=$(grep -c "react_on_rails:generate_packs" precompile_output.txt || true)
168176
if [ "$GENERATE_PACKS_COUNT" -gt 1 ]; then
169177
echo "::error::FAILURE: react_on_rails:generate_packs task ran $GENERATE_PACKS_COUNT times (should only run once)."
178+
echo " Matching lines:"
179+
grep -n "react_on_rails:generate_packs" precompile_output.txt
170180
FAILURES_FOUND=1
171181
fi
172182
fi
173183
174184
# Pattern 3: Module not found errors
175185
if grep -Ei "module not found|cannot find module|can't resolve" precompile_output.txt; then
176186
echo "::error::FAILURE: Module resolution errors detected in precompile output."
187+
echo " Sample matching lines:"
188+
grep -Ei "module not found|cannot find module|can't resolve" precompile_output.txt | head -3
177189
FAILURES_FOUND=1
178190
fi
179191
180-
# Pattern 4: Webpack build errors
181-
if grep -Ei "error in |failed to compile|compilation failed" precompile_output.txt; then
192+
# Pattern 4: Webpack build errors (use specific webpack error markers)
193+
if grep -Ei "webpack.*error|failed to compile|compilation failed|ERROR in" precompile_output.txt; then
182194
echo "::error::FAILURE: Webpack compilation errors detected."
195+
echo " Sample matching lines:"
196+
grep -Ei "webpack.*error|failed to compile|compilation failed|ERROR in" precompile_output.txt | head -3
183197
FAILURES_FOUND=1
184198
fi
185199
186-
# Pattern 5: Ruby/Rails errors during precompile
187-
if grep -Ei "NameError|LoadError|NoMethodError|SyntaxError" precompile_output.txt; then
200+
# Pattern 5: Ruby/Rails errors during precompile (match error class format)
201+
if grep -E "(NameError|LoadError|NoMethodError|SyntaxError):" precompile_output.txt; then
188202
echo "::error::FAILURE: Ruby errors detected during precompile."
203+
echo " Sample matching lines:"
204+
grep -E "(NameError|LoadError|NoMethodError|SyntaxError):" precompile_output.txt | head -3
189205
FAILURES_FOUND=1
190206
fi
191207
192208
# Pattern 6: Asset pipeline errors
193-
if grep -Ei "sprockets::filenotfound|asset .* was not declared" precompile_output.txt; then
209+
if grep -Ei "Sprockets::FileNotFound|Asset.*was not declared" precompile_output.txt; then
194210
echo "::error::FAILURE: Asset pipeline errors detected."
211+
echo " Sample matching lines:"
212+
grep -Ei "Sprockets::FileNotFound|Asset.*was not declared" precompile_output.txt | head -3
195213
FAILURES_FOUND=1
196214
fi
197215
198216
# Pattern 7: Memory issues
199217
if grep -Ei "javascript heap out of memory|killed|out of memory" precompile_output.txt; then
200218
echo "::error::FAILURE: Memory-related errors detected."
219+
echo " Sample matching lines:"
220+
grep -Ei "javascript heap out of memory|killed|out of memory" precompile_output.txt | head -3
201221
FAILURES_FOUND=1
202222
fi
203223
204224
# Pattern 8: Check for warnings that might indicate problems
205225
WARNING_COUNT=$(grep -ci "warning" precompile_output.txt || true)
206226
if [ "$WARNING_COUNT" -gt 10 ]; then
207227
echo "::warning::High number of warnings detected: $WARNING_COUNT warnings found. Please review."
228+
echo " Sample warnings:"
229+
grep -i "warning" precompile_output.txt | head -5
208230
fi
209231
210232
if [ "$FAILURES_FOUND" -eq 1 ]; then

0 commit comments

Comments
 (0)