Roseau PR Comment #49
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Roseau PR Comment | |
| on: | |
| workflow_run: | |
| workflows: | |
| - Pull Request Check | |
| types: | |
| - completed | |
| permissions: | |
| contents: read | |
| actions: read | |
| pull-requests: write | |
| jobs: | |
| comment: | |
| if: ${{ github.event.workflow_run.conclusion != 'skipped' }} | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo (needed for gh CLI) | |
| uses: actions/checkout@v4 | |
| - name: Download Roseau reports | |
| uses: actions/download-artifact@v7 | |
| with: | |
| pattern: roseau-* | |
| path: roseau-reports | |
| run-id: ${{ github.event.workflow_run.id }} | |
| github-token: ${{ secrets.PAT_TOKEN }} | |
| - name: Find PR number | |
| id: pr | |
| run: | | |
| HEAD_BRANCH="${{ github.event.workflow_run.head_branch }}" | |
| HEAD_SHA="${{ github.event.workflow_run.head_sha }}" | |
| PR_NUMBER=$(gh pr list \ | |
| --head "$HEAD_BRANCH" \ | |
| --state open \ | |
| --json number \ | |
| --jq '.[0].number') | |
| if [ -z "$PR_NUMBER" ]; then | |
| PR_NUMBER=$(gh pr list \ | |
| --search "$HEAD_SHA" \ | |
| --state open \ | |
| --json number \ | |
| --jq '.[0].number') | |
| fi | |
| if [ -z "$PR_NUMBER" ]; then | |
| echo "::warning::Could not find PR number for branch=$HEAD_BRANCH sha=$HEAD_SHA" | |
| fi | |
| echo "number=$PR_NUMBER" >> "$GITHUB_OUTPUT" | |
| env: | |
| GH_TOKEN: ${{ secrets.PAT_TOKEN }} | |
| - name: Generate report body | |
| run: | | |
| MODULES=($(jq -r '.[].module' .github/modules.json) main) | |
| row() { | |
| local name=$1 dir=$2 | |
| local csv="${dir}/report.csv" | |
| if [ -f "$csv" ] && [ "$(wc -l < "$csv")" -gt 1 ]; then | |
| local count=$(($(wc -l < "$csv") - 1)) | |
| echo "| ${name} | 🔴 BC detected | ${count} |" | |
| elif [ -f "$csv" ]; then | |
| echo "| ${name} | ✅ Compatible | 0 |" | |
| else | |
| echo "| ${name} | ⚪ Skipped | — |" | |
| fi | |
| } | |
| append_details() { | |
| local name=$1 dir=$2 | |
| local csv="${dir}/report.csv" | |
| if [ ! -f "$csv" ]; then return; fi | |
| local count=$(($(wc -l < "$csv") - 1)) | |
| if [ "$count" -le 0 ]; then return; fi | |
| { | |
| echo "### 🔴 ${name} — ${count} breaking change(s)" | |
| echo "" | |
| while IFS=';' read -r type symbol kind nature location newSymbol binaryBreaking sourceBreaking; do | |
| echo "#### \`${location}\`" | |
| echo '```' | |
| echo "${type}" | |
| echo "${symbol}" | |
| echo "${kind}" | |
| [ "$binaryBreaking" = "true" ] && echo "✗ binary-breaking" || echo "✓ binary-compatible" | |
| [ "$sourceBreaking" = "true" ] && echo "✗ source-breaking" || echo "✓ source-compatible" | |
| echo '```' | |
| echo "" | |
| done < <(tail -n +2 "$csv") | |
| } >> /tmp/roseau-body.md | |
| } | |
| { | |
| echo "## 🌿 Roseau API Breaking Change Report" | |
| echo "" | |
| echo "| Module | Status | Breaking Changes |" | |
| echo "|--------|--------|-----------------|" | |
| for mod in "${MODULES[@]}"; do | |
| row "$mod" "roseau-reports/roseau-${mod}" | |
| done | |
| echo "" | |
| } > /tmp/roseau-body.md | |
| for mod in "${MODULES[@]}"; do | |
| append_details "$mod" "roseau-reports/roseau-${mod}" | |
| done | |
| echo "> Full CSVs: see the *Artifacts* section of [this workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.event.workflow_run.id }})." >> /tmp/roseau-body.md | |
| - name: Find existing Roseau comment | |
| id: find-comment | |
| if: steps.pr.outputs.number != '' | |
| uses: peter-evans/find-comment@v3 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} | |
| issue-number: ${{ steps.pr.outputs.number }} | |
| comment-author: anvil-craft | |
| body-includes: Roseau API Breaking Change Report | |
| - name: Create or update PR comment | |
| if: steps.pr.outputs.number != '' | |
| uses: peter-evans/create-or-update-comment@v4 | |
| with: | |
| token: ${{ secrets.PAT_TOKEN }} | |
| comment-id: ${{ steps.find-comment.outputs.comment-id }} | |
| issue-number: ${{ steps.pr.outputs.number }} | |
| body-path: /tmp/roseau-body.md | |
| edit-mode: replace |