forked from conan-io/conan-center-index
-
Notifications
You must be signed in to change notification settings - Fork 1
84 lines (82 loc) · 3.2 KB
/
hooks-warnings.yml
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
name: hooks warnings
on:
issue_comment:
types: [created]
jobs:
comment:
if: ${{ github.event.issue.pull_request && github.event.sender.login == 'conan-center-bot' }}
runs-on: ubuntu-latest
steps:
- uses: actions/github-script@v6
with:
script: |
warnings_map = new Map()
const link_regex = /\[All logs\]\((?<url>https?:\/\/(www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*))\)/g;
for (const match of context.payload.comment.body.matchAll(link_regex))
{
prefix = "https://c3i.jfrog.io/c3i/misc/summary.html?json="
if(!match.groups.url.startsWith(prefix))
continue;
url = match.groups.url.slice(prefix.length)
try {
result = await github.request({
url: url,
});
} catch(err) {
core.warning(`error ${err.status} for url ${err.request.url}`)
continue
}
for (const job of result.data)
{
if (job.build == null)
continue;
try {
log = await github.request({
baseUrl: "https://c3i.jfrog.io/c3i/misc/",
url: job.build,
});
} catch(err) {
core.warning(`error ${err.status} for url ${err.request.url}`)
continue
}
prefix = "[HOOK - conan-center.py] "
warnings = log.data.split("\n").filter(line => line.startsWith(prefix) && line.includes(" WARN: "))
if(warnings.length == 0)
continue
if(!warnings_map.has(job.reference))
warnings_map.set(job.reference, new Set())
for(const warning of warnings)
{
msg = warning.slice(prefix.length)
warnings_map.get(job.reference).add(msg)
core.warning(msg)
}
}
}
if(warnings_map.size > 0)
{
comment = "<details>\n"
comment += "<summary>Hooks produced the following warnings"
const shaRegex = /(All green|Failure) in build \d+ \(`(?<sha>(\d|[a-z])+)`\):/g;
const shaMatch = shaRegex.exec(context.payload.comment.body)
if(shaMatch)
{
comment += " for commit " + shaMatch.groups.sha
}
comment += "</summary>\n\n"
for (const [ref, warnings] of warnings_map)
{
comment += "<details>\n"
comment += "<summary>" + ref + "</summary>\n\n```\n"
for(const warning of warnings)
comment += warning + "\n"
comment += "```\n</details>\n"
}
comment += "</details>\n"
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: comment
})
}