Skip to content

Beautiful, AI-native markdown IDE and LLM wiki

Trigger OK CLA refresh by dispatch instead of every commit status (#6760)

Andrew Mikofalvy2f8a3122523a
diff --git a/.github/scripts/bridge-public-pr-to-monorepo.mjs b/.github/scripts/bridge-public-pr-to-monorepo.mjs
index 2a3a40f17..5239f9745 100644
--- a/.github/scripts/bridge-public-pr-to-monorepo.mjs
+++ b/.github/scripts/bridge-public-pr-to-monorepo.mjs
@@ -10,6 +10,7 @@ const OSS_SYNC_BOT_NAME = 'inkeep-oss-sync[bot]';
const OSS_SYNC_BOT_EMAIL = '274976938+inkeep-oss-sync[bot]@users.noreply.github.com';
const MAX_COMMAND_ERROR_LENGTH = 4096;
const MAX_COMMAND_LABEL_LENGTH = 256;
+const CLA_VERIFIED_DISPATCH_EVENT = 'ok-cla-verified';
function sanitizeErrorMessage(value) {
if (typeof value !== 'string') return value;
@@ -617,8 +618,8 @@ function createClaGateGh({
isOrgMember: (login) => checkOrgMembership({ token: internalToken, org, login, request }),
setDraft: (pr, shouldBeDraft) =>
ensureDraftState({ token: internalToken, pullRequest: pr, shouldBeDraft }),
- setVerifiedStatus: (pr, state, description) =>
- postCommitStatus({
+ setVerifiedStatus: async (pr, state, description) => {
+ await postCommitStatus({
token: internalToken,
repo: internalRepo,
sha: pr.head.sha,
@@ -626,7 +627,16 @@ function createClaGateGh({
context: 'cla/verified',
description,
request,
- }),
+ });
+ if (state === 'success') {
+ await request({
+ token: internalToken,
+ method: 'POST',
+ path: `/repos/${internalRepo}/dispatches`,
+ body: { event_type: CLA_VERIFIED_DISPATCH_EVENT, client_payload: { sha: pr.head.sha } },
+ });
+ }
+ },
};
}
@@ -1140,6 +1150,7 @@ export {
buildCommitAttribution,
buildInternalPrBody,
buildWelcomePublicComment,
+ CLA_VERIFIED_DISPATCH_EVENT,
checkOrgMembership,
commitIndicatesConflicts,
createClaGateGh,
diff --git a/.github/scripts/bridge-public-pr-to-monorepo.test.mjs b/.github/scripts/bridge-public-pr-to-monorepo.test.mjs
index 63fcc04fc..31cfc4d61 100644
--- a/.github/scripts/bridge-public-pr-to-monorepo.test.mjs
+++ b/.github/scripts/bridge-public-pr-to-monorepo.test.mjs
@@ -9,6 +9,7 @@ import * as bridge from './bridge-public-pr-to-monorepo.mjs';
import {
applyPatchWithConflictDetection,
bridgeCommitSubject,
+ CLA_VERIFIED_DISPATCH_EVENT,
buildCommitAttribution,
buildWelcomePublicComment,
checkOrgMembership,
@@ -347,6 +348,35 @@ describe('createClaGateGh', () => {
});
});
+ test('a successful setVerifiedStatus then signals the internal refresh for that head', async () => {
+ const { request, calls } = fakeRequest(null);
+ const gh = createClaGateGh({ ...deps, request });
+ await gh.setVerifiedStatus({ head: { sha: 'internal-head' } }, 'success', 'CLA signed.');
+ expect(calls).toHaveLength(2);
+ expect(calls[0].path).toBe('/repos/inkeep/agents-private/statuses/internal-head');
+ expect(calls[1]).toMatchObject({
+ token: 'internal-token',
+ method: 'POST',
+ path: '/repos/inkeep/agents-private/dispatches',
+ body: { event_type: CLA_VERIFIED_DISPATCH_EVENT, client_payload: { sha: 'internal-head' } },
+ });
+ });
+
+ test('a failed status post sends no refresh signal', async () => {
+ const calls = [];
+ const request = async (args) => {
+ calls.push(args);
+ throw new Error('forbidden (403)');
+ };
+ const gh = createClaGateGh({ ...deps, request });
+ await expect(
+ gh.setVerifiedStatus({ head: { sha: 'internal-head' } }, 'success', 'CLA signed.'),
+ ).rejects.toThrow(/403/);
+ expect(calls.map((call) => call.path)).toEqual([
+ '/repos/inkeep/agents-private/statuses/internal-head',
+ ]);
+ });
+
test("isOrgMember checks the internal repo's org on the internal token", async () => {
const { request, calls } = fakeRequest(null);
const gh = createClaGateGh({ ...deps, request });
@@ -547,6 +577,7 @@ async function runBridgeSync({
draftMutation: null,
comment: null,
statuses: [],
+ dispatches: [],
validationRequests: [],
internalBodies: [],
};
@@ -696,6 +727,14 @@ async function runBridgeSync({
});
return json({});
}
+ if (method === 'POST' && url.endsWith('/repos/inkeep/agents-private/dispatches')) {
+ recorded.dispatches.push({
+ authorization: init.headers.Authorization,
+ afterStatus: recorded.statuses.at(-1),
+ ...JSON.parse(init.body),
+ });
+ return json(null, 204);
+ }
if (method === 'POST' && url.includes('/issues/310/comments')) {
recorded.comment = JSON.parse(init.body).body;
return json({ html_url: 'https://github.com/x/comments/1' });
@@ -762,9 +801,25 @@ describe('syncPublicPr metadata-event composition (conflict-hold fail-open guard
});
describe('bridge CLA status refresh', () => {
- test('a successful sync only posts status and never drives Actions', async () => {
+ test('a successful sync signals the internal refresh and never drives Actions', async () => {
const result = await runBridgeSync({ claStatus: 'success' });
expect(result.validationRequests).toEqual([]);
+ const status = result.statuses.at(-1);
+ expect(status).toMatchObject({ context: 'cla/verified', state: 'success' });
+ expect(result.dispatches).toEqual([
+ {
+ authorization: 'Bearer int',
+ afterStatus: status,
+ event_type: CLA_VERIFIED_DISPATCH_EVENT,
+ client_payload: { sha: status.sha },
+ },
+ ]);
+ });
+
+ test('an unsigned sync sends no refresh signal', async () => {
+ const result = await runBridgeSync({ claStatus: 'failure' });
+ expect(result.statuses.at(-1)).toMatchObject({ state: 'failure' });
+ expect(result.dispatches).toEqual([]);
});
test.each(['success', 'failure', 'pending', null])(
@@ -782,6 +837,16 @@ describe('bridge CLA status refresh', () => {
state: claStatus === 'success' ? 'success' : 'failure',
}),
]);
+ expect(result.dispatches).toEqual(
+ claStatus === 'success'
+ ? [
+ expect.objectContaining({
+ event_type: CLA_VERIFIED_DISPATCH_EVENT,
+ client_payload: { sha: 'internal-head-sha' },
+ }),
+ ]
+ : [],
+ );
expect(result.validationRequests).toEqual([]);
expect(result.internalBodies).toEqual([]);
},
@@ -812,6 +877,7 @@ describe('bridge CLA status refresh', () => {
...overrides,
});
expect(result.statuses).toEqual([]);
+ expect(result.dispatches).toEqual([]);
expect(result.draftMutation).toBeNull();
expect(result.internalBodies).toEqual([]);
});