-
Notifications
You must be signed in to change notification settings - Fork 152
83 lines (72 loc) · 2.73 KB
/
diff.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
name: Diff
on:
issue_comment:
types: [created]
jobs:
generate:
name: |
Generate matrix.
runs-on: ubuntu-latest
outputs:
diffs: ${{ steps.regress-ci.outputs.diffs }}
if: contains(toJson(github.event.comment.body), '\n/ci') || startsWith(github.event.comment.body, '/ci')
steps:
- name: Is member
run: |
if [[ "${{ github.event.comment.author_association }}" != "MEMBER" && "${{ github.event.comment.author_association }}" != "OWNER" ]]; then
exit 1
fi
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "diff"
- run: cargo regress ci
id: regress-ci
env:
GITHUB_COMMENT: ${{ github.event.comment.body }}
GITHUB_COMMENT_PR: ${{ github.event.issue.number }}
diff:
runs-on: ubuntu-latest
needs: [generate]
if: needs.generate.outputs.diffs != '{}' && needs.generate.outputs.diffs != '[]' && needs.generate.outputs.diffs != ''
strategy:
matrix:
include: ${{ fromJson(needs.generate.outputs.diffs) }}
steps:
- uses: actions/checkout@v4
- uses: dtolnay/rust-toolchain@master
with:
toolchain: stable
- name: Cache
uses: Swatinem/rust-cache@v2
with:
shared-key: "diff"
- uses: taiki-e/install-action@v2
if: matrix.needs_semver_checks
with:
tool: cargo-semver-checks
- uses: taiki-e/install-action@v2
with:
tool: git-delta
# if a new line is added here, make sure to update the `summary` job to reference the new step index
- run: cargo regress diff --use-pager-directly ${{ matrix.command }}
env:
GH_TOKEN: ${{ github.token }}
GITHUB_PR: ${{ matrix.pr }}
GIT_PAGER: delta --raw
summary:
runs-on: ubuntu-latest
needs: [diff, generate]
if: always() && needs.generate.outputs.diffs != '{}' && needs.generate.outputs.diffs != '[]' && needs.generate.outputs.diffs != '' && needs.generate.result == 'success'
steps:
- uses: actions/checkout@v4
- run: |
gh run view ${{ github.run_id }} --json jobs | \
jq -r '"Diff for [comment]("+$comment+")\n\n" + ([.jobs[] | select(.name | startswith("diff")) | "- [" + (.name | capture("\\((?<name>[^,]+),.*") | .name) + "](" + .url + "?pr=" + $pr_id + "#step:7:47)"] | join("\n"))' --arg pr_id "${{ github.event.issue.number }}" --arg comment "${{ github.event.comment.url }}"| \
gh pr comment "${{ github.event.issue.number }}" --body "$(< /dev/stdin)"
env:
GH_TOKEN: ${{ github.token }}