Skip to content

Commit eac1acf

Browse files
committed
ci: fix timeout command, set timeout options, enhance logging:
1. Timeout Handling: Proper timeout command syntax with specific timeout error detection 2. Process Management: Environment variable for Hugo shutdown timeout 3. Debugging: Enhanced log collection and artifact uploads 4. Error Context: Better error messages that help identify root causes (EPIPE, timeouts, etc.) 5. Resource Constraints: Memory limits and CI-specific optimizations
1 parent f873562 commit eac1acf

File tree

4 files changed

+66
-8
lines changed

4 files changed

+66
-8
lines changed

.github/actions/setup-docs-env/action.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,18 @@ runs:
1212

1313
- name: Install dependencies
1414
run: yarn install
15+
shell: bash
16+
17+
- name: Verify Hugo installation
18+
run: |
19+
echo "Checking Hugo availability..."
20+
if command -v hugo &> /dev/null; then
21+
echo "✅ Hugo found on PATH: $(which hugo)"
22+
hugo version
23+
else
24+
echo "⚠️ Hugo not found on PATH, will use project-local Hugo via yarn"
25+
fi
26+
27+
echo "Checking yarn hugo command..."
28+
yarn hugo version || echo "⚠️ Project Hugo not available via yarn"
1529
shell: bash

.github/actions/validate-links/action.yml

Lines changed: 48 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ inputs:
1717
description: 'Cache key prefix for this validation run'
1818
required: false
1919
default: 'link-validation'
20+
timeout:
21+
description: 'Test timeout in seconds'
22+
required: false
23+
default: '900'
2024

2125
outputs:
2226
failed:
@@ -44,15 +48,31 @@ runs:
4448
export GITHUB_ACTIONS=true
4549
export NODE_OPTIONS="--max-old-space-size=4096"
4650
47-
# Add timeout to prevent hanging
48-
timeout ${{ inputs.timeout }} node cypress/support/run-e2e-specs.js ${{ inputs.files }} \
51+
# Set test runner timeout for Hugo shutdown
52+
export HUGO_SHUTDOWN_TIMEOUT=5000
53+
54+
# Add timeout to prevent hanging (timeout command syntax: timeout DURATION COMMAND)
55+
timeout ${{ inputs.timeout }}s node cypress/support/run-e2e-specs.js ${{ inputs.files }} \
4956
--spec cypress/e2e/content/article-links.cy.js || {
5057
exit_code=$?
51-
echo "::error::Link validation failed with exit code $exit_code"
5258
53-
# Check for specific error patterns
54-
if [ -f hugo.log ]; then
59+
# Handle timeout specifically
60+
if [ $exit_code -eq 124 ]; then
61+
echo "::error::Link validation timed out after ${{ inputs.timeout }} seconds"
62+
echo "::notice::This may indicate Hugo server startup issues or very slow link validation"
63+
else
64+
echo "::error::Link validation failed with exit code $exit_code"
65+
fi
66+
67+
# Check for specific error patterns and logs
68+
if [ -f /tmp/hugo_server.log ]; then
5569
echo "::group::Hugo Server Logs"
70+
cat /tmp/hugo_server.log
71+
echo "::endgroup::"
72+
fi
73+
74+
if [ -f hugo.log ]; then
75+
echo "::group::Additional Hugo Logs"
5676
cat hugo.log
5777
echo "::endgroup::"
5878
fi
@@ -63,20 +83,40 @@ runs:
6383
echo "::endgroup::"
6484
fi
6585
86+
# Show Cypress artifacts if they exist
87+
if [ -d cypress/screenshots ]; then
88+
echo "::group::Available Screenshots"
89+
find cypress/screenshots -name "*.png" -type f 2>/dev/null || echo "No screenshots found"
90+
echo "::endgroup::"
91+
fi
92+
6693
exit $exit_code
6794
}
6895
6996
- name: Upload logs on failure
7097
if: failure()
7198
uses: actions/upload-artifact@v4
7299
with:
73-
name: validation-logs-${{ inputs.product-name }}
100+
name: validation-logs-${{ inputs.product-name && inputs.product-name || 'default' }}
74101
path: |
75102
hugo.log
103+
/tmp/hugo_server.log
104+
if-no-files-found: ignore
76105

77-
- name: Upload broken links report
106+
- name: Upload Cypress artifacts on failure
78107
if: failure()
79108
uses: actions/upload-artifact@v4
109+
with:
110+
name: cypress-artifacts-${{ inputs.product-name && inputs.product-name || 'default' }}
111+
path: |
112+
cypress/screenshots
113+
cypress/videos
114+
if-no-files-found: ignore
115+
116+
- name: Upload broken links report
117+
if: always()
118+
uses: actions/upload-artifact@v4
80119
with:
81120
name: broken-links-report${{ inputs.product-name && format('-{0}', inputs.product-name) || '' }}
82-
path: /tmp/broken_links_report.json
121+
path: /tmp/broken_links_report.json
122+
if-no-files-found: ignore

.github/workflows/pr-link-validation.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ jobs:
120120
product-name: ${{ matrix.product }}
121121
cache-enabled: ${{ matrix.cacheEnabled || 'true' }}
122122
cache-key: link-validation-${{ hashFiles(matrix.files || needs.setup.outputs.all-files) }}
123+
timeout: 900
123124

124125
report:
125126
name: Report Results

cypress/support/run-e2e-specs.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,9 @@ async function main() {
117117
let hugoProc = null;
118118
let exitCode = 0;
119119
let hugoStarted = false;
120+
121+
// Configure shutdown timeout - use environment variable or default
122+
const HUGO_SHUTDOWN_TIMEOUT = parseInt(process.env.HUGO_SHUTDOWN_TIMEOUT) || 3000;
120123

121124
// Add this signal handler to ensure cleanup on unexpected termination
122125
const cleanupAndExit = (code = 1) => {

0 commit comments

Comments
 (0)