Skip to content

Commit 0840841

Browse files
committed
Add lintcheck diff github action
1 parent 1e21936 commit 0840841

File tree

1 file changed

+110
-0
lines changed

1 file changed

+110
-0
lines changed

.github/workflows/lintcheck.yml

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

0 commit comments

Comments
 (0)