@@ -12,6 +12,7 @@ import {
1212import { MergeConflictsFatalError } from '../../../../ng-dev/pr/merge/failures.js' ;
1313import { createPullRequestValidationConfig } from '../../../../ng-dev/pr/common/validation/validation-config.js' ;
1414import { InvalidTargetLabelError } from '../../../../ng-dev/pr/common/targeting/target-label.js' ;
15+ import { resolve } from 'path' ;
1516
1617interface CommmitStatus {
1718 state : 'pending' | 'error' | 'failure' | 'success' ;
@@ -50,27 +51,40 @@ const sha = await (async () => {
5051} ) ( ) ;
5152
5253/** Set the mergability status on the pull request provided in the environment. */
53- async function setMergeabilityStatusOnPullRequest ( { state, description, targetUrl} : CommmitStatus ) {
54- await git . github . repos . createCommitStatus ( {
55- owner,
56- repo,
57- sha,
58- context : statusContextName ,
59- state,
60- // Status descriptions are limited to 140 characters.
61- description : description . substring ( 0 , 139 ) ,
62- target_url : targetUrl ,
63- } ) ;
54+ async function setMergeabilityStatusOnPullRequest (
55+ { state, description, targetUrl} : CommmitStatus ,
56+ canRetry = true ,
57+ ) {
58+ try {
59+ await git . github . repos . createCommitStatus ( {
60+ owner,
61+ repo,
62+ sha,
63+ context : statusContextName ,
64+ state,
65+ // Status descriptions are limited to 140 characters.
66+ description : description . substring ( 0 , 139 ) ,
67+ target_url : targetUrl ,
68+ } ) ;
69+ } catch {
70+ if ( canRetry ) {
71+ await new Promise ( ( resolve ) => setTimeout ( resolve , 5000 ) ) ;
72+ await setMergeabilityStatusOnPullRequest ( { state, description, targetUrl} , false ) ;
73+ }
74+ }
6475}
6576
6677async function main ( ) {
6778 try {
6879 // This is intentionally not awaited because we are just setting the status to pending, and wanting
6980 // to continue working.
70- let _unawaitedPromise = setMergeabilityStatusOnPullRequest ( {
71- state : 'pending' ,
72- description : 'Mergability check in progress' ,
73- } ) ;
81+ let _unawaitedPromise = setMergeabilityStatusOnPullRequest (
82+ {
83+ state : 'pending' ,
84+ description : 'Mergability check in progress' ,
85+ } ,
86+ false ,
87+ ) ;
7488
7589 // Create a tmp directory to perform checks in and change working to directory to it.
7690 await cloneRepoIntoTmpLocation ( { owner, repo} ) ;
0 commit comments