Skip to content

Commit 4f5fa5b

Browse files
authored
Merge pull request #728 from rust-embedded/improve-regress
improve regress
2 parents 14dac5a + eb0c405 commit 4f5fa5b

19 files changed

+4844
-4587
lines changed

.cargo/config.toml

+3
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[target.aarch64-unknown-linux-gnu]
22
linker = "aarch64-linux-gnu-gcc"
3+
4+
[alias]
5+
regress = "run -p svd2rust-regress --"

.github/workflows/ci.yml

+43-1
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,12 @@ jobs:
2121
runs-on: ubuntu-latest
2222
strategy:
2323
matrix:
24-
TARGET: [x86_64-unknown-linux-gnu, x86_64-apple-darwin, x86_64-pc-windows-msvc]
24+
TARGET:
25+
[
26+
x86_64-unknown-linux-gnu,
27+
x86_64-apple-darwin,
28+
x86_64-pc-windows-msvc,
29+
]
2530

2631
steps:
2732
- uses: actions/checkout@v4
@@ -171,3 +176,40 @@ jobs:
171176
uses: Swatinem/rust-cache@v2
172177

173178
- run: cargo fmt --all -- --check
179+
180+
artifact:
181+
name: Build svd2rust artifact
182+
if: github.event_name == 'pull_request'
183+
needs: [check]
184+
runs-on: ${{ matrix.runs-on }}
185+
strategy:
186+
matrix:
187+
include:
188+
- target: x86_64-unknown-linux-gnu
189+
runs-on: ubuntu-latest
190+
- target: aarch64-apple-darwin
191+
runs-on: macos-latest
192+
- target: x86_64-pc-windows-msvc
193+
runs-on: windows-latest
194+
suffix: .exe
195+
steps:
196+
- uses: actions/checkout@v3
197+
198+
- uses: dtolnay/rust-toolchain@master
199+
with:
200+
toolchain: stable
201+
targets: ${{ matrix.target }}
202+
203+
- name: Cache Dependencies
204+
uses: Swatinem/rust-cache@v2
205+
206+
- name: Build svd2rust artifact
207+
run: cargo build --release --target ${{ matrix.target }}
208+
209+
- run: mv target/${{ matrix.target }}/release/svd2rust${{ matrix.suffix || '' }} svd2rust-${{ matrix.target }}-$(git rev-parse --short HEAD)${{ matrix.suffix || '' }}
210+
211+
- name: Upload artifact
212+
uses: actions/upload-artifact@v3
213+
with:
214+
name: artifact-svd2rust-${{ matrix.target }}
215+
path: svd2rust-${{ matrix.target }}*

.github/workflows/diff.yml

+76
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
name: Diff
2+
on:
3+
issue_comment:
4+
types: [created]
5+
6+
jobs:
7+
generate:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
diffs: ${{ steps.regress-ci.outputs.diffs }}
11+
if: ${{ github.event.issue.pull_request }}
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- uses: dtolnay/rust-toolchain@master
16+
with:
17+
toolchain: stable
18+
19+
- name: Cache
20+
uses: Swatinem/rust-cache@v2
21+
with:
22+
shared-key: "diff"
23+
24+
- run: cargo regress ci
25+
id: regress-ci
26+
env:
27+
GITHUB_COMMENT: ${{ github.event.comment.body }}
28+
GITHUB_COMMENT_PR: ${{ github.event.comment.issue_url }}
29+
diff:
30+
runs-on: ubuntu-latest
31+
needs: [generate]
32+
if: needs.generate.outputs.diffs != '{}' && needs.generate.outputs.diffs != '[]' && needs.generate.outputs.diffs != ''
33+
strategy:
34+
matrix:
35+
include: ${{ fromJson(needs.generate.outputs.diffs) }}
36+
steps:
37+
- uses: actions/checkout@v4
38+
39+
- uses: dtolnay/rust-toolchain@master
40+
with:
41+
toolchain: stable
42+
43+
- name: Cache
44+
uses: Swatinem/rust-cache@v2
45+
with:
46+
shared-key: "diff"
47+
48+
- uses: taiki-e/install-action@v2
49+
if: matrix.needs_semver_checks
50+
with:
51+
tool: cargo-semver-checks
52+
53+
# if a new line is added here, make sure to update the `summary` job to reference the new step index
54+
- uses: taiki-e/install-action@v2
55+
with:
56+
tool: git-delta
57+
58+
- run: cargo regress diff ${{ matrix.command }} --use-pager-directly
59+
env:
60+
GH_TOKEN: ${{ github.token }}
61+
GITHUB_PR: ${{ matrix.pr }}
62+
GIT_PAGER: delta --hunk-header-style omit
63+
summary:
64+
runs-on: ubuntu-latest
65+
needs: [diff, generate]
66+
if: always() && needs.generate.outputs.diffs != '{}' && needs.generate.outputs.diffs != '[]' && needs.generate.outputs.diffs != ''
67+
steps:
68+
- uses: actions/checkout@v4
69+
70+
- run: |
71+
PR_ID=$(echo "${{ github.event.comment.issue_url }}" | grep -o '[0-9]\+$')
72+
gh run view ${{ github.run_id }} --json jobs | \
73+
jq -r '"Diff for [comment]("+$comment+")\n\n" + ([.jobs[] | select(.name | startswith("diff")) | "- [" + (.name | capture("\\((?<name>[^,]+),.*") | .name) + "](" + .url + "?pr=" + $pr_id + "#step:7:45)"] | join("\n"))' --arg pr_id "$PR_ID" --arg comment "${{ github.event.comment.url }}"| \
74+
gh pr comment "$PR_ID" --body "$(< /dev/stdin)"
75+
env:
76+
GH_TOKEN: ${{ github.token }}

.gitignore

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,4 @@
33
*.rs.bk
44
*.svd
55
target
6-
ci/svd2rust-regress/Cargo.lock
6+
output

0 commit comments

Comments
 (0)