mirror of
https://github.com/l0ng-ai/openidea.git
synced 2026-11-06 08:07:49 +00:00
CI Rust jobs build with line tables only (CARGO_PROFILE_DEV_DEBUG), which cut the Rust jobs from about 12 to 7.7 minutes on Ubuntu and 18 to 12.6 minutes on Windows and shrinks the cache. The workflows move to the actions releases that run on Node 24: checkout, setup-node and pnpm/action-setup v5, upload-artifact v6, github-script v8 (ci, pr-check and release). Co-authored-by: ldg030201 <100822592+ldg030201@users.noreply.github.com>
61 lines
2.7 KiB
YAML
61 lines
2.7 KiB
YAML
name: PR check
|
|
on:
|
|
# pull_request_target so the check can label PRs from forks. It never checks out
|
|
# or runs PR code: it only reads the PR title and description.
|
|
pull_request_target:
|
|
types: [opened, edited, reopened, ready_for_review]
|
|
|
|
permissions:
|
|
issues: write
|
|
pull-requests: write
|
|
|
|
concurrency:
|
|
group: pr-check-${{ github.event.pull_request.number }}
|
|
cancel-in-progress: true
|
|
|
|
jobs:
|
|
check:
|
|
if: github.event.pull_request.user.type != 'Bot' && !github.event.pull_request.draft
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/github-script@v8
|
|
with:
|
|
script: |
|
|
const pr = context.payload.pull_request;
|
|
const LABEL = 'needs-info';
|
|
const MARKER = '<!-- pr-check -->';
|
|
const body = (pr.body || '').replace(/<!--[\s\S]*?-->/g, '');
|
|
const problems = [];
|
|
|
|
const verified = body.match(/^##+\s*How it was verified\s*$([\s\S]*?)(?=^##+\s|(?![\s\S]))/im);
|
|
if (!verified || !verified[1].trim()) {
|
|
problems.push('Fill in **How it was verified**: the commands you ran and their results. UI changes need before/after screenshots.');
|
|
}
|
|
|
|
const { owner, repo } = context.repo;
|
|
const issue_number = pr.number;
|
|
const comments = await github.paginate(github.rest.issues.listComments, { owner, repo, issue_number });
|
|
const existing = comments.find(c => c.user.type === 'Bot' && c.body.includes(MARKER));
|
|
const labeled = pr.labels.some(l => l.name === LABEL);
|
|
|
|
if (problems.length) {
|
|
const text = `${MARKER}\nThanks for the PR. Before review, please update the description (see [CONTRIBUTING.md](https://github.com/${owner}/${repo}/blob/main/CONTRIBUTING.md)):\n\n${problems.map(p => `- ${p}`).join('\n')}\n\nThis check reruns when you edit the description.`;
|
|
if (existing) {
|
|
await github.rest.issues.updateComment({ owner, repo, comment_id: existing.id, body: text });
|
|
} else {
|
|
await github.rest.issues.createComment({ owner, repo, issue_number, body: text });
|
|
}
|
|
if (!labeled) {
|
|
await github.rest.issues.addLabels({ owner, repo, issue_number, labels: [LABEL] });
|
|
}
|
|
return;
|
|
}
|
|
|
|
// Only undo what this check did: the label is cleared only when our comment exists.
|
|
if (existing) {
|
|
await github.rest.issues.deleteComment({ owner, repo, comment_id: existing.id });
|
|
if (labeled) {
|
|
await github.rest.issues.removeLabel({ owner, repo, issue_number, name: LABEL }).catch(() => {});
|
|
}
|
|
}
|