mirror of
https://github.com/hwchase17/langchain.git
synced 2026-05-17 13:00:49 +00:00
Bumps [actions/github-script](https://github.com/actions/github-script) from 8.0.0 to 9.0.0. <details> <summary>Release notes</summary> <p><em>Sourced from <a href="https://github.com/actions/github-script/releases">actions/github-script's releases</a>.</em></p> <blockquote> <h2>v9.0.0</h2> <p><strong>New features:</strong></p> <ul> <li><strong><code>getOctokit</code> factory function</strong> — Available directly in the script context. Create additional authenticated Octokit clients with different tokens for multi-token workflows, GitHub App tokens, and cross-org access. See <a href="https://github.com/actions/github-script#creating-additional-clients-with-getoctokit">Creating additional clients with <code>getOctokit</code></a> for details and examples.</li> <li><strong>Orchestration ID in user-agent</strong> — The <code>ACTIONS_ORCHESTRATION_ID</code> environment variable is automatically appended to the user-agent string for request tracing.</li> </ul> <p><strong>Breaking changes:</strong></p> <ul> <li><strong><code>require('@actions/github')</code> no longer works in scripts.</strong> The upgrade to <code>@actions/github</code> v9 (ESM-only) means <code>require('@actions/github')</code> will fail at runtime. If you previously used patterns like <code>const { getOctokit } = require('@actions/github')</code> to create secondary clients, use the new injected <code>getOctokit</code> function instead — it's available directly in the script context with no imports needed.</li> <li><code>getOctokit</code> is now an injected function parameter. Scripts that declare <code>const getOctokit = ...</code> or <code>let getOctokit = ...</code> will get a <code>SyntaxError</code> because JavaScript does not allow <code>const</code>/<code>let</code> redeclaration of function parameters. Use the injected <code>getOctokit</code> directly, or use <code>var getOctokit = ...</code> if you need to redeclare it.</li> <li>If your script accesses other <code>@actions/github</code> internals beyond the standard <code>github</code>/<code>octokit</code> client, you may need to update those references for v9 compatibility.</li> </ul> <h2>What's Changed</h2> <ul> <li>Add ACTIONS_ORCHESTRATION_ID to user-agent string by <a href="https://github.com/Copilot"><code>@Copilot</code></a> in <a href="https://redirect.github.com/actions/github-script/pull/695">actions/github-script#695</a></li> <li>ci: use deployment: false for integration test environments by <a href="https://github.com/salmanmkc"><code>@salmanmkc</code></a> in <a href="https://redirect.github.com/actions/github-script/pull/712">actions/github-script#712</a></li> <li>feat!: add getOctokit to script context, upgrade <code>@actions/github</code> v9, <code>@octokit/core</code> v7, and related packages by <a href="https://github.com/salmanmkc"><code>@salmanmkc</code></a> in <a href="https://redirect.github.com/actions/github-script/pull/700">actions/github-script#700</a></li> </ul> <h2>New Contributors</h2> <ul> <li><a href="https://github.com/Copilot"><code>@Copilot</code></a> made their first contribution in <a href="https://redirect.github.com/actions/github-script/pull/695">actions/github-script#695</a></li> </ul> <p><strong>Full Changelog</strong>: <a href="https://github.com/actions/github-script/compare/v8.0.0...v9.0.0">https://github.com/actions/github-script/compare/v8.0.0...v9.0.0</a></p> </blockquote> </details> <details> <summary>Commits</summary> <ul> <li><a href="3a2844b7e9"><code>3a2844b</code></a> Merge pull request <a href="https://redirect.github.com/actions/github-script/issues/700">#700</a> from actions/salmanmkc/expose-getoctokit + prepare re...</li> <li><a href="ca10bbdd1a"><code>ca10bbd</code></a> fix: use <code>@octokit/core/</code>types import for v7 compatibility</li> <li><a href="86e48e20ac"><code>86e48e2</code></a> merge: incorporate main branch changes</li> <li><a href="c1084728b5"><code>c108472</code></a> chore: rebuild dist for v9 upgrade and getOctokit factory</li> <li><a href="afff112e4f"><code>afff112</code></a> Merge pull request <a href="https://redirect.github.com/actions/github-script/issues/712">#712</a> from actions/salmanmkc/deployment-false + fix user-ag...</li> <li><a href="ff8117e5b7"><code>ff8117e</code></a> ci: fix user-agent test to handle orchestration ID</li> <li><a href="81c6b78760"><code>81c6b78</code></a> ci: use deployment: false to suppress deployment noise from integration tests</li> <li><a href="3953caf885"><code>3953caf</code></a> docs: update README examples from <a href="https://github.com/v8"><code>@v8</code></a> to <a href="https://github.com/v9"><code>@v9</code></a>, add getOctokit docs and v9 brea...</li> <li><a href="c17d55b90d"><code>c17d55b</code></a> ci: add getOctokit integration test job</li> <li><a href="a047196d9a"><code>a047196</code></a> test: add getOctokit integration tests via callAsyncFunction</li> <li>Additional commits viewable in <a href="ed597411d8...3a2844b7e9">compare view</a></li> </ul> </details> <br /> [](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores) Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`. [//]: # (dependabot-automerge-start) [//]: # (dependabot-automerge-end) --- <details> <summary>Dependabot commands and options</summary> <br /> You can trigger Dependabot actions by commenting on this PR: - `@dependabot rebase` will rebase this PR - `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it - `@dependabot show <dependency name> ignore conditions` will show all of the ignore conditions of the specified dependency - `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself) - `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself) </details> Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
197 lines
8.6 KiB
YAML
197 lines
8.6 KiB
YAML
# Auto-close issues that bypass or ignore the issue template checkboxes.
|
||
#
|
||
# GitHub issue forms enforce `required: true` checkboxes in the web UI,
|
||
# but the API bypasses form validation entirely — bots/scripts can open
|
||
# issues with every box unchecked or skip the template altogether.
|
||
#
|
||
# Rules:
|
||
# 0. No issue type -> close unless author is an org member
|
||
# 1. No checkboxes at all -> close unless author is an org member or bot
|
||
# 2. Checkboxes present but none checked -> close
|
||
# 3. "Submission checklist" section incomplete -> close
|
||
# 4. "Package (Required)" section has no selection -> close
|
||
#
|
||
# Org membership check reuses the shared helper from pr-labeler.js and
|
||
# the same GitHub App used by tag-external-issues.yml.
|
||
|
||
name: Close Unchecked Issues
|
||
|
||
on:
|
||
issues:
|
||
types: [opened]
|
||
|
||
permissions:
|
||
contents: read
|
||
|
||
concurrency:
|
||
group: ${{ github.workflow }}-${{ github.event.issue.number }}
|
||
cancel-in-progress: true
|
||
|
||
jobs:
|
||
check-boxes:
|
||
runs-on: ubuntu-latest
|
||
permissions:
|
||
contents: read
|
||
issues: write
|
||
|
||
steps:
|
||
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
|
||
|
||
- name: Generate GitHub App token
|
||
id: app-token
|
||
uses: actions/create-github-app-token@1b10c78c7865c340bc4f6099eb2f838309f1e8c3 # v3
|
||
with:
|
||
app-id: ${{ secrets.ORG_MEMBERSHIP_APP_ID }}
|
||
private-key: ${{ secrets.ORG_MEMBERSHIP_APP_PRIVATE_KEY }}
|
||
|
||
- name: Validate issue checkboxes
|
||
if: steps.app-token.outcome == 'success'
|
||
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
|
||
with:
|
||
github-token: ${{ steps.app-token.outputs.token }}
|
||
script: |
|
||
const { owner, repo } = context.repo;
|
||
const issue_number = context.payload.issue.number;
|
||
const body = context.payload.issue.body ?? '';
|
||
const allChecked = (body.match(/- \[x\]/gi) || []).length;
|
||
const allUnchecked = (body.match(/- \[ \]/g) || []).length;
|
||
const total = allChecked + allUnchecked;
|
||
|
||
// ── Helpers ─────────────────────────────────────────────────
|
||
// Extract checkboxes under a markdown H2/H3 heading.
|
||
// Returns { checked, unchecked } counts, or null if the
|
||
// section heading is not found in the body.
|
||
function parseSection(heading) {
|
||
const escaped = heading.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
||
// Find the heading line
|
||
const headingRe = new RegExp(`^#{2,3}\\s+${escaped}\\s*$`, 'm');
|
||
const headingMatch = headingRe.exec(body);
|
||
if (!headingMatch) return null;
|
||
// Slice from after the heading to the next heading or end
|
||
const rest = body.slice(headingMatch.index + headingMatch[0].length);
|
||
const nextHeading = rest.search(/\n#{2,3}\s/);
|
||
const block = nextHeading === -1 ? rest : rest.slice(0, nextHeading);
|
||
return {
|
||
checked: (block.match(/- \[x\]/gi) || []).length,
|
||
unchecked: (block.match(/- \[ \]/g) || []).length,
|
||
};
|
||
}
|
||
|
||
let _cachedMember;
|
||
async function isOrgMember() {
|
||
if (_cachedMember) return _cachedMember;
|
||
const { h } = require('./.github/scripts/pr-labeler.js')
|
||
.loadAndInit(github, owner, repo, core);
|
||
const author = context.payload.sender.login;
|
||
const { isExternal } = await h.checkMembership(
|
||
author, context.payload.sender.type,
|
||
);
|
||
_cachedMember = { internal: !isExternal, author };
|
||
return _cachedMember;
|
||
}
|
||
|
||
async function closeWithComment(lines) {
|
||
const templateUrl = `https://github.com/${owner}/${repo}/issues/new/choose`;
|
||
lines.push(
|
||
'',
|
||
`Please use one of the [issue templates](${templateUrl}).`,
|
||
);
|
||
|
||
// Post comment first so the author sees the reason even if
|
||
// the subsequent close call fails.
|
||
await github.rest.issues.createComment({
|
||
owner, repo, issue_number,
|
||
body: lines.join('\n'),
|
||
});
|
||
|
||
await github.rest.issues.update({
|
||
owner, repo, issue_number,
|
||
state: 'closed',
|
||
state_reason: 'not_planned',
|
||
});
|
||
}
|
||
|
||
// ── Rule 0: no issue type (API/CLI bypass) ──────────────────
|
||
// Issue types are set automatically when using web UI templates.
|
||
// External users cannot set issue types via the API (requires
|
||
// write/triage permissions), so a missing type reliably indicates
|
||
// programmatic submission.
|
||
if (!context.payload.issue.type) {
|
||
let membership;
|
||
try {
|
||
membership = await isOrgMember();
|
||
} catch (e) {
|
||
// Org membership check failed — skip Rule 0 and let
|
||
// Rules 1-4 handle validation via checkboxes.
|
||
core.warning(`Rule 0: org membership check failed, skipping: ${e.message}`);
|
||
}
|
||
if (membership?.internal) {
|
||
console.log(`No issue type, but ${membership.author} is internal — OK`);
|
||
} else if (membership) {
|
||
console.log(`No issue type and ${membership.author} is external — closing`);
|
||
await closeWithComment([
|
||
'This issue was automatically closed because it appears to have been submitted programmatically — issue types are automatically set when using the GitHub web interface, and this issue has none.',
|
||
'',
|
||
'We do not allow automated issue submission at this time.',
|
||
]);
|
||
return;
|
||
}
|
||
}
|
||
|
||
// ── Rule 1: no checkboxes at all ────────────────────────────
|
||
if (total === 0) {
|
||
const { internal, author } = await isOrgMember();
|
||
if (internal) {
|
||
console.log(`No checkboxes, but ${author} is internal — OK`);
|
||
return;
|
||
}
|
||
console.log(`No checkboxes and ${author} is external — closing`);
|
||
await closeWithComment([
|
||
'This issue was automatically closed because no issue template was used.',
|
||
]);
|
||
return;
|
||
}
|
||
|
||
// ── Rule 2: checkboxes present but none checked ─────────────
|
||
if (allChecked === 0) {
|
||
console.log(`${allUnchecked} checkbox(es) present, none checked — closing`);
|
||
await closeWithComment([
|
||
'This issue was automatically closed because none of the required checkboxes were checked. Please re-file using an issue template and complete the checklist.',
|
||
]);
|
||
return;
|
||
}
|
||
|
||
// ── Rules 3–4: parse sections for targeted feedback ─────────
|
||
const checklist = parseSection('Submission checklist');
|
||
const pkg = parseSection('Package (Required)');
|
||
console.log(`Section parse — checklist: ${JSON.stringify(checklist)}, pkg: ${JSON.stringify(pkg)}`);
|
||
|
||
const problems = [];
|
||
|
||
if (checklist && checklist.unchecked > 0) {
|
||
problems.push(
|
||
'the submission checklist is incomplete — please confirm you searched for duplicates, included a reproduction, etc.'
|
||
);
|
||
}
|
||
if (pkg !== null && pkg.checked === 0) {
|
||
problems.push(
|
||
'no package was selected (e.g. langchain-core, langchain, langgraph) — this helps us route the issue to the right team'
|
||
);
|
||
} else if (pkg === null) {
|
||
problems.push(
|
||
'the package selection is missing (e.g. langchain-core, langchain, langgraph) — this helps us route the issue to the right team'
|
||
);
|
||
}
|
||
|
||
if (problems.length === 0) {
|
||
console.log(`All section checks passed (${allChecked} checked) — OK`);
|
||
return;
|
||
}
|
||
|
||
console.log(`Closing — problems: ${problems.join('; ')}`);
|
||
await closeWithComment([
|
||
'Thanks for opening an issue! It was automatically closed because:',
|
||
'',
|
||
...problems.map(p => `- ${p}`),
|
||
]);
|