Skip to content

Commit 8af303a

Browse files
committed
Move rustfmt into a separate job
1 parent ef6c0b8 commit 8af303a

File tree

4 files changed

+38
-7
lines changed

4 files changed

+38
-7
lines changed

.github/workflows/ci.yml

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,6 @@ jobs:
4949
- name: test protoc
5050
run: protoc/test.sh
5151
shell: bash
52-
- name: cargo fmt check
53-
run: cargo fmt -- --check
54-
shell: bash
5552
linux-beta-default-features:
5653
name: linux beta (default features)
5754
runs-on: ubuntu-latest
@@ -315,6 +312,19 @@ jobs:
315312
DEFAULT_BRANCH: master
316313
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
317314
VALIDATE_JSCPD: false
315+
rustfmt-check:
316+
name: rustfmt check
317+
runs-on: ubuntu-latest
318+
steps:
319+
- name: Checkout sources
320+
uses: actions/checkout@v2
321+
- name: cargo check
322+
uses: actions-rs/cargo@v1
323+
with:
324+
command: check
325+
- name: cargo fmt check
326+
run: cargo fmt -- --check
327+
shell: bash
318328
self-check:
319329
name: CI self-check
320330
runs-on: ubuntu-latest

ci-gen/src/actions.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ pub fn cargo_build(name: &str, args: &str) -> Step {
6565
cargo(name, "build", args)
6666
}
6767

68+
#[allow(dead_code)]
69+
pub fn cargo_check(name: &str, args: &str) -> Step {
70+
cargo(name, "check", args)
71+
}
72+
6873
pub fn cargo_doc(name: &str, args: &str) -> Step {
6974
cargo(name, "doc", args)
7075
}

ci-gen/src/ghwf.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -125,6 +125,7 @@ pub struct Job {
125125
}
126126

127127
impl Job {
128+
#[allow(dead_code)]
128129
pub fn step(mut self, step: Step) -> Self {
129130
self.steps.push(step);
130131
self

ci-gen/src/main.rs

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::actions::cache;
2+
use crate::actions::cargo_check;
23
use crate::actions::cargo_doc;
34
use crate::actions::cargo_test;
45
use crate::actions::checkout_sources;
@@ -198,13 +199,25 @@ fn super_linter_job() -> Job {
198199
}
199200
}
200201

202+
fn rustfmt_job() -> Job {
203+
let mut steps = Vec::new();
204+
steps.push(checkout_sources());
205+
// force generate code
206+
steps.push(cargo_check("cargo check", ""));
207+
steps.push(Step::run("cargo fmt check", "cargo fmt -- --check"));
208+
Job {
209+
id: "rustfmt-check".to_owned(),
210+
name: "rustfmt check".to_owned(),
211+
runs_on: LINUX.ghwf,
212+
steps,
213+
..Default::default()
214+
}
215+
}
216+
201217
fn jobs() -> Yaml {
202218
let mut r = Vec::new();
203219

204-
r.push(
205-
job(RustToolchain::Stable, LINUX, Features::Default)
206-
.step(Step::run("cargo fmt check", "cargo fmt -- --check")),
207-
);
220+
r.push(job(RustToolchain::Stable, LINUX, Features::Default));
208221
r.push(job(RustToolchain::Beta, LINUX, Features::Default));
209222
r.push(job(
210223
RustToolchain::Stable,
@@ -227,6 +240,8 @@ fn jobs() -> Yaml {
227240

228241
r.push(super_linter_job());
229242

243+
r.push(rustfmt_job());
244+
230245
r.push(self_check_job());
231246

232247
// TODO: enable macos

0 commit comments

Comments
 (0)