forked from cross-rs/cross
-
Notifications
You must be signed in to change notification settings - Fork 0
43 lines (42 loc) · 2.46 KB
/
try.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
name: Try
on:
issue_comment:
types: [created]
jobs:
try:
if: github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && (contains(github.event.comment.body, '\n/ci try') || startsWith(github.event.comment.body, '/ci try'))
uses: ./.github/workflows/ci.yml
with:
matrix-args: try --comment "${{ github.event.comment.body }}" --pr ${{ github.event.issue.number }}
checkout-ref: refs/pull/${{ github.event.issue.number }}/head
comment:
needs: try
if: always() && needs.try.result != 'skipped'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
# comment on the PR with the result and links to the logs using gh cli
# Something like `### Try build: [{result}]({link_to_logs})`
# the url to the logs are on jobs[name="try"].url gathered with `gh run view ${{ github.run_id }} --json jobs`
- name: Comment on PR
run: |
PR_ID=${{ github.event.issue.number }}
gh run view ${{ github.run_id }} --json jobs |\
jq -r --arg pr_id "$PR_ID" --arg comment "${{ github.event.comment.url }}" '
"Diff for [comment](" + $comment + ")\n\n- [Run](" + (.jobs[] | select(.name == "try / generate-matrix") | .url) + ")\n" +
def job_to_md: . | "- [" + (.box) + .name + "](" + .url + "?pr=" + $pr_id + (.conclusion | if . == "success" then "#step:10:1)" else "#)" end);
def wrap_if_needed:
if length > 10 then
"<details>\n<summary>" + (.[0].conclusion | if . == "success" then "Successful Jobs" else "Failed Jobs" end) + "</summary>\n" + (map(job_to_md) | join("\n")) + "\n</details>"
else
map(job_to_md) | join("\n")
end;
"Try run for [comment](" + $comment + ")\n\n- [Matrix](" + (.jobs[] | select(.name == "try / generate-matrix") | .url) + ")\n" +
([.jobs[] | select(.name | startswith("try / target")) | select(.name | contains("matrix.pretty") | not ) | . as $job |
{conclusion: $job.conclusion, box: ($job.conclusion | if . == "success" then "✅ " else "❌ " end), name: ($job.name | capture("\\((?<name>[^,]+),.*") | .name), url: $job.url} ] |
group_by(if .conclusion == "success" then "success" else "failure" end) |
map(wrap_if_needed) |
join("\n"))' |\
gh pr comment "$PR_ID" --body "$(< /dev/stdin)"
env:
GH_TOKEN: ${{ github.token }}