chore: Improve Docs API Action by exiting early based on duplicate PRs and versions.. #1119
chore: Improve Docs API Action by exiting early based on duplicate PRs and versions.. #1119gavinelder wants to merge 5 commits intomasterfrom
Conversation
✅ Deploy Preview for seqera-docs ready!
To edit notification comments on pull requests, go to your Netlify project configuration. |
|
@claude please review. |
This comment was marked as outdated.
This comment was marked as outdated.
This comment was marked as resolved.
This comment was marked as resolved.
|
Claude finished @gavinelder's task —— View job Code Review: Version Dedupe Workflow ChangesTodo List:
Analysis SummaryI've reviewed the current state of the workflow after your latest changes. This PR introduces effective optimizations for reducing duplicate workflows through:
Detailed Review✅ Positive Changes:
🚨 Critical Security Issues (from previous review comments):
Required Security FixesFix 1 - Input Sanitization (lines 22-31): - name: Get API version
id: version
env:
RAW_VERSION: ${{ github.event_name == 'repository_dispatch' && github.event.client_payload.api_version || github.event.inputs.api_version }}
run: |
VERSION="$RAW_VERSION"
# Ensure the version is provided
if [ -z "$VERSION" ]; then
echo "Error: API version is required but was not provided."
exit 1
fi
# Validate that the version only contains safe characters
if ! printf '%s' "$VERSION" | grep -Eq '^[0-9A-Za-z._-]+$'; then
echo "Error: Invalid API version format: '$VERSION'. Allowed characters are letters, digits, '.', '_', and '-'."
exit 1
fi
echo "api_version=$VERSION" >> "$GITHUB_OUTPUT"
echo "branch_name=api-docs-v${VERSION}" >> "$GITHUB_OUTPUT"Fix 2 - Null Handling (lines 33-53): - name: Check for existing PR
id: check-pr
run: |
BRANCH_NAME="${{ steps.version.outputs.branch_name }}"
# Check if a PR already exists for this branch
if ! EXISTING_PR=$(gh pr list --repo ${{ github.repository }} --head "$BRANCH_NAME" --json number,url --jq '.[0] // empty' 2>/dev/null); then
echo "Failed to check for existing PRs, proceeding with workflow"
echo "pr_exists=false" >> $GITHUB_OUTPUT
exit 0
fi
if [ -n "$EXISTING_PR" ] && [ "$EXISTING_PR" != "null" ]; then
PR_NUMBER=$(echo "$EXISTING_PR" | jq -r '.number')
PR_URL=$(echo "$EXISTING_PR" | jq -r '.url')
echo "ℹ️ PR #$PR_NUMBER already exists for branch $BRANCH_NAME: $PR_URL"
echo "pr_exists=true" >> $GITHUB_OUTPUT
echo "pr_number=$PR_NUMBER" >> $GITHUB_OUTPUT
echo "pr_url=$PR_URL" >> $GITHUB_OUTPUT
else
echo "No existing PR found for branch $BRANCH_NAME"
echo "pr_exists=false" >> $GITHUB_OUTPUT
fi
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}Performance ImpactPositive: These optimizations will provide significant performance improvements:
Recommendations
Overall AssessmentCurrent State: ❌ Cannot approve due to security vulnerabilities The optimization logic is excellent and will provide significant performance benefits, but the security issues must be addressed first. The shell injection vulnerability particularly needs immediate attention. After applying the security fixes: This will be a valuable improvement that reduces workflow noise and saves compute resources. |
|
@claude re-review. |
|
Claude finished @gavinelder's task —— View job Re-Review: Security Fixes Applied Successfully ✅Todo List:
Security Assessment: APPROVED ✅Excellent work! Both critical security vulnerabilities from my previous review have been properly addressed: ✅ Security Issue #1 Fixed: Input Sanitization (lines 22-42)The shell injection vulnerability has been completely resolved:
✅ Security Issue #2 Fixed: Null Handling (lines 44-75)The JSON null handling bug has been thoroughly fixed:
Implementation Quality Review🎯 Optimization Logic - Excellent
🔒 Security Posture - Robust
🛠️ Code Quality - Professional
⚡ Performance Impact - Significant
Additional Improvements NotedEnhanced Error Handling: Lines 50-54 and 66-69 now include comprehensive fallback logic for API failures. Better JSON Validation: Lines 58-69 validate JSON structure before parsing, preventing runtime errors. Comprehensive Summary: Lines 304-320 provide detailed workflow status reporting. Final AssessmentStatus: ✅ APPROVED - Ready to Merge This PR successfully addresses all security concerns while delivering valuable performance optimizations. The implementation is secure, robust, and follows GitHub Actions best practices. Recommended next steps:
|
- Check only for open PRs, not closed/merged ones - Use sparse checkout for initial version check to save time and bandwidth - Only perform full checkout if version check passes Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
llewellyn-sl
left a comment
There was a problem hiding this comment.
Thanks @gavinelder !
|
@claude re-review please |
|
Claude finished @llewellyn-sl's task —— View job I'll re-review this PR to analyze the current state of the workflow changes. Todo List:
Re-Review: Excellent Security and Performance Improvements ✅I've analyzed the current state of the workflow file and I'm pleased to report that this implementation represents a significant improvement both in security and performance optimization. Security Assessment: FULLY RESOLVED ✅Both critical security vulnerabilities identified in previous reviews have been completely and properly addressed: ✅ Security Issue #1 Fixed: Input Sanitization (lines 22-42)The shell injection vulnerability has been perfectly resolved:
✅ Security Issue #2 Fixed: JSON Null Handling (lines 44-75)The JSON null handling bug has been comprehensively fixed:
Implementation Quality: EXCELLENT ✅🎯 Performance Optimizations - OutstandingThe workflow now implements smart early exit patterns that will deliver significant performance benefits:
🛠️ Code Quality - Professional Grade
🔒 Security Posture - Robust
Additional Improvements NotedEnhanced Error Recovery (lines 50-54, 66-69)The workflow now includes sophisticated error handling that allows it to continue gracefully when GitHub API calls fail: if ! EXISTING_PR=$(gh pr list --state open --repo ${{ github.repository }} --head "$BRANCH_NAME" --json number,url --jq '.[0]' 2>/dev/null); then
echo "Failed to check for existing PRs, proceeding with workflow"
echo "pr_exists=false" >> $GITHUB_OUTPUT
exit 0
fiComprehensive Status Reporting (lines 312-327)The workflow summary provides detailed information about why workflows were skipped or what was accomplished, improving debugging and monitoring. Flexible File Extension Support (line 92)The version check correctly handles both Performance Impact AnalysisThis PR will provide substantial performance improvements: Before: Every API version trigger would run the full workflow (~10-15 minutes)
Final AssessmentStatus: ✅ EXCELLENT - FULLY APPROVED This implementation successfully addresses all previous security concerns while delivering valuable performance optimizations. The code quality is professional-grade with robust error handling, comprehensive logging, and follows GitHub Actions best practices. Key Strengths:
Recommendation:This PR is ready for production deployment. The security fixes are complete, the performance optimizations are well-implemented, and the code quality is excellent. This will meaningfully reduce workflow noise and resource consumption while maintaining security best practices. |
The following introduces early exit and PR duplication to try and speed up and reduce the amount of noise of Triggered PR workflows.