Skip to content

Commit 346ce89

Browse files
committed
Add lintcheck diff github action
1 parent 5d77e47 commit 346ce89

File tree

1 file changed

+107
-0
lines changed

1 file changed

+107
-0
lines changed

.github/workflows/lintcheck.yml

Lines changed: 107 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,107 @@
1+
name: Lintcheck
2+
3+
on: pull_request
4+
5+
env:
6+
RUST_BACKTRACE: 1
7+
CARGO_INCREMENTAL: 0
8+
9+
concurrency:
10+
# For a given workflow, if we push to the same PR, cancel all previous builds on that PR.
11+
group: "${{ github.workflow }}-${{ github.event.pull_request.number}}"
12+
cancel-in-progress: true
13+
14+
jobs:
15+
base:
16+
runs-on: ubuntu-latest
17+
18+
outputs:
19+
key: ${{ steps.key.outputs.key }}
20+
21+
steps:
22+
- name: Checkout
23+
uses: actions/checkout@v4
24+
with:
25+
fetch-depth: 0
26+
27+
- name: Checkout merge base
28+
run: git checkout ${{ github.event.pull_request.base.sha }}
29+
30+
- name: Checkout current lintcheck
31+
run: |
32+
rm -rf lintcheck
33+
git checkout ${{ github.sha }} -- lintcheck
34+
35+
- name: Create cache key
36+
id: key
37+
run: echo "key=lintcheck-base-${{ hashfiles('lintcheck/**') }}-${{ github.event.pull_request.base.sha }}" >> "$GITHUB_OUTPUT"
38+
39+
- name: Cache results
40+
id: cache
41+
uses: actions/cache@v4
42+
with:
43+
path: lintcheck-logs/base.json
44+
key: ${{ steps.key.outputs.key }}
45+
46+
- name: Run lintcheck
47+
if: steps.cache.outputs.cache-hit != 'true'
48+
run: cargo lintcheck --json
49+
50+
- name: Rename JSON file
51+
if: steps.cache.outputs.cache-hit != 'true'
52+
run: mv lintcheck-logs/lintcheck_crates_logs.json lintcheck-logs/base.json
53+
54+
head:
55+
runs-on: ubuntu-latest
56+
57+
outputs:
58+
key: ${{ steps.key.outputs.key }}
59+
60+
steps:
61+
- name: Checkout
62+
uses: actions/checkout@v4
63+
64+
- name: Create cache key
65+
id: key
66+
run: echo "key=lintcheck-head-${{ github.sha }}" >> "$GITHUB_OUTPUT"
67+
68+
- name: Cache results
69+
id: cache
70+
uses: actions/cache@v4
71+
with:
72+
path: lintcheck-logs/head.json
73+
key: ${{ steps.key.outputs.key }}
74+
75+
- name: Run lintcheck
76+
if: steps.cache.outputs.cache-hit != 'true'
77+
run: cargo lintcheck --json
78+
79+
- name: Rename JSON file
80+
if: steps.cache.outputs.cache-hit != 'true'
81+
run: mv lintcheck-logs/lintcheck_crates_logs.json lintcheck-logs/head.json
82+
83+
diff:
84+
runs-on: ubuntu-latest
85+
86+
needs: [base, head]
87+
88+
steps:
89+
- name: Checkout
90+
uses: actions/checkout@v4
91+
92+
- name: Restore base JSON
93+
uses: actions/cache/restore@v4
94+
with:
95+
key: ${{ needs.base.outputs.key }}
96+
path: lintcheck-logs/base.json
97+
fail-on-cache-miss: true
98+
99+
- name: Restore head JSON
100+
uses: actions/cache/restore@v4
101+
with:
102+
key: ${{ needs.head.outputs.key }}
103+
path: lintcheck-logs/head.json
104+
fail-on-cache-miss: true
105+
106+
- name: Diff results
107+
run: cargo lintcheck diff lintcheck-logs/base.json lintcheck-logs/head.json >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)