@@ -132,7 +132,7 @@ jobs:
132132 run : cd react_on_rails/spec/dummy && pnpm run build:rescript
133133 - name : Generate file system-based packs
134134 run : cd react_on_rails/spec/dummy && RAILS_ENV=production bundle exec rake react_on_rails:generate_packs
135- - name : Run assets:precompile and check output
135+ - name : Run assets:precompile and capture output
136136 run : |
137137 cd react_on_rails/spec/dummy
138138
@@ -146,139 +146,14 @@ jobs:
146146 PRECOMPILE_EXIT=${PIPESTATUS[0]}
147147
148148 echo "=========================================="
149- echo "Precompile finished. Checking output for known issues..."
150- echo ""
151-
152- # Check for known failure patterns
153- FAILURES_FOUND=0
154149
155150 # Check if rake command itself failed
156151 if [ "$PRECOMPILE_EXIT" -ne 0 ]; then
157152 echo "::error::Precompile command failed with exit code $PRECOMPILE_EXIT"
158- FAILURES_FOUND=1
159- fi
160-
161- # Pattern 1: Duplicate webpack compilation (indicates rake tasks running twice)
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
169- FAILURES_FOUND=1
170- fi
171- fi
172-
173- # Pattern 2: Duplicate task execution messages (generate_packs)
174- if grep -q "react_on_rails:generate_packs" precompile_output.txt; then
175- GENERATE_PACKS_COUNT=$(grep -c "react_on_rails:generate_packs" precompile_output.txt || true)
176- if [ "$GENERATE_PACKS_COUNT" -gt 1 ]; then
177- 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
180- FAILURES_FOUND=1
181- fi
182- fi
183-
184- # Pattern 2b: Duplicate locale generation
185- if grep -q "react_on_rails:locale" precompile_output.txt; then
186- LOCALE_COUNT=$(grep -c "react_on_rails:locale" precompile_output.txt || true)
187- if [ "$LOCALE_COUNT" -gt 1 ]; then
188- echo "::error::FAILURE: react_on_rails:locale task ran $LOCALE_COUNT times (should only run once)."
189- echo " Matching lines:"
190- grep -n "react_on_rails:locale" precompile_output.txt
191- FAILURES_FOUND=1
192- fi
193- fi
194-
195- # Pattern 2c: Duplicate webpack builds (check "Built at:" messages)
196- BUILT_AT_COUNT=$(grep -c "Built at:" precompile_output.txt || true)
197- if [ "$BUILT_AT_COUNT" -gt 1 ]; then
198- echo "::error::FAILURE: Detected $BUILT_AT_COUNT webpack builds (expected 1). Tasks may be running twice."
199- echo " Matching lines:"
200- grep -n "Built at:" precompile_output.txt | head -5
201- FAILURES_FOUND=1
202- fi
203-
204- # Pattern 3: Module not found errors
205- if grep -Ei "module not found|cannot find module|can't resolve" precompile_output.txt; then
206- echo "::error::FAILURE: Module resolution errors detected in precompile output."
207- echo " Sample matching lines:"
208- grep -Ei "module not found|cannot find module|can't resolve" precompile_output.txt | head -3
209- FAILURES_FOUND=1
210- fi
211-
212- # Pattern 3b: ENOENT errors (missing files/directories)
213- if grep -q "Error: ENOENT" precompile_output.txt; then
214- echo "::error::FAILURE: Missing file or directory errors detected."
215- echo " Sample matching lines:"
216- grep -n "Error: ENOENT" precompile_output.txt | head -3
217- FAILURES_FOUND=1
218- fi
219-
220- # Pattern 4: Webpack build errors (use specific webpack error markers)
221- if grep -Ei "webpack.*error|failed to compile|compilation failed|ERROR in" precompile_output.txt; then
222- echo "::error::FAILURE: Webpack compilation errors detected."
223- echo " Sample matching lines:"
224- grep -Ei "webpack.*error|failed to compile|compilation failed|ERROR in" precompile_output.txt | head -3
225- FAILURES_FOUND=1
153+ exit "$PRECOMPILE_EXIT"
226154 fi
227-
228- # Pattern 5: Ruby/Rails errors during precompile (match error class format)
229- if grep -E "(NameError|LoadError|NoMethodError|SyntaxError):" precompile_output.txt; then
230- echo "::error::FAILURE: Ruby errors detected during precompile."
231- echo " Sample matching lines:"
232- grep -E "(NameError|LoadError|NoMethodError|SyntaxError):" precompile_output.txt | head -3
233- FAILURES_FOUND=1
234- fi
235-
236- # Pattern 6: Asset pipeline errors
237- if grep -Ei "Sprockets::FileNotFound|Asset.*was not declared" precompile_output.txt; then
238- echo "::error::FAILURE: Asset pipeline errors detected."
239- echo " Sample matching lines:"
240- grep -Ei "Sprockets::FileNotFound|Asset.*was not declared" precompile_output.txt | head -3
241- FAILURES_FOUND=1
242- fi
243-
244- # Pattern 7: Memory issues
245- if grep -Ei "javascript heap out of memory|killed|out of memory" precompile_output.txt; then
246- echo "::error::FAILURE: Memory-related errors detected."
247- echo " Sample matching lines:"
248- grep -Ei "javascript heap out of memory|killed|out of memory" precompile_output.txt | head -3
249- FAILURES_FOUND=1
250- fi
251-
252- # Pattern 8: Check for warnings that might indicate problems
253- WARNING_COUNT=$(grep -ci "warning" precompile_output.txt || true)
254- if [ "$WARNING_COUNT" -gt 10 ]; then
255- echo "::warning::High number of warnings detected: $WARNING_COUNT warnings found. Please review."
256- echo " Sample warnings:"
257- grep -i "warning" precompile_output.txt | head -5
258- fi
259-
260- # Pattern 9: Deprecation warnings (log for visibility, don't fail)
261- DEPRECATION_COUNT=$(grep -c "DEPRECATION" precompile_output.txt || true)
262- if [ "$DEPRECATION_COUNT" -gt 0 ]; then
263- echo "::warning::Found $DEPRECATION_COUNT deprecation warnings. These may indicate future breakage."
264- echo " Deprecation messages:"
265- grep -n "DEPRECATION" precompile_output.txt | head -5
266- fi
267-
268- if [ "$FAILURES_FOUND" -eq 1 ]; then
269- echo ""
270- echo "=========================================="
271- echo "PRECOMPILE CHECK FAILED"
272- echo "=========================================="
273- echo "Review the output above for details."
274- exit 1
275- fi
276-
277- echo ""
278- echo "=========================================="
279- echo "PRECOMPILE CHECK PASSED"
280- echo "=========================================="
281- echo "No known failure patterns detected in precompile output."
155+ - name : Validate precompile output
156+ run : script/validate-precompile-output react_on_rails/spec/dummy/precompile_output.txt
282157 - name : Upload precompile output
283158 if : always()
284159 uses : actions/upload-artifact@v4
0 commit comments