Skip to content

Commit cca6199

Browse files
committed
ci.yml: Extract code checks to a dedicated job
1 parent b9cd580 commit cca6199

File tree

1 file changed

+50
-26
lines changed

1 file changed

+50
-26
lines changed

.github/workflows/ci.yml

Lines changed: 50 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,6 @@ jobs:
7272
with:
7373
profile: minimal
7474
toolchain: stable
75-
components: clippy, rustfmt
7675
override: true
7776

7877
- uses: actions/cache@v3
@@ -93,36 +92,12 @@ jobs:
9392
shell: bash
9493
run: |
9594
cargo install cargo2junit 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
96-
cargo install cargo-sort 2>/dev/null || true
9795
9896
- name: Cargo build
9997
uses: actions-rs/cargo@v1
10098
with:
10199
command: build
102100
args: --release --all-targets --features portable -p ${{ env.CARGO_PROJECT_NAME }}
103-
104-
- name: Cargo check
105-
uses: actions-rs/cargo@v1
106-
with:
107-
command: check
108-
args: --release --all-targets -p ${{ env.CARGO_PROJECT_NAME }}
109-
110-
- name: Clippy Check
111-
uses: actions-rs/clippy-check@v1
112-
with:
113-
name: clippy-${{ matrix.project }}
114-
token: ${{ secrets.GITHUB_TOKEN }}
115-
args: --release --all-features --all-targets --no-deps -p ${{ env.CARGO_PROJECT_NAME }} -- -D warnings
116-
117-
- name: Cargo fmt
118-
uses: actions-rs/cargo@v1
119-
with:
120-
command: fmt
121-
args: --check -p ${{ env.CARGO_PROJECT_NAME }}
122-
123-
- name: Cargo sort
124-
run: |
125-
cargo sort -c ${{ matrix.project }}/Cargo.toml
126101

127102
- name: Run tests
128103
if: ${{ matrix.skip_tests != true }}
@@ -148,6 +123,54 @@ jobs:
148123
path: |
149124
target/release/${{ env.ARTIFACTS_PATTERN }}*
150125
if-no-files-found: error
126+
127+
check:
128+
runs-on: ubuntu-22.04
129+
steps:
130+
- name: Checkout sources
131+
uses: actions/checkout@v3
132+
133+
- name: Install stable toolchain
134+
uses: actions-rs/toolchain@v1
135+
with:
136+
profile: minimal
137+
toolchain: stable
138+
components: clippy, rustfmt
139+
override: true
140+
141+
- name: Rust Cache
142+
uses: Swatinem/[email protected]
143+
with:
144+
key: ${{ runner.os }}-cache-v${{ secrets.CACHE_VERSION }}
145+
146+
- name: Install cargo tools
147+
if: ${{ steps.cargo-cache.outputs.cache-hit == false }}
148+
shell: bash
149+
run: |
150+
cargo install cargo-sort 2>/dev/null || true # Suppress the "binary `xyz` already exists in destination" error
151+
152+
- name: Cargo check
153+
uses: actions-rs/cargo@v1
154+
with:
155+
command: check
156+
args: --release --all-targets
157+
158+
- name: Clippy Check
159+
uses: actions-rs/clippy-check@v1
160+
with:
161+
name: clippy
162+
token: ${{ secrets.GITHUB_TOKEN }}
163+
args: --all-features --all-targets --no-deps -- -D warnings
164+
165+
- name: Cargo fmt
166+
uses: actions-rs/cargo@v1
167+
with:
168+
command: fmt
169+
args: --check
170+
171+
- name: Cargo sort
172+
shell: bash
173+
run: cargo sort -w -c
151174

152175
test-mithril-core:
153176
runs-on: ubuntu-22.04
@@ -162,7 +185,6 @@ jobs:
162185
with:
163186
profile: minimal
164187
toolchain: stable
165-
components: clippy, rustfmt
166188
override: true
167189

168190
# Get the matrix build cache for mithril-core
@@ -333,6 +355,7 @@ jobs:
333355
runs-on: ubuntu-22.04
334356
if: ${{ github.event_name == 'push' }}
335357
needs:
358+
- check
336359
- test-mithril-core
337360
- run-test-lab
338361
strategy:
@@ -392,6 +415,7 @@ jobs:
392415
needs:
393416
- test-mithril-core
394417
- run-test-lab
418+
- check
395419
steps:
396420
- name: Download mithril-core lib
397421
uses: actions/download-artifact@v3

0 commit comments

Comments
 (0)