fix: Prevent workflow failures by removing exit codes and improving error handling
- Replace all 'exit 1' statements with warnings and skip flags - Add SKIP_CLI environment variable to control CLI execution - Create fallback reviews immediately when prerequisites fail - Wrap CLI execution in conditional checks - Ensure workflows always complete successfully with informative messages This prevents the 'Process completed with exit code 1' error and ensures the workflows fail gracefully with helpful feedback instead of crashing.
This commit is contained in:
parent
9b5508de4a
commit
a5de88907c
2 changed files with 62 additions and 12 deletions
|
|
@ -196,8 +196,17 @@ runs:
|
|||
|
||||
# Validate API key
|
||||
if [ -z "$CONTINUE_API_KEY" ]; then
|
||||
echo "Error: CONTINUE_API_KEY environment variable is not set"
|
||||
exit 1
|
||||
echo "Warning: CONTINUE_API_KEY environment variable is not set"
|
||||
# Create fallback review and continue
|
||||
cat > inline_review.json << 'EOF'
|
||||
{
|
||||
"review_summary": "AI review skipped: CONTINUE_API_KEY not configured.",
|
||||
"comments": []
|
||||
}
|
||||
EOF
|
||||
echo "SKIP_CLI=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "SKIP_CLI=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
# Log the prompt for debugging
|
||||
|
|
@ -208,13 +217,25 @@ runs:
|
|||
echo "===== END REVIEW PROMPT ====="
|
||||
|
||||
# Test Continue CLI availability
|
||||
echo "Testing Continue CLI..."
|
||||
cn --version || { echo "Error: Continue CLI not found"; exit 1; }
|
||||
if [ "$SKIP_CLI" != "true" ]; then
|
||||
echo "Testing Continue CLI..."
|
||||
if ! cn --version; then
|
||||
echo "Warning: Continue CLI not found or not working"
|
||||
cat > inline_review.json << 'EOF'
|
||||
{
|
||||
"review_summary": "AI review skipped: Continue CLI installation failed.",
|
||||
"comments": []
|
||||
}
|
||||
EOF
|
||||
echo "SKIP_CLI=true" >> $GITHUB_ENV
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run the CLI and capture JSON output with error handling
|
||||
echo "Executing Continue CLI with org: ${{ inputs.continue-org }}, config: ${{ inputs.continue-config }}"
|
||||
if [ "$SKIP_CLI" != "true" ]; then
|
||||
echo "Executing Continue CLI with org: ${{ inputs.continue-org }}, config: ${{ inputs.continue-config }}"
|
||||
if ! cn --readonly --format json --org "${{ inputs.continue-org }}" --config "${{ inputs.continue-config }}" -p "$(cat inline_review_prompt.txt)" > inline_review_raw.json 2>cli_error.log; then
|
||||
echo "Error: Continue CLI command failed"
|
||||
echo "Warning: Continue CLI command failed"
|
||||
echo "CLI error log:"
|
||||
cat cli_error.log
|
||||
|
||||
|
|
@ -225,7 +246,7 @@ runs:
|
|||
"comments": []
|
||||
}
|
||||
EOF
|
||||
# Don't exit with failure to allow posting fallback comment
|
||||
echo "Created fallback review due to CLI failure"
|
||||
else
|
||||
# Log the output for debugging
|
||||
echo "Initial Continue CLI output:"
|
||||
|
|
@ -247,6 +268,7 @@ runs:
|
|||
cat inline_review.json
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Post Inline Review Comments
|
||||
if: env.SKIP_REVIEW != 'true'
|
||||
|
|
|
|||
|
|
@ -159,8 +159,20 @@ runs:
|
|||
|
||||
# Validate API key
|
||||
if [ -z "$CONTINUE_API_KEY" ]; then
|
||||
echo "Error: CONTINUE_API_KEY environment variable is not set"
|
||||
exit 1
|
||||
echo "Warning: CONTINUE_API_KEY environment variable is not set"
|
||||
# Create fallback review and continue
|
||||
cat > code_review.md << 'EOF'
|
||||
## Code Review Summary
|
||||
|
||||
⚠️ AI review skipped: CONTINUE_API_KEY not configured.
|
||||
|
||||
### Configuration Required
|
||||
- Please set the CONTINUE_API_KEY secret in repository settings
|
||||
- Verify that the organization and config path are valid
|
||||
EOF
|
||||
echo "SKIP_CLI=true" >> $GITHUB_ENV
|
||||
else
|
||||
echo "SKIP_CLI=false" >> $GITHUB_ENV
|
||||
fi
|
||||
|
||||
# Validate inputs to prevent command injection
|
||||
|
|
@ -175,11 +187,26 @@ runs:
|
|||
fi
|
||||
|
||||
# Test Continue CLI availability
|
||||
echo "Testing Continue CLI..."
|
||||
cn --version || { echo "Error: Continue CLI not found"; exit 1; }
|
||||
if [ "$SKIP_CLI" != "true" ]; then
|
||||
echo "Testing Continue CLI..."
|
||||
if ! cn --version; then
|
||||
echo "Warning: Continue CLI not found or not working"
|
||||
cat > code_review.md << 'EOF'
|
||||
## Code Review Summary
|
||||
|
||||
⚠️ AI review skipped: Continue CLI installation failed.
|
||||
|
||||
### Troubleshooting
|
||||
- Check that npm installation succeeded
|
||||
- Verify @continuedev/cli package is available
|
||||
EOF
|
||||
echo "SKIP_CLI=true" >> $GITHUB_ENV
|
||||
fi
|
||||
fi
|
||||
|
||||
# Run the CLI with validated config and error handling
|
||||
echo "Executing Continue CLI with org: $CONTINUE_ORG, config: $CONTINUE_CONFIG"
|
||||
if [ "$SKIP_CLI" != "true" ]; then
|
||||
echo "Executing Continue CLI with org: $CONTINUE_ORG, config: $CONTINUE_CONFIG"
|
||||
if ! cn --readonly --org "$CONTINUE_ORG" --config "$CONTINUE_CONFIG" -p "$(cat review_prompt.txt)" > code_review.md 2>cli_error.log; then
|
||||
echo "Error: Continue CLI command failed"
|
||||
echo "CLI error log:"
|
||||
|
|
@ -199,6 +226,7 @@ EOF
|
|||
else
|
||||
echo "Review generated successfully"
|
||||
fi
|
||||
fi
|
||||
|
||||
- name: Upload Review Results
|
||||
if: env.SHOULD_RUN == 'true' && always()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue