Skip to content

Commit e864e09

Browse files
authored
Merge pull request #140 from hanxizh9910/feature/automated-test-failure-detector
Fixed the indentation and format of the comment created in the issues
2 parents 7770193 + 650304c commit e864e09

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

.github/scripts/create-or-update-issues.js

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ module.exports = async ({github, context}) => {
8484
// For each failing test, create or update a comment
8585
for (const test of tests) {
8686
const commentMarker = `<!-- test-failure: ${test.test_name} -->`;
87-
const ciLinks = test.jobs.map(j => ` - \`${j.job}\`: [CI link](${j.url})`).join('\n');
87+
const ciLinks = test.jobs.map(j => `- \`${j.job}\`: [CI link](${j.url})`).join('\n');
8888
const envNames = test.jobs.map(j => j.job);
8989

9090
const existingComment = comments.find(c => c.body.includes(commentMarker));
@@ -103,7 +103,7 @@ module.exports = async ({github, context}) => {
103103
const firstSeenMatch = existingComment.body.match(/\*\*First seen:\*\*\s*(.+)/);
104104
const firstSeen = firstSeenMatch ? firstSeenMatch[1].trim() : today;
105105

106-
const firstCIMatch = existingComment.body.match(/\*\*First CI:\*\*\n([\s\S]*?)\n\*\*Last seen:/);
106+
const firstCIMatch = existingComment.body.match(/\*\*First CI:\*\*\n([\s\S]*?)\n\n\*\*Last seen:/);
107107
const firstCI = firstCIMatch ? firstCIMatch[1].trim() : ciLinks;
108108

109109
const updatedComment = [
@@ -116,11 +116,14 @@ module.exports = async ({github, context}) => {
116116
'```',
117117
``,
118118
`**First seen:** ${firstSeen}`,
119+
``,
119120
`**First CI:**`,
120121
firstCI,
122+
``,
121123
`**Last seen:** ${today}`,
122124
`**Occurrences:** ${occurrences}`,
123125
`**Affected environments:** ${allEnvs.map(e => '`' + e + '`').join(', ')}`,
126+
``,
124127
`**Latest CI:**`,
125128
ciLinks,
126129
``,
@@ -151,11 +154,14 @@ module.exports = async ({github, context}) => {
151154
'```',
152155
``,
153156
`**First seen:** ${today}`,
157+
``,
154158
`**First CI:**`,
155159
ciLinks,
160+
``,
156161
`**Last seen:** ${today}`,
157162
`**Occurrences:** 1`,
158163
`**Affected environments:** ${envNames.map(e => '`' + e + '`').join(', ')}`,
164+
``,
159165
`**Latest CI:**`,
160166
ciLinks,
161167
``,
@@ -192,7 +198,7 @@ module.exports = async ({github, context}) => {
192198
// Create one comment per failing test
193199
for (const test of tests) {
194200
const commentMarker = `<!-- test-failure: ${test.test_name} -->`;
195-
const ciLinks = test.jobs.map(j => ` - \`${j.job}\`: [CI link](${j.url})`).join('\n');
201+
const ciLinks = test.jobs.map(j => `- \`${j.job}\`: [CI link](${j.url})`).join('\n');
196202
const envNames = test.jobs.map(j => j.job);
197203

198204
await github.rest.issues.createComment({
@@ -209,11 +215,14 @@ module.exports = async ({github, context}) => {
209215
'```',
210216
``,
211217
`**First seen:** ${today}`,
218+
``,
212219
`**First CI:**`,
213220
ciLinks,
221+
``,
214222
`**Last seen:** ${today}`,
215223
`**Occurrences:** 1`,
216224
`**Affected environments:** ${envNames.map(e => '`' + e + '`').join(', ')}`,
225+
``,
217226
`**Latest CI:**`,
218227
ciLinks,
219228
``,

0 commit comments

Comments
 (0)