@@ -28,24 +28,13 @@ const getMetadataFromIssueBody = (body) => {
28
28
}
29
29
}
30
30
31
- class Component {
32
- constructor ( slug , metadata , issueNumber , drifted , error ) {
33
- this . slug = slug ;
34
- this . metadata = metadata ;
35
- this . issueNumber = issueNumber ;
36
- this . drifted = drifted ;
37
- this . error = error ;
38
- }
39
- }
40
-
41
31
const mapOpenGitHubIssuesToComponents = async ( octokit , context ) => {
42
32
const repository = context . repo ;
43
33
44
34
let per_page = 100 ; // Max allowed value per page
45
35
let page = 1 ;
46
36
let componentsToIssues = { } ;
47
37
let componentsToMetadata = { } ;
48
- let components = { } ;
49
38
let isContinue = true ;
50
39
51
40
while ( isContinue ) {
@@ -60,14 +49,13 @@ const mapOpenGitHubIssuesToComponents = async (octokit, context) => {
60
49
isContinue = false ;
61
50
} else {
62
51
const driftDetectionIssues = response . data
63
- . filter ( issue => issue . title . startsWith ( 'Drift Detected in' ) ) ;
52
+ . filter ( issue => issue . title . startsWith ( 'Drift Detected in' ) || issue . title . startsWith ( 'Failure Detected in' ) ) ;
64
53
65
54
for ( let issue of driftDetectionIssues ) {
66
55
const metadata = getMetadataFromIssueBody ( issue . body ) ;
67
56
const slug = `${ metadata . stack } -${ metadata . component } `
68
57
componentsToIssues [ slug ] = issue . number ;
69
58
componentsToMetadata [ slug ] = metadata ;
70
- components [ slug ] = new Component ( slug , metadata , issue . number , true , false )
71
59
}
72
60
73
61
page ++ ;
@@ -77,7 +65,6 @@ const mapOpenGitHubIssuesToComponents = async (octokit, context) => {
77
65
return {
78
66
componentsToIssues : componentsToIssues ,
79
67
componentsToMetadata : componentsToMetadata ,
80
- components : components
81
68
} ;
82
69
}
83
70
@@ -87,7 +74,6 @@ const readMetadataFromPlanArtifacts = async () => {
87
74
88
75
let componentsToState = { } ;
89
76
let componentsToMetadata = { } ;
90
- let components = { } ;
91
77
92
78
for ( let i = 0 ; i < metadataFiles . length ; i ++ ) {
93
79
const metadata = JSON . parse ( fs . readFileSync ( metadataFiles [ i ] , 'utf8' ) ) ;
@@ -99,13 +85,11 @@ const readMetadataFromPlanArtifacts = async () => {
99
85
error : metadata . error
100
86
} ;
101
87
componentsToMetadata [ slug ] = metadata ;
102
- components [ slug ] = new Component ( slug , metadata , null , metadata . drifted , metadata . error )
103
88
}
104
89
105
90
return {
106
91
componentsToState : componentsToState ,
107
92
componentsToMetadata : componentsToMetadata ,
108
- components : components
109
93
} ;
110
94
}
111
95
@@ -241,15 +225,15 @@ const convertTeamsToUsers = async (octokit, orgName, teams) => {
241
225
return users ;
242
226
}
243
227
244
- const createIssues = async ( octokit , context , maxOpenedIssues , labels , users , componentsToIssues , componentsCandidatesToCreateIssue , componentsCandidatesToCloseIssue ) => {
228
+ const createIssues = async ( octokit , context , maxOpenedIssues , labels , users , componentsToIssues , componentsCandidatesToCreateIssue , componentsCandidatesToCloseIssue , erroredComponents ) => {
245
229
const repository = context . repo ;
246
230
const numberOfMaximumPotentialIssuesThatCanBeCreated = Math . max ( 0 , maxOpenedIssues - Object . keys ( componentsToIssues ) . length + componentsCandidatesToCloseIssue . length ) ;
247
231
const numOfIssuesToCreate = Math . min ( numberOfMaximumPotentialIssuesThatCanBeCreated , componentsCandidatesToCreateIssue . length ) ;
248
232
const componentsToNewlyCreatedIssues = { } ;
249
233
250
234
for ( let i = 0 ; i < numOfIssuesToCreate ; i ++ ) {
251
235
const slug = componentsCandidatesToCreateIssue [ i ] ;
252
- const issueTitle = `Drift Detected in \`${ slug } \`` ;
236
+ const issueTitle = erroredComponents . hasOwnProperty ( slug ) ? `Failure Detected in \` ${ slug } \`` : `Drift Detected in \`${ slug } \`` ;
253
237
const issueDescription = fs . readFileSync ( `issue-description-${ slug } .md` , 'utf8' ) ;
254
238
255
239
const newIssue = await octokit . rest . issues . create ( {
@@ -423,7 +407,7 @@ const runAction = async (octokit, context, parameters) => {
423
407
let users = assigneeUsers . concat ( usersFromTeams ) ;
424
408
users = [ ...new Set ( users ) ] ; // get unique set
425
409
426
- const componentsToNewlyCreatedIssues = await createIssues ( octokit , context , maxOpenedIssues , labels , users , componentsToIssueNumber , componentsCandidatesToCreateIssue , componentsCandidatesToCloseIssue ) ;
410
+ const componentsToNewlyCreatedIssues = await createIssues ( octokit , context , maxOpenedIssues , labels , users , componentsToIssueNumber , componentsCandidatesToCreateIssue , componentsCandidatesToCloseIssue , erroredComponents ) ;
427
411
428
412
await updateIssues ( octokit , context , componentsToIssueNumber , componentsToUpdateExistingIssue ) ;
429
413
0 commit comments