@@ -83,53 +83,59 @@ export async function submitFeedback(
8383
8484export async function createSubmission ( token : string ) {
8585 const gradingServerURL = getInput ( 'grading_server' )
86- const response = await fetch (
87- `${ gradingServerURL } /functions/v1/autograder-create-submission` ,
88- {
89- method : 'POST' ,
90- headers : {
91- 'Content-Type' : 'application/json' ,
92- Authorization : `${ token } `
86+
87+ return retryWithExponentialBackoff ( async ( ) => {
88+ const response = await fetch (
89+ `${ gradingServerURL } /functions/v1/autograder-create-submission` ,
90+ {
91+ method : 'POST' ,
92+ headers : {
93+ 'Content-Type' : 'application/json' ,
94+ Authorization : `${ token } `
95+ }
9396 }
94- }
95- )
96- if ( ! response . ok ) {
97- throw new Error ( `Failed to create submission: ${ response . statusText } ` )
98- }
99- const resp = ( await response . json ( ) ) as SubmissionResponse
100- if ( resp . error ) {
101- throw new Error (
102- `Failed to create submission: ${ resp . error . message } ${ resp . error . details } `
10397 )
104- }
105- return resp
98+ if ( ! response . ok ) {
99+ throw new Error ( `Failed to create submission: ${ response . statusText } ` )
100+ }
101+ const resp = ( await response . json ( ) ) as SubmissionResponse
102+ if ( resp . error ) {
103+ throw new Error (
104+ `Failed to create submission: ${ resp . error . message } ${ resp . error . details } `
105+ )
106+ }
107+ return resp
108+ } )
106109}
107110
108111export async function createRegressionTestRun (
109112 token : string ,
110113 regression_test_id : number
111114) {
112115 const gradingServerURL = getInput ( 'grading_server' )
113- const response = await fetch (
114- `${ gradingServerURL } /functions/v1/autograder-create-regression-test-run/${ regression_test_id } ` ,
115- {
116- method : 'POST' ,
117- headers : {
118- 'Content-Type' : 'application/json' ,
119- Authorization : `${ token } `
116+
117+ return retryWithExponentialBackoff ( async ( ) => {
118+ const response = await fetch (
119+ `${ gradingServerURL } /functions/v1/autograder-create-regression-test-run/${ regression_test_id } ` ,
120+ {
121+ method : 'POST' ,
122+ headers : {
123+ 'Content-Type' : 'application/json' ,
124+ Authorization : `${ token } `
125+ }
120126 }
121- }
122- )
123- if ( ! response . ok ) {
124- throw new Error (
125- `Failed to create regression test run: ${ response . statusText } `
126127 )
127- }
128- const resp = ( await response . json ( ) ) as RegressionTestRunResponse
129- if ( resp . error ) {
130- throw new Error (
131- `Failed to create regression test run: ${ resp . error . message } ${ resp . error . details } `
132- )
133- }
134- return resp
128+ if ( ! response . ok ) {
129+ throw new Error (
130+ `Failed to create regression test run: ${ response . statusText } `
131+ )
132+ }
133+ const resp = ( await response . json ( ) ) as RegressionTestRunResponse
134+ if ( resp . error ) {
135+ throw new Error (
136+ `Failed to create regression test run: ${ resp . error . message } ${ resp . error . details } `
137+ )
138+ }
139+ return resp
140+ } )
135141}
0 commit comments