@@ -138,7 +138,7 @@ const FYI_CHECK_NAMES = [
138
138
"Swagger BreakingChange" ,
139
139
"Swagger PrettierCheck" ,
140
140
] ;
141
- const AUTOMATED_CHECK_NAME = "Automated merging requirements met" ;
141
+ const AUTOMATED_CHECK_NAME = "[TEST-IGNORE] Automated merging requirements met" ;
142
142
const NEXT_STEPS_COMMENT_ID = "NextStepsToMerge" ;
143
143
144
144
/** @type {CheckMetadata[] } */
@@ -370,15 +370,15 @@ export async function summarizeChecksImpl(
370
370
371
371
outputRunDetails ( core , requiredCheckRuns , fyiCheckRuns ) ;
372
372
373
- if ( ! impactAssessment ) {
373
+ if ( impactAssessment ) {
374
+ core . info ( `ImpactAssessment: ${ JSON . stringify ( impactAssessment ) } ` ) ;
375
+ } else {
374
376
core . info (
375
- "Bailing out early without taking any further action, PR impact assessment is not yet complete." ,
377
+ `No impact assessment found for ${ owner } /${ repo } #${ issue_number } . ` +
378
+ `No labels will be added or removed in this run, and only "pending" status check will be set.` ,
376
379
) ;
377
- return ;
378
380
}
379
381
380
- core . info ( `ImpactAssessment: ${ JSON . stringify ( impactAssessment ) } ` ) ;
381
-
382
382
let labelContext = await updateLabels ( labelNames , impactAssessment ) ;
383
383
384
384
core . info (
@@ -425,6 +425,7 @@ export async function summarizeChecksImpl(
425
425
targetBranch ,
426
426
requiredCheckRuns ,
427
427
fyiCheckRuns ,
428
+ impactAssessment !== undefined ,
428
429
) ;
429
430
430
431
core . info (
@@ -441,15 +442,7 @@ export async function summarizeChecksImpl(
441
442
// )
442
443
443
444
// finally, update the "Automated merging requirements met" commit status
444
- await updateCommitStatus (
445
- github ,
446
- core ,
447
- owner ,
448
- repo ,
449
- head_sha ,
450
- "[TEST-IGNORE] Automated merging requirements met" ,
451
- automatedChecksMet ,
452
- ) ;
445
+ await updateCommitStatus ( github , core , owner , repo , head_sha , automatedChecksMet ) ;
453
446
454
447
core . info (
455
448
`Summarize checks has identified that status of "[TEST-IGNORE] Automated merging requirements met" commit status should be updated to: ${ JSON . stringify ( automatedChecksMet ) } .` ,
@@ -463,19 +456,10 @@ export async function summarizeChecksImpl(
463
456
* @param {string } owner
464
457
* @param {string } repo
465
458
* @param {string } head_sha
466
- * @param {string } statusContext
467
459
* @param {CheckRunResult } checkResult
468
460
* @returns {Promise<void> }
469
461
*/
470
- export async function updateCommitStatus (
471
- github ,
472
- core ,
473
- owner ,
474
- repo ,
475
- head_sha ,
476
- statusContext ,
477
- checkResult ,
478
- ) {
462
+ export async function updateCommitStatus ( github , core , owner , repo , head_sha , checkResult ) {
479
463
// Map CheckRunResult status to commit status state
480
464
/** @type {"pending" | "success" | "failure" | "error" } */
481
465
let state ;
@@ -497,12 +481,12 @@ export async function updateCommitStatus(
497
481
checkResult . summary . length > 140
498
482
? checkResult . summary . substring ( 0 , 137 ) + "..."
499
483
: checkResult . summary ,
500
- context : statusContext ,
484
+ context : checkResult . name ,
501
485
// target_url: undefined, // Optional: add a URL if you want to link to more details
502
486
} ) ;
503
487
504
488
core . info (
505
- `Created commit status for ${ statusContext } with state: ${ state } and description: ${ checkResult . summary } ` ,
489
+ `Created commit status for ${ checkResult . name } with state: ${ state } and description: ${ checkResult . summary } ` ,
506
490
) ;
507
491
}
508
492
@@ -775,7 +759,7 @@ export function checkRunIsSuccessful(checkRun) {
775
759
* @param {any } response - GraphQL response data
776
760
* @returns {[CheckRunData[], CheckRunData[], number | undefined] }
777
761
*/
778
- function extractRunsFromGraphQLResponse ( response ) {
762
+ export function extractRunsFromGraphQLResponse ( response ) {
779
763
/** @type {CheckRunData[] } */
780
764
const reqCheckRuns = [ ] ;
781
765
/** @type {CheckRunData[] } */
@@ -792,22 +776,12 @@ function extractRunsFromGraphQLResponse(response) {
792
776
( checkSuiteNode ) => {
793
777
if ( checkSuiteNode . checkRuns ?. nodes ) {
794
778
checkSuiteNode . checkRuns . nodes . forEach ( ( checkRunNode ) => {
795
- // We have some specific guidance for some of the required checks.
796
- const checkInfo =
797
- CHECK_METADATA . find ( ( metadata ) => metadata . name === checkRunNode . name ) ||
798
- /** @type {CheckMetadata } */ ( {
799
- precedence : 1000 ,
800
- name : checkRunNode . name ,
801
- suppressionLabels : [ ] ,
802
- troubleshootingGuide : defaultTsg ,
803
- } ) ;
804
-
805
779
if ( checkRunNode . isRequired ) {
806
780
reqCheckRuns . push ( {
807
781
name : checkRunNode . name ,
808
782
status : checkRunNode . status ,
809
783
conclusion : checkRunNode . conclusion ,
810
- checkInfo : checkInfo ,
784
+ checkInfo : getCheckInfo ( checkRunNode . name ) ,
811
785
} ) ;
812
786
}
813
787
// Note the "else" here. It means that:
@@ -820,7 +794,7 @@ function extractRunsFromGraphQLResponse(response) {
820
794
name : checkRunNode . name ,
821
795
status : checkRunNode . status ,
822
796
conclusion : checkRunNode . conclusion ,
823
- checkInfo : checkInfo ,
797
+ checkInfo : getCheckInfo ( checkRunNode . name ) ,
824
798
} ) ;
825
799
}
826
800
} ) ;
@@ -851,6 +825,23 @@ function extractRunsFromGraphQLResponse(response) {
851
825
}
852
826
return [ reqCheckRuns , fyiCheckRuns , impactAssessmentWorkflowRun ] ;
853
827
}
828
+ /**
829
+ * Get metadata for a specific check from our index.
830
+ * @param {string } checkName
831
+ * @returns {CheckMetadata }
832
+ */
833
+ export function getCheckInfo ( checkName ) {
834
+ return (
835
+ CHECK_METADATA . find ( ( metadata ) => metadata . name === checkName ) ||
836
+ /** @type {CheckMetadata } */ ( {
837
+ precedence : 1000 ,
838
+ name : checkName ,
839
+ suppressionLabels : [ ] ,
840
+ troubleshootingGuide : defaultTsg ,
841
+ } )
842
+ ) ;
843
+ }
844
+
854
845
// #endregion
855
846
// #region next steps
856
847
/**
@@ -861,6 +852,7 @@ function extractRunsFromGraphQLResponse(response) {
861
852
* @param {string } targetBranch
862
853
* @param {CheckRunData[] } requiredRuns
863
854
* @param {CheckRunData[] } fyiRuns
855
+ * @param {boolean } assessmentCompleted
864
856
* @returns {Promise<[string, CheckRunResult]> }
865
857
*/
866
858
export async function createNextStepsComment (
@@ -870,13 +862,15 @@ export async function createNextStepsComment(
870
862
targetBranch ,
871
863
requiredRuns ,
872
864
fyiRuns ,
865
+ assessmentCompleted ,
873
866
) {
874
867
// select just the metadata that we need about the runs.
875
868
const requiredCheckInfos = requiredRuns
876
869
. filter ( ( run ) => checkRunIsSuccessful ( run ) === false )
877
870
. map ( ( run ) => run . checkInfo ) ;
878
871
879
- // determine if required runs have any successful runs.
872
+ // determine if required runs have any in-progress or queued runs
873
+ // if there are any, we consider the requirements not met.
880
874
const requiredCheckInfosPresent = requiredRuns . some ( ( run ) => {
881
875
const status = run . status . toLowerCase ( ) ;
882
876
return status !== "queued" && status !== "in_progress" ;
@@ -892,6 +886,7 @@ export async function createNextStepsComment(
892
886
requiredCheckInfosPresent ,
893
887
requiredCheckInfos ,
894
888
fyiCheckInfos ,
889
+ assessmentCompleted ,
895
890
) ;
896
891
897
892
return [ commentBody , automatedChecksMet ] ;
@@ -904,6 +899,7 @@ export async function createNextStepsComment(
904
899
* @param {boolean } requiredCheckInfosPresent
905
900
* @param {CheckMetadata[] } failingReqChecksInfo
906
901
* @param {CheckMetadata[] } failingFyiChecksInfo
902
+ * @param {boolean } assessmentCompleted
907
903
* @returns {Promise<[string, CheckRunResult]> }
908
904
*/
909
905
async function buildNextStepsToMergeCommentBody (
@@ -913,6 +909,7 @@ async function buildNextStepsToMergeCommentBody(
913
909
requiredCheckInfosPresent ,
914
910
failingReqChecksInfo ,
915
911
failingFyiChecksInfo ,
912
+ assessmentCompleted ,
916
913
) {
917
914
// Build the comment header
918
915
const commentTitle = `<h2>Next Steps to Merge</h2>` ;
@@ -922,10 +919,13 @@ async function buildNextStepsToMergeCommentBody(
922
919
// we are "blocked" if we have any violated labelling rules OR if we have any failing required checks
923
920
const anyBlockerPresent = failingReqChecksInfo . length > 0 || violatedReqLabelsRules . length > 0 ;
924
921
const anyFyiPresent = failingFyiChecksInfo . length > 0 ;
925
- // we consider requirements met if there are no blockers (which INCLUDES violated labelling rules) AND
926
- // that we have at least one required check that is not in progress or queued.
927
- // This might be too aggressive, but it's a good start.
928
- const requirementsMet = ! anyBlockerPresent && requiredCheckInfosPresent ;
922
+ // we consider requirements met if there are:
923
+ // - no blockers (which includes violated labelling rules in its definition) (anyBlockerPresent)
924
+ // - that none of the required checks are in_progress or queued (requiredCheckInfosPresent)
925
+ // - and that the assessment is completed. If it is not, we assume we are still evaluating the requirements. Not having
926
+ // the assessment completed is a blocker, as we may end up having violated labelling rules that would be detected only after
927
+ // it is completed.
928
+ const requirementsMet = ! anyBlockerPresent && requiredCheckInfosPresent && assessmentCompleted ;
929
929
930
930
// Compose the body based on the current state
931
931
const [ commentBody , automatedChecksMet ] = getCommentBody (
@@ -958,7 +958,6 @@ function getCommentBody(
958
958
failingFyiChecksInfo ,
959
959
violatedRequiredLabelsRules ,
960
960
) {
961
- let title = "Automated merging requirements are being evaluated" ;
962
961
/** @type {"pending" | keyof typeof CheckConclusion } */
963
962
let status = "pending" ;
964
963
let summaryData = "The requirements for merging this PR are still being evaluated. Please wait." ;
@@ -971,7 +970,6 @@ function getCommentBody(
971
970
bodyProper += getBlockerPresentBody ( failingReqChecksInfo , violatedRequiredLabelsRules ) ;
972
971
summaryData =
973
972
"❌ This PR cannot be merged because some requirements are not met. See the details." ;
974
- title = "Some automated merging requirements are not met" ;
975
973
status = "FAILURE" ;
976
974
}
977
975
@@ -983,8 +981,6 @@ function getCommentBody(
983
981
bodyProper += getFyiPresentBody ( failingFyiChecksInfo ) ;
984
982
if ( ! anyBlockerPresent ) {
985
983
bodyProper += `If you still want to proceed merging this PR without addressing the above failures, ${ diagramTsg ( 4 , false ) } .` ;
986
- title =
987
- "All automated merging requirements are met, though there are some non-required failures." ;
988
984
summaryData =
989
985
`⚠️ Some important automated merging requirements have failed. As of today you can still merge this PR, ` +
990
986
`but soon these requirements will be blocking.` +
@@ -1003,7 +999,6 @@ function getCommentBody(
1003
999
`<br/>To merge this PR, refer to ` +
1004
1000
`<a href="https://aka.ms/azsdk/specreview/merge">aka.ms/azsdk/specreview/merge</a>.` +
1005
1001
"<br/>For help, consult comments on this PR and see [aka.ms/azsdk/pr-getting-help](https://aka.ms/azsdk/pr-getting-help)." ;
1006
- title = "Automated merging requirements are met" ;
1007
1002
status = "SUCCESS" ;
1008
1003
} else {
1009
1004
bodyProper =
@@ -1013,7 +1008,7 @@ function getCommentBody(
1013
1008
1014
1009
/** @type {CheckRunResult } */
1015
1010
const automatedChecksMet = {
1016
- name : title ,
1011
+ name : AUTOMATED_CHECK_NAME ,
1017
1012
summary : summaryData ,
1018
1013
result : status ,
1019
1014
} ;
0 commit comments