fix(tools): remove linked issue check (#68470)

This commit is contained in:
majestic-owl448
2026-08-20 20:46:53 +02:00
committed by GitHub
parent 92df061486
commit c77b18edcd
3 changed files with 5 additions and 137 deletions
@@ -1,84 +0,0 @@
'use strict';
async function addDeprioritizedLabel(github, context) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ['deprioritized']
});
}
module.exports = async ({ github, context, core, isAllowListed }) => {
if (isAllowListed === 'true') return;
const result = await github.graphql(
`query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
closingIssuesReferences(first: 10) {
nodes {
number
labels(first: 10) { nodes { name } }
assignees(first: 10) { nodes { login } }
}
}
}
}
}`,
{
owner: context.repo.owner,
repo: context.repo.repo,
number: context.payload.pull_request.number
}
);
const pr = result.repository?.pullRequest;
if (!pr) return;
const linkedIssues = pr.closingIssuesReferences.nodes;
if (linkedIssues.length === 0) {
core.setOutput('failure_reason', 'no_linked_issue');
core.setFailed('No linked issue found.');
await addDeprioritizedLabel(github, context);
return;
}
const hasWaitingTriage = linkedIssues.some(issue =>
issue.labels.nodes.some(l => l.name === 'status: waiting triage')
);
if (hasWaitingTriage) {
core.setOutput('failure_reason', 'waiting_triage');
core.setFailed('Linked issue has not been triaged yet.');
await addDeprioritizedLabel(github, context);
return;
}
const prAuthor = context.payload.pull_request.user.login;
const isNaomiSprintAssignee = linkedIssues.some(
issue =>
issue.labels.nodes.some(l => l.name === "Naomi's Sprints") &&
issue.assignees.nodes.some(a => a.login === prAuthor)
);
if (isNaomiSprintAssignee) {
await github.rest.issues.addLabels({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.payload.pull_request.number,
labels: ["Naomi's Sprints"]
});
return;
}
const isOpenForContribution = linkedIssues.some(issue =>
issue.labels.nodes.some(
l => l.name === 'help wanted' || l.name === 'first timers only'
)
);
if (!isOpenForContribution) {
core.setOutput('failure_reason', 'not_open_for_contribution');
core.setFailed('Linked issue is not open for contribution.');
await addDeprioritizedLabel(github, context);
}
};
@@ -33,32 +33,11 @@ const MESSAGES = {
'Please edit your PR description to include the following template with the checklist items completed.',
'',
TEMPLATE_BLOCK
].join('\n'),
no_linked_issue: [
'**Linked Issue:** We kindly ask that contributors open an issue before submitting a PR so the change can be discussed and approved before work begins. This helps avoid situations where significant effort goes into something we ultimately cannot merge.',
'',
'Please open an issue first and allow it to be triaged. Once the issue is open for contribution, you are welcome to update this pull request to reflect the issue consensus. Until then, we will not be able to review your pull request.'
].join('\n'),
waiting_triage: [
'**Linked Issue:** The linked issue has not been triaged yet, and a solution has not been agreed upon. Once the issue is open for contribution, you are welcome to update this pull request to reflect the issue consensus. Until then, we will not be able to review your pull request.'
].join('\n'),
not_open_for_contribution:
'**Linked Issue:** The linked issue is not open for contribution. If you are looking for issues to contribute to, please check out issues labeled [`help wanted`](https://github.com/freeCodeCamp/freeCodeCamp/issues?q=is%3Aissue+is%3Aopen+label%3A%22help+wanted%22) or [`first timers only`](https://github.com/freeCodeCamp/freeCodeCamp/issues?q=is%3Aissue+is%3Aopen+label%3A%22first+timers+only%22).'
].join('\n')
};
module.exports = async ({
github,
context,
templateResult,
templateReason,
linkedIssueResult,
linkedIssueReason
}) => {
const allPassed =
templateResult === 'success' && linkedIssueResult === 'success';
module.exports = async ({ github, context, templateResult, templateReason }) => {
const allPassed = templateResult === 'success';
if (allPassed) {
try {
@@ -81,9 +60,6 @@ module.exports = async ({
if (templateResult === 'failure' && MESSAGES[templateReason]) {
sections.push(MESSAGES[templateReason]);
}
if (linkedIssueResult === 'failure' && MESSAGES[linkedIssueReason]) {
sections.push(MESSAGES[linkedIssueReason]);
}
if (sections.length === 0) return;
+2 -26
View File
@@ -183,34 +183,12 @@ jobs:
const fn = require('./.github/scripts/pr-guidelines/check-pr-template.js');
await fn({ github, context, core, isAllowListed: '${{ needs.no-web-commits.outputs.is_allow_listed }}' });
# Verifies that each PR references a linked, triaged issue before it can be reviewed.
check-linked-issue:
name: Check Linked Issue
runs-on: ubuntu-24.04
needs: [no-web-commits, no-main-branch]
if: needs.no-web-commits.result == 'success' && needs.no-main-branch.result == 'success'
outputs:
failure_reason: ${{ steps.check.outputs.failure_reason }}
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
with:
sparse-checkout: .github/scripts/pr-guidelines
sparse-checkout-cone-mode: false
- id: check
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const fn = require('./.github/scripts/pr-guidelines/check-linked-issue.js');
await fn({ github, context, core, isAllowListed: '${{ needs.no-web-commits.outputs.is_allow_listed }}' });
# Coordinates reporting: posts a single combined comment when checks fail,
# or removes the deprioritized label when all checks pass.
report:
name: Report
runs-on: ubuntu-24.04
needs: [no-web-commits, no-main-branch, check-pr-template, check-linked-issue]
needs: [no-web-commits, no-main-branch, check-pr-template]
if: always() && needs.no-web-commits.result == 'success' && needs.no-main-branch.result == 'success'
steps:
- uses: actions/checkout@d23441a48e516b6c34aea4fa41551a30e30af803 # v6
@@ -227,7 +205,5 @@ jobs:
github,
context,
templateResult: '${{ needs.check-pr-template.result }}',
templateReason: '${{ needs.check-pr-template.outputs.failure_reason }}',
linkedIssueResult: '${{ needs.check-linked-issue.result }}',
linkedIssueReason: '${{ needs.check-linked-issue.outputs.failure_reason }}'
templateReason: '${{ needs.check-pr-template.outputs.failure_reason }}'
});