@@ -2,7 +2,6 @@ const assert = require("node:assert/strict");
22const test = require ( "node:test" ) ;
33
44const {
5- renderComment,
65 resolve,
76 upsertCommentForCurrentHead,
87 validateResult,
@@ -53,39 +52,6 @@ test("validates the fixed artifact schema", () => {
5352 ) ;
5453} ) ;
5554
56- test ( "renders baseline, impact, ceiling, and ceiling changes" , ( ) => {
57- const baseline = result ( ) ;
58- const current = result ( { measuredTurnWebSocketWireBytes : 260_000 } ) ;
59- current . providers . codex . ceiling = {
60- ...current . providers . codex . ceiling ,
61- measuredTurnWebSocketWireBytes : 330_000 ,
62- } ;
63- const comment = renderComment ( {
64- current,
65- baseline,
66- currentRun : {
67- sha : "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb" ,
68- conclusion : "success" ,
69- url : "https://github.com/pingdotgg/t3code/actions/runs/2" ,
70- } ,
71- baselineRun : {
72- sha : "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa" ,
73- matchesBase : true ,
74- url : "https://github.com/pingdotgg/t3code/actions/runs/1" ,
75- } ,
76- } ) ;
77-
78- assert . match ( comment , / M a i n b a s e l i n e \| T h i s P R \| I m p a c t \| P R c e i l i n g / ) ;
79- assert . match ( comment , / \+ 9 \. 8 K i B \( \+ 4 \. 0 % \) / ) ;
80- assert . match ( comment , / T h i s P R c h a n g e s t r a n s f e r c e i l i n g s / ) ;
81- assert . match ( comment , / 3 1 2 \. 5 K i B → 3 2 2 \. 3 K i B / ) ;
82- assert . match ( comment , / < ! - - t 3 - t h r e a d - t r a n s f e r - r e p o r t - - > / ) ;
83- assert . match (
84- comment ,
85- / < ! - - t 3 - t h r e a d - t r a n s f e r - r e s u l t - s h a : b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b b - - > / ,
86- ) ;
87- } ) ;
88-
8955test ( "resolves a fallback PR with a redacted head repo and exact main baseline" , async ( ) => {
9056 const outputs = { } ;
9157 const listWorkflowRunArtifacts = ( ) => { } ;
@@ -216,6 +182,47 @@ test("does not guess when a fallback commit belongs to multiple PRs", async () =
216182 assert . equal ( fetchedPull , false ) ;
217183} ) ;
218184
185+ test ( "skips a missing PR commit but preserves other lookup failures" , async ( ) => {
186+ for ( const [ status , message , shouldSkip ] of [
187+ [ 422 , "No commit found for SHA: old-head" , true ] ,
188+ [ 422 , "Validation Failed" , false ] ,
189+ [ 403 , "API rate limit exceeded" , false ] ,
190+ ] ) {
191+ const outputs = { } ;
192+ const error = Object . assign ( new Error ( message ) , {
193+ status,
194+ response : { data : { message } } ,
195+ } ) ;
196+ const run = resolve ( {
197+ github : {
198+ paginate : async ( ) => {
199+ throw error ;
200+ } ,
201+ rest : { repos : { listPullRequestsAssociatedWithCommit : ( ) => { } } } ,
202+ } ,
203+ context : {
204+ repo : { owner : "pingdotgg" , repo : "t3code" } ,
205+ payload : {
206+ workflow_run : { event : "pull_request" , head_sha : "old-head" , pull_requests : [ ] } ,
207+ } ,
208+ } ,
209+ core : {
210+ info : ( ) => { } ,
211+ setOutput : ( key , value ) => {
212+ outputs [ key ] = value ;
213+ } ,
214+ } ,
215+ } ) ;
216+ if ( shouldSkip ) {
217+ await run ;
218+ assert . equal ( outputs . publish , "false" ) ;
219+ } else {
220+ await assert . rejects ( run , ( caught ) => caught === error ) ;
221+ assert . deepEqual ( outputs , { } ) ;
222+ }
223+ }
224+ } ) ;
225+
219226test ( "does not report a passing run that skipped the server tests" , async ( ) => {
220227 const outputs = { } ;
221228 const listWorkflowRunArtifacts = ( ) => { } ;
@@ -332,21 +339,3 @@ test("preserves a successful result when a same-SHA rerun has no artifact", asyn
332339 assert . equal ( published , true ) ;
333340 assert . equal ( updatedComment , false ) ;
334341} ) ;
335-
336- test ( "accepts V2 without comparing it to the V1 scenario" , ( ) => {
337- const current = result ( ) ;
338- current . scenario . id = "thread-transfer-v2" ;
339- current . providers . codex . ceiling = { ...current . providers . codex . ceiling , totalWireBytes : 3000000 } ;
340- assert . equal ( validateResult ( current ) , current ) ;
341- const comment = renderComment ( {
342- current,
343- baseline : result ( ) ,
344- currentRun : { sha : "bbbbbbbb" , conclusion : "success" , url : "https://example.com/current" } ,
345- baselineRun : { sha : "aaaaaaaa" , matchesBase : true , url : "https://example.com/baseline" } ,
346- } ) ;
347- assert . match ( comment , / f i x t u r e c h a n g e d / ) ;
348- assert . doesNotMatch ( comment , / T h i s P R c h a n g e s t r a n s f e r c e i l i n g s / ) ;
349- assert . doesNotMatch ( comment , / [ + - ] \d + \. \d + % / ) ;
350- current . scenario . id = "unrecognized" ;
351- assert . throws ( ( ) => validateResult ( current ) , / n o t s u p p o r t e d / ) ;
352- } ) ;
0 commit comments