|
56 | 56 | Test: |
57 | 57 | runs-on: ubuntu-latest |
58 | 58 | steps: |
59 | | - - uses: actions-rust-lang/setup-rust-toolchain@v1 |
| 59 | + - uses: actions-rust-lang/setup-rust-toolchain@166cdcfd11aee3cb47222f9ddb555ce30ddb9659 # v1 |
60 | 60 | - uses: actions/checkout@v5 |
61 | 61 | - name: Install dependencies |
62 | 62 | run: | |
|
69 | 69 | runs-on: ubuntu-latest |
70 | 70 | permissions: |
71 | 71 | contents: read |
72 | | - pull-requests: write |
73 | 72 | env: |
74 | 73 | # Branch coverage requires nightly (-Z coverage-options=branch); don't let |
75 | 74 | # nightly lint churn fail the coverage report. Stable jobs enforce warnings. |
@@ -116,19 +115,67 @@ jobs: |
116 | 115 | f"({count('branches-covered')} / {count('branches-valid')}) |" |
117 | 116 | ) |
118 | 117 | PY |
119 | | - - name: Add coverage PR comment |
120 | | - uses: marocchino/sticky-pull-request-comment@773744901bac0e8cbb5a0dc842800d45e9b2b405 # v2 |
121 | | - if: >- |
122 | | - github.event_name == 'pull_request' && |
123 | | - github.actor != 'dependabot[bot]' && |
124 | | - github.event.pull_request.head.repo.full_name == github.repository |
125 | | - with: |
126 | | - header: code-coverage |
127 | | - recreate: true |
128 | | - path: code-coverage-results.md |
129 | 118 | - name: Write coverage to job summary |
130 | 119 | if: always() |
131 | 120 | run: cat code-coverage-results.md >> "$GITHUB_STEP_SUMMARY" |
| 121 | + - name: Upload coverage summary |
| 122 | + uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4 |
| 123 | + with: |
| 124 | + name: coverage-summary |
| 125 | + path: code-coverage-results.md |
| 126 | + if-no-files-found: error |
| 127 | + Coverage-Report: |
| 128 | + if: >- |
| 129 | + github.event_name == 'pull_request' && |
| 130 | + github.actor != 'dependabot[bot]' && |
| 131 | + github.event.pull_request.head.repo.full_name == github.repository |
| 132 | + needs: Coverage |
| 133 | + runs-on: ubuntu-latest |
| 134 | + permissions: |
| 135 | + actions: read |
| 136 | + pull-requests: write |
| 137 | + steps: |
| 138 | + - name: Download coverage summary |
| 139 | + uses: actions/download-artifact@d3f86a106a0bac45b974a628896c90dbdf5c8093 # v4 |
| 140 | + with: |
| 141 | + name: coverage-summary |
| 142 | + path: . |
| 143 | + - name: Add coverage PR comment |
| 144 | + uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8 |
| 145 | + with: |
| 146 | + script: | |
| 147 | + const fs = require('node:fs'); |
| 148 | + const marker = '<!-- Sticky Pull Request Commentcode-coverage -->'; |
| 149 | + const body = `${fs.readFileSync('code-coverage-results.md', 'utf8').trimEnd()}\n\n${marker}`; |
| 150 | + const { owner, repo } = context.repo; |
| 151 | + const issue_number = context.issue.number; |
| 152 | + const comments = await github.paginate(github.rest.issues.listComments, { |
| 153 | + owner, |
| 154 | + repo, |
| 155 | + issue_number, |
| 156 | + per_page: 100, |
| 157 | + }); |
| 158 | + const existing = comments.find( |
| 159 | + (comment) => |
| 160 | + comment.user.login === 'github-actions[bot]' && |
| 161 | + comment.body.endsWith(marker), |
| 162 | + ); |
| 163 | +
|
| 164 | + if (existing) { |
| 165 | + await github.rest.issues.updateComment({ |
| 166 | + owner, |
| 167 | + repo, |
| 168 | + comment_id: existing.id, |
| 169 | + body, |
| 170 | + }); |
| 171 | + } else { |
| 172 | + await github.rest.issues.createComment({ |
| 173 | + owner, |
| 174 | + repo, |
| 175 | + issue_number, |
| 176 | + body, |
| 177 | + }); |
| 178 | + } |
132 | 179 | Format: |
133 | 180 | runs-on: ubuntu-latest |
134 | 181 | steps: |
|
0 commit comments