@@ -16,28 +16,6 @@ const DEFAULT_INPUTS = {
1616 rerun_group : "all" ,
1717 reuse_evidence : "true" ,
1818} ;
19- const WORKFLOW_RUN_CHECK_SUITE_QUERY = `
20- query($owner: String!, $repo: String!, $oid: GitObjectID!, $after: String) {
21- repository(owner: $owner, name: $repo) {
22- object(oid: $oid) {
23- ... on Commit {
24- checkSuites(first: 100, after: $after) {
25- nodes {
26- status
27- conclusion
28- workflowRun {
29- url
30- }
31- }
32- pageInfo {
33- hasNextPage
34- endCursor
35- }
36- }
37- }
38- }
39- }
40- }` ;
4119
4220function usage ( ) {
4321 console . error ( `Usage: node scripts/full-release-validation-at-sha.mjs [--sha <target-sha>] [--target-ref <canonical-release-branch-or-tag>] [--workflow-sha <trusted-main-ref>] [--keep-branch] [--dry-run] [-- -f key=value ...]
@@ -282,50 +260,19 @@ function findLatestRunId(branch, sha) {
282260 return match ?. databaseId ? String ( match . databaseId ) : "" ;
283261}
284262
285- export function selectWorkflowRunCheckSuite ( nodes , parentRunId ) {
263+ function readWorkflowRun ( parentRunId , workflowSha ) {
286264 if ( ! / ^ [ 1 - 9 ] [ 0 - 9 ] * $ / u. test ( String ( parentRunId ) ) ) {
287265 throw new Error ( "parent run ID must be a positive decimal" ) ;
288266 }
289- const expectedUrl = `https://github.com/openclaw/openclaw/actions/runs/${ parentRunId } ` ;
290- return nodes . find ( ( node ) => node ?. workflowRun ?. url === expectedUrl ) ;
291- }
292-
293- function readWorkflowRunCheckSuite ( parentRunId , workflowSha ) {
294- let after ;
295- for ( let page = 0 ; page < 20 ; page += 1 ) {
296- const queryArgs = [
297- "api" ,
298- "graphql" ,
299- "-F" ,
300- "owner=openclaw" ,
301- "-F" ,
302- "repo=openclaw" ,
303- "-F" ,
304- `oid=${ workflowSha } ` ,
305- "-f" ,
306- `query=${ WORKFLOW_RUN_CHECK_SUITE_QUERY } ` ,
307- ] ;
308- if ( after ) {
309- queryArgs . push ( "-F" , `after=${ after } ` ) ;
310- }
311- const response = JSON . parse ( run ( "gh" , queryArgs ) ) ;
312- const checkSuites = response ?. data ?. repository ?. object ?. checkSuites ;
313- if ( ! checkSuites || ! Array . isArray ( checkSuites . nodes ) ) {
314- throw new Error ( "GraphQL response did not include commit check suites" ) ;
315- }
316- const match = selectWorkflowRunCheckSuite ( checkSuites . nodes , parentRunId ) ;
317- if ( match ) {
318- return match ;
319- }
320- if ( ! checkSuites . pageInfo ?. hasNextPage ) {
321- return undefined ;
322- }
323- after = checkSuites . pageInfo . endCursor ;
324- if ( ! after ) {
325- throw new Error ( "GraphQL check-suite pagination omitted its end cursor" ) ;
326- }
267+ const workflowRun = JSON . parse (
268+ run ( "gh" , [ "api" , `repos/openclaw/openclaw/actions/runs/${ parentRunId } ` ] ) ,
269+ ) ;
270+ if ( workflowRun . head_sha !== workflowSha ) {
271+ throw new Error (
272+ `Full Release Validation run ${ parentRunId } head ${ String ( workflowRun . head_sha ) } does not match trusted workflow SHA ${ workflowSha } ` ,
273+ ) ;
327274 }
328- throw new Error ( "Full Release Validation check suite was not found within 20 pages" ) ;
275+ return workflowRun ;
329276}
330277
331278function waitForWorkflowRun ( parentRunId , workflowSha ) {
@@ -334,7 +281,7 @@ function waitForWorkflowRun(parentRunId, workflowSha) {
334281 for ( let attempt = 0 ; attempt < 480 ; attempt += 1 ) {
335282 let suite ;
336283 try {
337- suite = readWorkflowRunCheckSuite ( parentRunId , workflowSha ) ;
284+ suite = readWorkflowRun ( parentRunId , workflowSha ) ;
338285 consecutiveErrors = 0 ;
339286 } catch ( error ) {
340287 consecutiveErrors += 1 ;
@@ -345,15 +292,13 @@ function waitForWorkflowRun(parentRunId, workflowSha) {
345292 console . warn ( `Parent run status query failed; retrying: ${ message } ` ) ;
346293 }
347294
348- const summary = suite
349- ? `${ String ( suite . status ) . toLowerCase ( ) } /${ String ( suite . conclusion ?? "pending" ) . toLowerCase ( ) } `
350- : "awaiting-check-suite" ;
295+ const summary = `${ String ( suite ?. status ?? "pending" ) . toLowerCase ( ) } /${ String ( suite ?. conclusion ?? "pending" ) . toLowerCase ( ) } ` ;
351296 if ( summary !== lastSummary ) {
352297 console . log ( `Parent run status: ${ summary } ` ) ;
353298 lastSummary = summary ;
354299 }
355- if ( suite ?. status === "COMPLETED " ) {
356- if ( suite . conclusion === "SUCCESS " ) {
300+ if ( suite ?. status === "completed " ) {
301+ if ( suite . conclusion === "success " ) {
357302 return ;
358303 }
359304 throw new Error (
0 commit comments