|
11 | 11 | name: Check OCaml References |
12 | 12 |
|
13 | 13 | on: |
| 14 | + pull_request: |
| 15 | + branches: |
| 16 | + - develop |
| 17 | + - main |
14 | 18 | schedule: |
15 | 19 | # Run every Monday at 9:00 AM UTC |
16 | 20 | - cron: '0 9 * * 1' |
@@ -46,17 +50,68 @@ jobs: |
46 | 50 | OCAML_BRANCH: ${{ github.event.inputs.branch || 'compatible' }} |
47 | 51 | run: | |
48 | 52 | set +e |
| 53 | + # Capture output to file |
49 | 54 | ./.github/scripts/check-ocaml-refs.sh \ |
50 | 55 | --repo "$OCAML_REPO" \ |
51 | | - --branch "$OCAML_BRANCH" |
| 56 | + --branch "$OCAML_BRANCH" 2>&1 | tee validation_output.txt |
52 | 57 | exit_code=$? |
53 | 58 | if [ $exit_code -ne 0 ]; then |
54 | 59 | echo "has_issues=true" >> $GITHUB_OUTPUT |
55 | | - exit 0 |
| 60 | + else |
| 61 | + echo "has_issues=false" >> $GITHUB_OUTPUT |
56 | 62 | fi |
| 63 | + # Store output for PR comment |
| 64 | + echo "output_file=validation_output.txt" >> $GITHUB_OUTPUT |
| 65 | + exit 0 |
| 66 | +
|
| 67 | + - name: Prepare PR comment |
| 68 | + if: github.event_name == 'pull_request' |
| 69 | + id: prepare-comment |
| 70 | + env: |
| 71 | + HAS_ISSUES: ${{ steps.check.outputs.has_issues }} |
| 72 | + OCAML_REPO: ${{ github.event.inputs.repo || 'https://github.com/MinaProtocol/mina.git' }} |
| 73 | + OCAML_BRANCH: ${{ github.event.inputs.branch || 'compatible' }} |
| 74 | + run: | |
| 75 | + # Determine status message |
| 76 | + if [ "$HAS_ISSUES" = "true" ]; then |
| 77 | + STATUS_MSG="❌ Validation failed" |
| 78 | + else |
| 79 | + STATUS_MSG="✓ Validation passed" |
| 80 | + fi |
| 81 | +
|
| 82 | + # Create comment body |
| 83 | + cat > comment.md <<COMMENT_EOF |
| 84 | + ## OCaml Reference Validation Results |
| 85 | +
|
| 86 | + **Repository**: ${OCAML_REPO} |
| 87 | + **Branch**: ${OCAML_BRANCH} |
| 88 | + **Status**: ${STATUS_MSG} |
| 89 | +
|
| 90 | + <details> |
| 91 | + <summary>Click to see full validation output</summary> |
| 92 | +
|
| 93 | + \`\`\` |
| 94 | + COMMENT_EOF |
| 95 | +
|
| 96 | + # Append validation output |
| 97 | + cat validation_output.txt >> comment.md |
| 98 | +
|
| 99 | + # Close the code block and details |
| 100 | + cat >> comment.md <<'COMMENT_EOF' |
| 101 | + ``` |
| 102 | +
|
| 103 | + </details> |
| 104 | + COMMENT_EOF |
| 105 | +
|
| 106 | + - name: Post PR comment with validation results |
| 107 | + if: github.event_name == 'pull_request' |
| 108 | + uses: peter-evans/create-or-update-comment@v4 |
| 109 | + with: |
| 110 | + issue-number: ${{ github.event.pull_request.number }} |
| 111 | + body-path: comment.md |
57 | 112 |
|
58 | 113 | - name: Update references if stale |
59 | | - if: steps.check.outputs.has_issues != 'true' |
| 114 | + if: steps.check.outputs.has_issues != 'true' && github.event_name != 'pull_request' |
60 | 115 | env: |
61 | 116 | OCAML_REPO: ${{ github.event.inputs.repo || 'https://github.com/MinaProtocol/mina.git' }} |
62 | 117 | OCAML_BRANCH: ${{ github.event.inputs.branch || 'compatible' }} |
|
67 | 122 | --update |
68 | 123 |
|
69 | 124 | - name: Check for changes |
| 125 | + if: github.event_name != 'pull_request' |
70 | 126 | id: changes |
71 | 127 | run: | |
72 | 128 | if git diff --quiet; then |
|
76 | 132 | fi |
77 | 133 |
|
78 | 134 | - name: Create Pull Request |
79 | | - if: steps.changes.outputs.has_changes == 'true' |
| 135 | + if: steps.changes.outputs.has_changes == 'true' && github.event_name != 'pull_request' |
80 | 136 | uses: peter-evans/create-pull-request@v6 |
81 | 137 | with: |
82 | 138 | token: ${{ secrets.GITHUB_TOKEN }} |
@@ -118,6 +174,8 @@ jobs: |
118 | 174 | echo "" >> $GITHUB_STEP_SUMMARY |
119 | 175 | if [ "${{ steps.check.outputs.has_issues }}" == "true" ]; then |
120 | 176 | echo "❌ Validation failed - some OCaml references are invalid" >> $GITHUB_STEP_SUMMARY |
| 177 | + elif [ "${{ github.event_name }}" == "pull_request" ]; then |
| 178 | + echo "✓ Validation completed - results posted as PR comment" >> $GITHUB_STEP_SUMMARY |
121 | 179 | elif [ "${{ steps.changes.outputs.has_changes }}" == "true" ]; then |
122 | 180 | echo "✓ Validation passed - created PR to update stale references" >> $GITHUB_STEP_SUMMARY |
123 | 181 | else |
|
0 commit comments