This repository has been archived by the owner on Sep 21, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 40
125 lines (96 loc) · 3.73 KB
/
report_test_flakes.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
on:
workflow_call:
name: 'Workflow Analysis'
jobs:
report-test-flakes:
name: 'Report test flakes'
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/download-artifact@v3
- name: Parse test results
id: parse-test-results
run: |
sudo apt-get install colorized-logs
echo -n 'results=[' >> $GITHUB_OUTPUT
ENTRIES=""
for RESULTS_DIR in test-results-*/ ; do
mapfile -t target <$RESULTS_DIR/target
PLATFORM="${target[0]}"
FEATURES="${target[1]}"
TOOLCHAIN="${target[2]}"
LOG_PATH="$RESULTS_DIR/log"
csplit -q "$LOG_PATH" %^------------%
SUMMARY=""
if [[ -f "./xx00" ]]; then
SUMMARY=$(tail ./xx00 -n+2 | ansi2txt | jq -M --compact-output --raw-input --slurp . | sed -e 's/\\/\\\\/g')
else
continue
fi
ENTRY="{\"platform\":\"$PLATFORM\",\"features\":\"$FEATURES\",\"toolchain\":\"$TOOLCHAIN\",\"summary\":$SUMMARY}"
if [ -z "$ENTRIES" ]; then
ENTRIES="$ENTRY"
else
ENTRIES="$ENTRIES,$ENTRY"
fi
done
echo -n "$ENTRIES ]" >> $GITHUB_OUTPUT
- name: Report test flakes
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const results = JSON.parse(`${{ steps.parse-test-results.outputs.results }}`);
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
});
const testFlakeAnalysisHeader = 'Test flake analysis';
const existingComment = comments.find(comment => {
return comment.user.type === 'Bot' && comment.body.includes(testFlakeAnalysisHeader)
});
let body = '';
if (results.length == 0) {
body = "No test results to analyze. Maybe none of the test runs passed?";
} else {
let table = "\n\n| status | platform | features | toolchain |\n|:---:|---|---|---|\n";
const flakeSummaries = [];
for (result of results) {
const isFlakey = result.summary.indexOf("FLAKY") > 0;
table += `| ${ isFlakey ? "🟡" : "🟢" } | \`${ result.platform }\` | \`${ result.features }\` | \`${result.toolchain}\` |\n`;
if (isFlakey) {
flakeSummaries.push(`#### Flake summary for \`${ result.platform }\`, \`${ result.features }\`, \`${ result.toolchain }\`
\`\`\`shell
${ result.summary }
\`\`\``);
}
}
if (flakeSummaries.length == 0) {
body += '\nNo flakes detected 🎉\n\n'
}
body += table;
if (flakeSummaries.length > 0) {
body += "\n\n";
body += flakeSummaries.join('\n\n');
}
}
body = `### ${testFlakeAnalysisHeader}
${body}`;
if (existingComment) {
github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body
});
} else {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
}