дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
Restore AGENTS.md (CLAUDE.md links to it) and the verify skill, and add a pr skill covering scope, checks to run, the evidence each kind of change needs and a UX consistency review against DESIGN.md and PRODUCT.md. The PR template lists evidence by change type, and the PR check also asks for screenshots or a recording when a PR changes UI files under src/, unless the description says "No visible change".
79 рядки
3.9 KiB
YAML
79 рядки
3.9 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, description and changed file names.
|
|
pull_request_target:
|
|
types: [opened, edited, reopened, ready_for_review, synchronize]
|
|
|
|
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@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
|
|
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;
|
|
|
|
if (verified && verified[1].trim()) {
|
|
const section = verified[1];
|
|
const hasMedia =
|
|
/!\[[^\]]*\]\(|<img\b|<video\b|github\.com\/user-attachments\/|https?:\/\/\S+\.(png|jpe?g|gif|webp|mp4|mov|webm)\b/i.test(section);
|
|
const optedOut = /no visible change/i.test(section);
|
|
if (!hasMedia && !optedOut) {
|
|
const files = await github.paginate(github.rest.pulls.listFiles, { owner, repo, pull_number: issue_number, per_page: 100 });
|
|
const ui = files
|
|
.filter(f => f.status !== 'removed')
|
|
.map(f => f.filename)
|
|
.filter(name => /^src\/.*\.(tsx|css)$/.test(name) && !/\.(test|spec)\.tsx$/.test(name));
|
|
if (ui.length) {
|
|
const shown = ui.slice(0, 3).map(n => `\`${n}\``).join(', ') + (ui.length > 3 ? ', …' : '');
|
|
problems.push(`This PR changes UI files (${shown}). Add before/after screenshots, or a recording for interactions, to **How it was verified**; if nothing users see changed, write "No visible change" and say what you checked.`);
|
|
}
|
|
}
|
|
}
|
|
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(() => {});
|
|
}
|
|
}
|