Skip to content

Commit 454bfa2

Browse files
committed
Add lintcheck diff github action
1 parent 3b7caab commit 454bfa2

File tree

1 file changed

+111
-0
lines changed

1 file changed

+111
-0
lines changed

.github/workflows/lintcheck.yml

Lines changed: 111 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,111 @@
1+
name: Lintcheck
2+
3+
on: pull_request
4+
5+
env:
6+
RUST_BACKTRACE: 1
7+
CARGO_INCREMENTAL: 0
8+
CARGO_UNSTABLE_SPARSE_REGISTRY: true
9+
10+
jobs:
11+
base:
12+
runs-on: ubuntu-latest
13+
14+
outputs:
15+
key: ${{ steps.key.outputs.key }}
16+
17+
steps:
18+
- uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
19+
with:
20+
github_token: "${{ secrets.github_token }}"
21+
22+
- name: Checkout
23+
uses: actions/checkout@v3
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@v3
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+
- uses: rust-lang/simpleinfra/github-actions/cancel-outdated-builds@master
62+
with:
63+
github_token: "${{ secrets.github_token }}"
64+
65+
- name: Checkout
66+
uses: actions/checkout@v3
67+
68+
- name: Create cache key
69+
id: key
70+
run: echo "key=lintcheck-head-${{ github.sha }}" >> "$GITHUB_OUTPUT"
71+
72+
- name: Cache results
73+
id: cache
74+
uses: actions/cache@v3
75+
with:
76+
path: lintcheck-logs/head.json
77+
key: ${{ steps.key.outputs.key }}
78+
79+
- name: Run lintcheck
80+
if: steps.cache.outputs.cache-hit != 'true'
81+
run: cargo lintcheck --json
82+
83+
- name: Rename JSON file
84+
if: steps.cache.outputs.cache-hit != 'true'
85+
run: mv lintcheck-logs/lintcheck_crates_logs.json lintcheck-logs/head.json
86+
87+
diff:
88+
runs-on: ubuntu-latest
89+
90+
needs: [base, head]
91+
92+
steps:
93+
- name: Checkout
94+
uses: actions/checkout@v3
95+
96+
- name: Restore base JSON
97+
uses: actions/cache/restore@v3
98+
with:
99+
key: ${{ needs.base.outputs.key }}
100+
path: lintcheck-logs/base.json
101+
fail-on-cache-miss: true
102+
103+
- name: Restore head JSON
104+
uses: actions/cache/restore@v3
105+
with:
106+
key: ${{ needs.head.outputs.key }}
107+
path: lintcheck-logs/head.json
108+
fail-on-cache-miss: true
109+
110+
- name: Diff results
111+
run: cargo lintcheck diff lintcheck-logs/base.json lintcheck-logs/head.json >> $GITHUB_STEP_SUMMARY

0 commit comments

Comments
 (0)