mirror of
https://github.com/RustPython/RustPython.git
synced 2026-10-28 18:59:04 +08:00
Bumps [actions/download-artifact](https://github.com/actions/download-artifact) from 8.0.1 to 8.0.2. - [Release notes](https://github.com/actions/download-artifact/releases) - [Commits](https://github.com/actions/download-artifact/compare/3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c...9000827ccba6bdab643e8b6fd33ac0654aef8333) --- updated-dependencies: - dependency-name: actions/download-artifact dependency-version: 8.0.2 dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
82 lines
3.0 KiB
YAML
82 lines
3.0 KiB
YAML
on:
|
||
workflow_run:
|
||
workflows: [pyperformance]
|
||
types: [completed]
|
||
|
||
name: pyperformance comment
|
||
|
||
# Same split as `codspeed-comment.yaml`: a `pull_request` run from a fork gets
|
||
# a read-only token however it is configured, so the comparison is computed
|
||
# there and handed over as an artifact, and this workflow -- which
|
||
# `workflow_run` always runs in the base repo's context -- is the one trusted
|
||
# with a token that may write the comment.
|
||
permissions:
|
||
contents: read
|
||
actions: read # needed by download-artifact to fetch another run's artifact
|
||
pull-requests: write
|
||
|
||
jobs:
|
||
comment:
|
||
if: ${{ github.event.workflow_run.conclusion == 'success' }}
|
||
runs-on: ubuntu-latest
|
||
steps:
|
||
- name: Download the comparison produced by the pyperformance workflow
|
||
uses: actions/download-artifact@9000827ccba6bdab643e8b6fd33ac0654aef8333 # v8.0.2
|
||
with:
|
||
name: pyperformance-diff
|
||
run-id: ${{ github.event.workflow_run.id }}
|
||
github-token: ${{ github.token }}
|
||
continue-on-error: true # absent when the job was skipped or dispatched
|
||
|
||
- name: Post or update the PR comment
|
||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||
with:
|
||
script: |
|
||
const fs = require('fs');
|
||
if (!fs.existsSync('diff.md')) {
|
||
core.info('No diff.md in this run; nothing to comment.');
|
||
return;
|
||
}
|
||
|
||
const marker = '<!-- pyperformance-local-diff -->';
|
||
const run = context.payload.workflow_run;
|
||
let prNumber = (run.pull_requests || []).map((pr) => pr.number)[0];
|
||
if (!prNumber) {
|
||
const { data } = await github.rest.repos.listPullRequestsAssociatedWithCommit({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
commit_sha: run.head_sha,
|
||
});
|
||
prNumber = data.find((pr) => pr.state === 'open')?.number;
|
||
}
|
||
if (!prNumber) {
|
||
core.info(`No open pull request for ${run.head_sha}; nothing to comment.`);
|
||
return;
|
||
}
|
||
|
||
const raw = fs.readFileSync('diff.md', 'utf8').slice(0, 60000);
|
||
const body = `${marker}\n\n${raw.replace(/<!--/g, '<!--')}`;
|
||
|
||
const comments = await github.paginate(github.rest.issues.listComments, {
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
issue_number: prNumber,
|
||
});
|
||
const existing = comments.find((c) => c.body && c.body.includes(marker));
|
||
|
||
if (existing) {
|
||
await github.rest.issues.updateComment({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
comment_id: existing.id,
|
||
body,
|
||
});
|
||
} else {
|
||
await github.rest.issues.createComment({
|
||
owner: context.repo.owner,
|
||
repo: context.repo.repo,
|
||
issue_number: prNumber,
|
||
body,
|
||
});
|
||
}
|