Skip to content

Commit 7fbbc04

Browse files
committed
Add timeout handling, execution tracking, and job summary
Enhance the Run CAgent step with: Timeout Support: - Implement timeout using bash 'timeout' command - Exit code 124 indicates timeout occurred - Clear error message when timeout is reached Execution Time Tracking: - Track start and end time of agent execution - Output execution-time in seconds for use in subsequent steps GitHub Actions Job Summary: - Create formatted markdown summary table - Show agent name, exit code, execution time, versions - Visual status indicators (✅ success, ❌ failed, ⏱️ timeout) - Expandable section with last 100 lines of agent output - Summary appears in GitHub Actions UI for easy review Debug Mode Support: - Enable bash tracing (set -x) when debug mode is on - Output working directory and workspace paths - Log exit code, execution time, and output file location
1 parent 8c51959 commit 7fbbc04

File tree

1 file changed

+73
-3
lines changed

1 file changed

+73
-3
lines changed

action.yml

Lines changed: 73 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,14 @@ runs:
208208
GOOGLE_API_KEY: ${{ inputs.google-api-key || env.GOOGLE_API_KEY }}
209209
GITHUB_PERSONAL_ACCESS_TOKEN: ${{ inputs.github-token }}
210210
run: |
211+
set -e
212+
213+
if [[ "${{ inputs.debug }}" == "true" ]]; then
214+
set -x
215+
echo "::debug::Working directory: $(pwd)"
216+
echo "::debug::GitHub workspace: $GITHUB_WORKSPACE"
217+
fi
218+
211219
# Build the command
212220
CMD="$GITHUB_WORKSPACE/cagent run"
213221
@@ -234,10 +242,72 @@ runs:
234242
echo "Running: $CMD"
235243
236244
# Capture output to both console and file
237-
OUTPUT_FILE="/tmp/cagent-output-$$.log"
238-
eval $CMD 2>&1 | tee "$OUTPUT_FILE"
239-
EXIT_CODE=${PIPESTATUS[0]}
245+
OUTPUT_FILE=$(mktemp /tmp/cagent-output.XXXXXX.log)
246+
247+
# Track execution time
248+
START_TIME=$(date +%s)
249+
250+
# Run with timeout if specified
251+
set +e # Don't exit on command failure
252+
if [ "${{ inputs.timeout }}" != "0" ]; then
253+
timeout "${{ inputs.timeout }}" bash -c "eval $CMD 2>&1 | tee '$OUTPUT_FILE'"
254+
EXIT_CODE=$?
255+
if [ $EXIT_CODE -eq 124 ]; then
256+
echo "::error::Agent execution timed out after ${{ inputs.timeout }} seconds"
257+
fi
258+
else
259+
eval $CMD 2>&1 | tee "$OUTPUT_FILE"
260+
EXIT_CODE=${PIPESTATUS[0]}
261+
fi
262+
set -e
240263
264+
END_TIME=$(date +%s)
265+
EXECUTION_TIME=$((END_TIME - START_TIME))
266+
267+
# Set outputs
241268
echo "exit-code=$EXIT_CODE" >> $GITHUB_OUTPUT
242269
echo "output-file=$OUTPUT_FILE" >> $GITHUB_OUTPUT
270+
echo "execution-time=$EXECUTION_TIME" >> $GITHUB_OUTPUT
271+
272+
# Create job summary
273+
{
274+
echo "## CAgent Execution Summary"
275+
echo ""
276+
echo "| Property | Value |"
277+
echo "|----------|-------|"
278+
echo "| Agent | \`${{ inputs.agent }}\` |"
279+
echo "| Exit Code | $EXIT_CODE |"
280+
echo "| Execution Time | ${EXECUTION_TIME}s |"
281+
echo "| CAgent Version | ${{ inputs.cagent-version }} |"
282+
echo "| MCP Gateway | ${{ steps.setup-binaries.outputs.mcp-installed }} |"
283+
if [ "${{ inputs.timeout }}" != "0" ]; then
284+
echo "| Timeout | ${{ inputs.timeout }}s |"
285+
fi
286+
echo ""
287+
288+
if [ $EXIT_CODE -eq 0 ]; then
289+
echo "✅ **Status:** Success"
290+
elif [ $EXIT_CODE -eq 124 ]; then
291+
echo "⏱️ **Status:** Timeout"
292+
else
293+
echo "❌ **Status:** Failed"
294+
fi
295+
echo ""
296+
297+
echo "<details>"
298+
echo "<summary>Agent Output (click to expand)</summary>"
299+
echo ""
300+
echo "\`\`\`"
301+
# Show last 100 lines of output
302+
tail -n 100 "$OUTPUT_FILE"
303+
echo "\`\`\`"
304+
echo "</details>"
305+
} >> $GITHUB_STEP_SUMMARY
306+
307+
if [[ "${{ inputs.debug }}" == "true" ]]; then
308+
echo "::debug::Exit code: $EXIT_CODE"
309+
echo "::debug::Execution time: ${EXECUTION_TIME}s"
310+
echo "::debug::Output file: $OUTPUT_FILE"
311+
fi
312+
243313
exit $EXIT_CODE

0 commit comments

Comments
 (0)