|
| 1 | +name: "RADE PR Score Diff" |
| 2 | +description: "Run RADE on PR base/head refs and comment reusability/accessibility score deltas." |
| 3 | +author: "Buildrr89" |
| 4 | +branding: |
| 5 | + icon: "bar-chart-2" |
| 6 | + color: "blue" |
| 7 | +inputs: |
| 8 | + github-token: |
| 9 | + description: "GitHub token used to read PR metadata and post comments." |
| 10 | + required: true |
| 11 | + pr-number: |
| 12 | + description: "Pull request number." |
| 13 | + required: true |
| 14 | + base-sha: |
| 15 | + description: "Base commit SHA for comparison." |
| 16 | + required: true |
| 17 | + head-sha: |
| 18 | + description: "Head commit SHA for comparison." |
| 19 | + required: true |
| 20 | + input-path: |
| 21 | + description: "Path to RADE input JSON fixture inside the repository." |
| 22 | + required: false |
| 23 | + default: "examples/sample_ios_output.json" |
| 24 | + app-id: |
| 25 | + description: "Application identifier passed to RADE CLI." |
| 26 | + required: false |
| 27 | + default: "com.example.legacyapp" |
| 28 | + python-version: |
| 29 | + description: "Python runtime version used to run RADE CLI." |
| 30 | + required: false |
| 31 | + default: "3.14" |
| 32 | +runs: |
| 33 | + using: "composite" |
| 34 | + steps: |
| 35 | + - name: Setup Python |
| 36 | + uses: actions/setup-python@v5 |
| 37 | + with: |
| 38 | + python-version: ${{ inputs.python-version }} |
| 39 | + |
| 40 | + - name: Install RADE runtime dependencies |
| 41 | + shell: bash |
| 42 | + run: python -m pip install --disable-pip-version-check neo4j playwright pyyaml |
| 43 | + |
| 44 | + - name: Generate base/head reports |
| 45 | + shell: bash |
| 46 | + run: | |
| 47 | + set -euo pipefail |
| 48 | + git checkout --quiet "${{ inputs.base-sha }}" |
| 49 | + python -m src.core.cli analyze \ |
| 50 | + --input "${{ inputs.input-path }}" \ |
| 51 | + --app-id "${{ inputs.app-id }}" \ |
| 52 | + --json-output "$RUNNER_TEMP/rade-base.json" |
| 53 | + git checkout --quiet "${{ inputs.head-sha }}" |
| 54 | + python -m src.core.cli analyze \ |
| 55 | + --input "${{ inputs.input-path }}" \ |
| 56 | + --app-id "${{ inputs.app-id }}" \ |
| 57 | + --json-output "$RUNNER_TEMP/rade-head.json" |
| 58 | +
|
| 59 | + - name: Build PR comment body |
| 60 | + shell: bash |
| 61 | + run: | |
| 62 | + set -euo pipefail |
| 63 | + python scripts/pr_score_comment.py \ |
| 64 | + --base-report "$RUNNER_TEMP/rade-base.json" \ |
| 65 | + --head-report "$RUNNER_TEMP/rade-head.json" \ |
| 66 | + --base-ref "${{ inputs.base-sha }}" \ |
| 67 | + --head-ref "${{ inputs.head-sha }}" \ |
| 68 | + --output "$RUNNER_TEMP/rade-comment.md" |
| 69 | +
|
| 70 | + - name: Post or update PR comment |
| 71 | + uses: actions/github-script@v7 |
| 72 | + with: |
| 73 | + github-token: ${{ inputs.github-token }} |
| 74 | + script: | |
| 75 | + const fs = require("fs"); |
| 76 | + const marker = "<!-- rade-pr-score-comment -->"; |
| 77 | + const issue_number = Number("${{ inputs.pr-number }}"); |
| 78 | + const body = fs.readFileSync(`${process.env.RUNNER_TEMP}/rade-comment.md`, "utf8"); |
| 79 | +
|
| 80 | + const { data: comments } = await github.rest.issues.listComments({ |
| 81 | + owner: context.repo.owner, |
| 82 | + repo: context.repo.repo, |
| 83 | + issue_number, |
| 84 | + per_page: 100 |
| 85 | + }); |
| 86 | +
|
| 87 | + const existing = comments.find((comment) => comment.body && comment.body.includes(marker)); |
| 88 | +
|
| 89 | + if (existing) { |
| 90 | + await github.rest.issues.updateComment({ |
| 91 | + owner: context.repo.owner, |
| 92 | + repo: context.repo.repo, |
| 93 | + comment_id: existing.id, |
| 94 | + body |
| 95 | + }); |
| 96 | + } else { |
| 97 | + await github.rest.issues.createComment({ |
| 98 | + owner: context.repo.owner, |
| 99 | + repo: context.repo.repo, |
| 100 | + issue_number, |
| 101 | + body |
| 102 | + }); |
| 103 | + } |
0 commit comments