@@ -74,7 +74,9 @@ async function githubApi(
7474
7575 if ( ! resp . ok ) {
7676 const text = await resp . text ( ) ;
77- throw new Error ( `GitHub API ${ resp . status } ${ resp . statusText } : ${ text } ` ) ;
77+ throw new Error (
78+ `GitHub API ${ resp . status } ${ resp . statusText } : ${ text } ` ,
79+ ) ;
7880 }
7981
8082 // 204 No Content
@@ -128,16 +130,18 @@ async function updateSourceSpec(): Promise<void> {
128130 operationId : "getStatus" ,
129131 summary : `Status v${ specVersion } ` ,
130132 responses : {
131- "200" : { description : `Returns status v${ specVersion } ` } ,
133+ "200" : {
134+ description : `Returns status v${ specVersion } ` ,
135+ } ,
132136 } ,
133137 } ,
134138 } ,
135139 } ,
136140 } ;
137141
138- const content = Buffer . from (
139- JSON . stringify ( spec , null , 2 ) + "\n ",
140- ) . toString ( "base64" ) ;
142+ const content = Buffer . from ( ` ${ JSON . stringify ( spec , null , 2 ) } \n` ) . toString (
143+ "base64 ",
144+ ) ;
141145 const sha = await getFileSha ( SOURCE_SPEC_PATH ) ;
142146
143147 await githubApi ( `/repos/${ OWNER } /${ REPO } /contents/${ SOURCE_SPEC_PATH } ` , {
@@ -241,9 +245,7 @@ async function waitForWorkflowRun(
241245 const runs : WorkflowRun [ ] = data . workflow_runs ;
242246
243247 // Find a run that started after our trigger
244- const run = runs . find (
245- ( r : any ) => new Date ( r . created_at ) > afterDate ,
246- ) ;
248+ const run = runs . find ( ( r : any ) => new Date ( r . created_at ) > afterDate ) ;
247249
248250 if ( run ) {
249251 if ( run . status === "completed" ) {
@@ -279,9 +281,7 @@ async function getPRCommitCount(prNumber: number): Promise<number> {
279281}
280282
281283async function getPRComments ( prNumber : number ) : Promise < GitHubComment [ ] > {
282- return githubApi (
283- `/repos/${ OWNER } /${ REPO } /issues/${ prNumber } /comments` ,
284- ) ;
284+ return githubApi ( `/repos/${ OWNER } /${ REPO } /issues/${ prNumber } /comments` ) ;
285285}
286286
287287async function pushConflictingCommit ( branchSha : string ) : Promise < void > {
@@ -327,26 +327,20 @@ async function pushConflictingCommit(branchSha: string): Promise<void> {
327327 } ) ;
328328
329329 // Create a commit
330- const newCommit = await githubApi (
331- `/repos/${ OWNER } /${ REPO } /git/commits` ,
332- {
333- method : "POST" ,
334- body : {
335- message : "Conflicting change to force merge conflict" ,
336- tree : tree . sha ,
337- parents : [ branchSha ] ,
338- } ,
330+ const newCommit = await githubApi ( `/repos/${ OWNER } /${ REPO } /git/commits` , {
331+ method : "POST" ,
332+ body : {
333+ message : "Conflicting change to force merge conflict" ,
334+ tree : tree . sha ,
335+ parents : [ branchSha ] ,
339336 } ,
340- ) ;
337+ } ) ;
341338
342339 // Update the branch ref
343- await githubApi (
344- `/repos/${ OWNER } /${ REPO } /git/refs/heads/${ BRANCH } ` ,
345- {
346- method : "PATCH" ,
347- body : { sha : newCommit . sha , force : true } ,
348- } ,
349- ) ;
340+ await githubApi ( `/repos/${ OWNER } /${ REPO } /git/refs/heads/${ BRANCH } ` , {
341+ method : "PATCH" ,
342+ body : { sha : newCommit . sha , force : true } ,
343+ } ) ;
350344
351345 console . log ( ` Pushed conflicting commit ${ newCommit . sha } to ${ BRANCH } ` ) ;
352346}
@@ -356,7 +350,9 @@ async function pushConflictingCommit(branchSha: string): Promise<void> {
356350async function testHappyPath ( ) : Promise < void > {
357351 console . log ( "\n=== TEST: Happy Path ===" ) ;
358352
359- console . log ( "Step 1: Update source spec and trigger workflow (first run - should create PR)" ) ;
353+ console . log (
354+ "Step 1: Update source spec and trigger workflow (first run - should create PR)" ,
355+ ) ;
360356 await updateSourceSpec ( ) ;
361357
362358 const before1 = new Date ( ) ;
@@ -379,7 +375,9 @@ async function testHappyPath(): Promise<void> {
379375 const commits1 = await getPRCommitCount ( prNumber ) ;
380376 console . log ( ` PR #${ prNumber } created with ${ commits1 } commit(s)` ) ;
381377
382- console . log ( "\nStep 2: Reset fern spec on PR branch and trigger workflow (should reuse existing PR)" ) ;
378+ console . log (
379+ "\nStep 2: Reset fern spec on PR branch and trigger workflow (should reuse existing PR)" ,
380+ ) ;
383381 // Instead of changing the source spec (which is subject to raw.githubusercontent.com CDN cache),
384382 // we reset fern/openapi/openapi.json on the update-api branch to {} so that fern api update
385383 // will write the (cached) origin content and produce a git diff.
@@ -415,7 +413,9 @@ async function testHappyPath(): Promise<void> {
415413 ) ;
416414 }
417415
418- console . log ( ` Still 1 PR (#${ prNumber } ), commits: ${ commits1 } → ${ commits2 } ` ) ;
416+ console . log (
417+ ` Still 1 PR (#${ prNumber } ), commits: ${ commits1 } → ${ commits2 } ` ,
418+ ) ;
419419 console . log ( " PASS: Happy path\n" ) ;
420420}
421421
@@ -434,12 +434,16 @@ async function testConflictPath(): Promise<void> {
434434 const branchData = await githubApi (
435435 `/repos/${ OWNER } /${ REPO } /git/refs/heads/${ BRANCH } ` ,
436436 ) ;
437- const currentSha = branchData . object . sha ;
437+ const _currentSha = branchData . object . sha ;
438438
439- console . log ( "Step 1: Reset fern spec on PR branch so fern api update will produce a diff" ) ;
439+ console . log (
440+ "Step 1: Reset fern spec on PR branch so fern api update will produce a diff" ,
441+ ) ;
440442 await resetFernSpec ( BRANCH ) ;
441443
442- console . log ( "Step 2: Trigger workflow and push conflicting commit during fern install window" ) ;
444+ console . log (
445+ "Step 2: Trigger workflow and push conflicting commit during fern install window" ,
446+ ) ;
443447 // The workflow takes ~5-10s to install fern-api. During this window,
444448 // we push a commit to origin/update-api that the action won't have locally,
445449 // causing its subsequent push to fail (remote has commits the local doesn't).
@@ -448,7 +452,9 @@ async function testConflictPath(): Promise<void> {
448452
449453 // Wait for the workflow to start and pull the branch, then push a conflicting commit.
450454 // The fern-api install takes ~5-10s, so we have a window.
451- console . log ( " Waiting 12s for workflow to pull branch before pushing conflict..." ) ;
455+ console . log (
456+ " Waiting 12s for workflow to pull branch before pushing conflict..." ,
457+ ) ;
452458 await sleep ( 12000 ) ;
453459
454460 // Get the updated SHA (after resetFernSpec added a commit)
@@ -473,14 +479,13 @@ async function testConflictPath(): Promise<void> {
473479 console . log ( "Step 3: Check for conflict comment on PR" ) ;
474480 const comments = await getPRComments ( pr . number ) ;
475481 const conflictComment = comments . find (
476- ( c ) => c . body . includes ( "Sync failed" ) || c . body . includes ( "Rebase error" ) ,
482+ ( c ) =>
483+ c . body . includes ( "Sync failed" ) || c . body . includes ( "Rebase error" ) ,
477484 ) ;
478485
479486 if ( conflictComment ) {
480487 console . log ( ` Found conflict comment on PR #${ pr . number } :` ) ;
481- console . log (
482- ` ${ conflictComment . body . substring ( 0 , 200 ) } ...` ,
483- ) ;
488+ console . log ( ` ${ conflictComment . body . substring ( 0 , 200 ) } ...` ) ;
484489 console . log ( " PASS: Conflict path - error comment posted\n" ) ;
485490 } else if ( run . conclusion === "failure" ) {
486491 console . log (
0 commit comments