|
22 | 22 | - ".github/workflows/policy-smart-sci.yml" |
23 | 23 | workflow_dispatch: |
24 | 24 |
|
25 | | -permissions: read-all |
| 25 | +permissions: |
| 26 | + contents: read |
| 27 | + pull-requests: write |
26 | 28 |
|
27 | 29 | jobs: |
28 | 30 | sci-1: |
@@ -140,3 +142,83 @@ jobs: |
140 | 142 | echo "SCI-3 failed: no tests to run" |
141 | 143 | exit 1 |
142 | 144 | fi |
| 145 | +
|
| 146 | + report: |
| 147 | + name: SCI PR Comment |
| 148 | + if: always() && github.event_name == 'pull_request' |
| 149 | + needs: [sci-1, sci-2, sci-3] |
| 150 | + runs-on: ubuntu-22.04 |
| 151 | + permissions: |
| 152 | + contents: read |
| 153 | + pull-requests: write |
| 154 | + steps: |
| 155 | + - name: Update PR Comment |
| 156 | + uses: actions/github-script@v7 |
| 157 | + env: |
| 158 | + SCI1_RESULT: ${{ needs.sci-1.result }} |
| 159 | + SCI2_RESULT: ${{ needs.sci-2.result }} |
| 160 | + SCI3_RESULT: ${{ needs.sci-3.result }} |
| 161 | + RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} |
| 162 | + with: |
| 163 | + script: | |
| 164 | + const marker = "<!-- dae-policy-smart-sci -->"; |
| 165 | + const toIcon = (result) => { |
| 166 | + switch (result) { |
| 167 | + case "success": |
| 168 | + return "✅"; |
| 169 | + case "failure": |
| 170 | + return "❌"; |
| 171 | + case "cancelled": |
| 172 | + return "⚪"; |
| 173 | + case "skipped": |
| 174 | + return "⏭️"; |
| 175 | + default: |
| 176 | + return "❔"; |
| 177 | + } |
| 178 | + }; |
| 179 | +
|
| 180 | + const jobs = [ |
| 181 | + { name: "SCI-1 Strategy Correctness", result: process.env.SCI1_RESULT || "unknown" }, |
| 182 | + { name: "SCI-2 TCP Retry Semantics", result: process.env.SCI2_RESULT || "unknown" }, |
| 183 | + { name: "SCI-3 Concurrency Race", result: process.env.SCI3_RESULT || "unknown" }, |
| 184 | + ]; |
| 185 | +
|
| 186 | + const allSuccess = jobs.every((j) => j.result === "success"); |
| 187 | + const summary = allSuccess ? "pass" : "not pass"; |
| 188 | + const body = [ |
| 189 | + marker, |
| 190 | + "## Policy Smart SCI", |
| 191 | + "", |
| 192 | + `- Summary: **${summary}**`, |
| 193 | + `- Workflow run: ${process.env.RUN_URL}`, |
| 194 | + "", |
| 195 | + "### Job Status", |
| 196 | + "", |
| 197 | + ...jobs.map((j) => `- ${toIcon(j.result)} ${j.name}: \`${j.result}\``), |
| 198 | + ].join("\n"); |
| 199 | +
|
| 200 | + const { owner, repo } = context.repo; |
| 201 | + const issue_number = context.issue.number; |
| 202 | + const comments = await github.paginate(github.rest.issues.listComments, { |
| 203 | + owner, |
| 204 | + repo, |
| 205 | + issue_number, |
| 206 | + per_page: 100, |
| 207 | + }); |
| 208 | +
|
| 209 | + const existing = comments.find((c) => c.body && c.body.includes(marker)); |
| 210 | + if (existing) { |
| 211 | + await github.rest.issues.updateComment({ |
| 212 | + owner, |
| 213 | + repo, |
| 214 | + comment_id: existing.id, |
| 215 | + body, |
| 216 | + }); |
| 217 | + } else { |
| 218 | + await github.rest.issues.createComment({ |
| 219 | + owner, |
| 220 | + repo, |
| 221 | + issue_number, |
| 222 | + body, |
| 223 | + }); |
| 224 | + } |
0 commit comments