Skip to content

Three center integration and numerical stabilities of trinity #33

Three center integration and numerical stabilities of trinity

Three center integration and numerical stabilities of trinity #33

name: PR Review Plan Comment
on:
pull_request_target:
types: [opened, synchronize, reopened]
jobs:
review-plan-comment:
name: Comment advisory PR review plan
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
issues: write
steps:
- name: Checkout trusted base code
uses: actions/checkout@v7
with:
# Keep the workflow and helper script versions in sync while avoiding fork code.
ref: ${{ github.event.pull_request.base.ref }}
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Get changed files
uses: actions/github-script@v9
with:
script: |
const files = await github.paginate(
github.rest.pulls.listFiles,
{
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
per_page: 100,
}
);
const names = files.map((file) => file.filename).join("\n");
require("fs").writeFileSync("changed-files.txt", names);
- name: Generate review plan
run: |
python scripts/ci/pr_review_plan.py --stdin --format github-comment < changed-files.txt > pr-review-plan.md
- name: Comment review plan
uses: actions/github-script@v9
with:
script: |
const fs = require("fs");
const marker = "<!-- deeptb-pr-review-plan -->";
const plan = fs.readFileSync("pr-review-plan.md", "utf8");
const body = [
marker,
"This advisory review plan was generated from changed file names using trusted base-branch code.",
"此审查计划由受信任的 base 分支代码根据变更文件名生成,仅作为维护者辅助。",
"",
plan,
].join("\n");
const comments = await github.paginate(
github.rest.issues.listComments,
{
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
per_page: 100,
}
);
const previous = comments.find((comment) =>
comment.user.type === "Bot" && comment.body.includes(marker)
);
if (previous) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: previous.id,
body,
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
body,
});
}