Skip to content

Commit a9c0cbd

Browse files
committed
Auto merge of #3290 - Turbo87:lint-job, r=jtgeibel
CI: Run `cargo fmt` and `cargo clippy` as a dedicated job It looks like `cargo clippy` and `cargo test` are currently fighting over the compile cache, which increases our CI times quite a bit. This PR moves the linting checks (`cargo fmt` and `cargo clippy`) out of the regular `backend` job to having linting and tests run in parallel.
2 parents 4ce0dcf + 96355e1 commit a9c0cbd

File tree

1 file changed

+45
-14
lines changed

1 file changed

+45
-14
lines changed

.github/workflows/ci.yml

Lines changed: 45 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,49 @@ jobs:
6464
- run: yarn build
6565
continue-on-error: true
6666

67+
backend-lint:
68+
name: Backend (linting)
69+
runs-on: ubuntu-18.04
70+
71+
steps:
72+
- uses: actions/checkout@v2
73+
74+
# Current size as of 2021-02-15: ~105 MB
75+
- name: Cache cargo registry and git deps
76+
uses: actions/cache@v2.1.4
77+
with:
78+
path: |
79+
~/.cargo/registry/cache
80+
~/.cargo/registry/index
81+
~/.cargo/git/db
82+
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
83+
restore-keys: |
84+
${{ runner.os }}-cargo-
85+
86+
- id: rustc
87+
run:
88+
echo "::set-output name=version::$(rustc -V)"
89+
90+
- name: Cache cargo build
91+
uses: actions/cache@v2.1.4
92+
with:
93+
path: target
94+
key: v2-${{ runner.os }}-cargo-clippy-${{ steps.rustc.outputs.version }}-${{ hashFiles('**/Cargo.lock') }}
95+
restore-keys: |
96+
v2-${{ runner.os }}-cargo-clippy-${{ steps.rustc.outputs.version }}-
97+
98+
- name: Install Rust
99+
run: |
100+
rustup set profile minimal
101+
rustup update stable
102+
rustup default stable
103+
104+
- run: rustup component add rustfmt
105+
- run: rustup component add clippy
106+
107+
- run: cargo fmt -- --check
108+
- run: cargo clippy --all-targets --all-features --all
109+
67110
backend:
68111
name: Backend
69112
runs-on: ubuntu-18.04
@@ -146,12 +189,6 @@ jobs:
146189
rustup update ${{ matrix.rust }}
147190
rustup default ${{ matrix.rust }}
148191
149-
- name: Install lint tools
150-
if: matrix.rust == 'stable'
151-
run: |
152-
rustup component add rustfmt
153-
rustup component add clippy
154-
155192
- id: rustc
156193
run:
157194
echo "::set-output name=version::$(rustc -V)"
@@ -170,12 +207,6 @@ jobs:
170207
which diesel || cargo install diesel_cli --vers $(cat .diesel_version) --no-default-features --features postgres --debug
171208
diesel database setup --locked-schema
172209
173-
- name: Lint
174-
if: matrix.rust == 'stable'
175-
run: |
176-
cargo fmt -- --check
177-
cargo clippy --all-targets --all-features --all
178-
179210
- name: Install cargo-tarpaulin
180211
if: matrix.rust == 'stable'
181212
run: which cargo-tarpaulin || cargo install cargo-tarpaulin
@@ -202,7 +233,7 @@ jobs:
202233
name: bors build finished
203234
if: success()
204235
runs-on: ubuntu-latest
205-
needs: [frontend, backend]
236+
needs: [frontend, backend, backend-lint]
206237

207238
steps:
208239
- name: Mark the job as successful
@@ -212,7 +243,7 @@ jobs:
212243
name: bors build finished
213244
if: "!success()"
214245
runs-on: ubuntu-latest
215-
needs: [frontend, backend]
246+
needs: [frontend, backend, backend-lint]
216247

217248
steps:
218249
- name: Mark the job as a failure

0 commit comments

Comments
 (0)