Skip to content

Commit f8832a3

Browse files
committed
build: convert check_pr_issue_references to schedule-based trigger
The workflow was failing on every run because `pull_request` events from fork PRs do not have access to the `COPILOT_GITHUB_TOKEN` secret. Switch to a schedule-based trigger (every 6h) that runs in the main repo context, where secrets are always available. The workflow now auto-discovers recently updated PRs and checks for existing bot comments to avoid duplicates. --- type: pre_commit_static_analysis_report description: Results of running static analysis checks when committing changes. report: - task: lint_filenames status: passed - task: lint_editorconfig status: passed - task: lint_markdown status: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: na - task: lint_javascript_cli status: na - task: lint_javascript_examples status: na - task: lint_javascript_tests status: na - task: lint_javascript_benchmarks status: na - task: lint_python status: na - task: lint_r status: na - task: lint_c_src status: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: na - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: passed - task: lint_typescript_tests status: na - task: lint_license_headers status: passed ---
1 parent fda6d89 commit f8832a3

2 files changed

Lines changed: 77 additions & 64 deletions

File tree

.github/workflows/check-pr-issue-references.lock.yml renamed to .github/workflows/check_pr_issue_references.lock.yml

Lines changed: 29 additions & 44 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.github/workflows/check-pr-issue-references.md renamed to .github/workflows/check_pr_issue_references.md

Lines changed: 48 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ description: >
33
Checks whether issue/PR references in a PR body are actually related to the PR.
44
Posts an informational comment when suspicious references are detected.
55
6+
run-name: check_pr_issue_references
7+
68
on:
7-
pull_request:
8-
types: [opened, edited]
9-
forks: ["*"]
9+
schedule: every 6h
1010
workflow_dispatch:
1111
inputs:
12-
pr_number:
13-
description: 'Pull request number to check'
14-
required: true
15-
type: number
16-
roles: all
12+
pr_numbers:
13+
description: 'Comma-separated PR numbers to check (leave empty to auto-discover recent PRs)'
14+
required: false
15+
type: string
1716

1817
permissions:
1918
contents: read
@@ -36,33 +35,54 @@ network:
3635

3736
safe-outputs:
3837
add-comment:
39-
max: 1
38+
max: 10
4039
noop:
40+
max: 10
4141

42-
timeout-minutes: 5
42+
timeout-minutes: 10
4343
---
4444

4545
# Check PR Issue References
4646

47-
You are a reference validator for the stdlib-js/stdlib repository. Your only task is
48-
to check whether issue/PR references in a pull request description are actually related
49-
to the PR.
47+
You are a reference validator for the stdlib-js/stdlib repository. Your task is
48+
to check whether issue/PR references in pull request descriptions are actually
49+
related to the PRs.
50+
51+
## Step 1: Discover PRs to Check
52+
53+
If `${{ github.event.inputs.pr_numbers }}` is provided, parse it as a
54+
comma-separated list of PR numbers and fetch those PRs.
55+
56+
Otherwise, use the GitHub tool to list open pull requests in `stdlib-js/stdlib`,
57+
sorted by `updated` in descending order. Filter to PRs whose `updated_at` is
58+
within the last 7 hours. If no PRs match, call `noop` with "No recently updated
59+
PRs found" and stop.
60+
61+
Process at most 10 PRs per run.
62+
63+
## Step 2: Check for Existing Comments (Deduplication)
5064

51-
## Your Task
65+
For each PR, before analyzing it:
5266

53-
1. **Read the triggering pull request** using the GitHub tool. Note the PR title, body,
54-
and changed files. If triggered via `workflow_dispatch`, the PR number is
55-
`${{ github.event.inputs.pr_number }}`.
67+
1. List comments on the PR using the GitHub tool.
68+
2. If any comment body contains the heading `**Issue Reference Review**`, this
69+
PR was already checked. Skip it and call `noop` with "PR #X already has an
70+
Issue Reference Review comment. Skipping."
71+
3. If no such comment exists, proceed to Step 3.
5672

57-
2. **Extract all issue/PR references** from the PR body. Look for:
73+
## Step 3: Extract and Assess References
74+
75+
For each PR that passes deduplication:
76+
77+
1. **Extract all issue/PR references** from the PR body. Look for:
5878
- `#123` (bare references)
5979
- `stdlib-js/stdlib#123` (qualified references)
6080
- `https://github.com/stdlib-js/stdlib/issues/123` (URL references)
6181
- Pay special attention to closing keywords: Resolves, Closes, Fixes (and variants)
6282

63-
3. **For each referenced issue/PR**, fetch its title and body using the GitHub tool.
83+
2. **For each referenced issue/PR**, fetch its title and body using the GitHub tool.
6484

65-
4. **Assess whether each reference is plausibly related** to the pull request:
85+
3. **Assess whether each reference is plausibly related** to the pull request:
6686
- **related**: Clear topical connection (same package, same feature area, PR addresses the issue)
6787
- **suspicious**: Connection is unclear or tenuous
6888
- **unrelated**: Completely different topics, packages, or feature areas
@@ -81,6 +101,9 @@ to the PR.
81101

82102
## Safe Outputs
83103

104+
When calling `add-comment`, you **MUST** set the `item_number` parameter to the
105+
PR number so the comment is posted on the correct PR.
106+
84107
- **If ALL references appear related** (or there are no references): Call `noop` with a
85108
brief explanation like "All N issue references in PR #X appear related."
86109

@@ -106,3 +129,8 @@ to the PR.
106129
> *This assessment was generated by an AI model and is informational only.*
107130
108131
Only include suspicious/unrelated references in the table, not related ones.
132+
133+
## Important Notes
134+
135+
- Process each PR independently. A failure on one PR should not prevent checking others.
136+
- A `noop` call is expected for each PR that is skipped or has all-valid references.

0 commit comments

Comments
 (0)