Skip to content

Commit 3522dac

Browse files
committed
ci: Separate CI testing to Check and Build
Disable the duplicated CI testing named "Clippy Check", and separate the Build action into two parts: "Check" and "Build". Signed-off-by: Xuewei Niu <niuxuewei.nxw@antgroup.com>
1 parent 8c5121f commit 3522dac

File tree

7 files changed

+73
-43
lines changed

7 files changed

+73
-43
lines changed

.github/workflows/bvt.yml

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,38 @@
11
name: BVT
22
on: [pull_request]
33
jobs:
4-
make:
5-
name: Make
4+
check:
5+
name: Check
66
runs-on: ${{ matrix.os }}
77
strategy:
88
matrix:
99
os: [ubuntu-latest, macos-latest]
1010
steps:
1111
- name: Checkout
1212
uses: actions/checkout@v3
13-
- name: Make
13+
- name: Check
1414
run: |
1515
make deps
16-
make
17-
make -C example deps
18-
make -C example
19-
make -C ttrpc-codegen deps
20-
make -C ttrpc-codegen
16+
make check
17+
make -C compiler check
18+
make -C ttrpc-codegen check
2119
22-
clippy_check:
23-
name: Clippy Check
20+
make:
21+
name: Build
2422
runs-on: ${{ matrix.os }}
2523
strategy:
2624
matrix:
2725
os: [ubuntu-latest, macos-latest]
2826
steps:
29-
- uses: actions/checkout@v3
30-
- run: rustup component add clippy
31-
- uses: tim-actions/clippy-check@master
32-
with:
33-
token: ${{ secrets.GITHUB_TOKEN }}
34-
args: --all-features
35-
name: checks-${{ matrix.os }}
27+
- name: Checkout
28+
uses: actions/checkout@v3
29+
- name: Build
30+
run: |
31+
make deps
32+
make
33+
make -C compiler
34+
make -C ttrpc-codegen
35+
make -C example build-examples
3636
3737
deny:
3838
runs-on: ubuntu-latest

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
all: debug check test
1+
all: debug test
22

33
#
44
# Build

compiler/Makefile

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
all: debug test
2+
3+
#
4+
# Build
5+
#
6+
7+
.PHONY: debug
8+
debug:
9+
cargo build --verbose --all-targets
10+
11+
.PHONY: release
12+
release:
13+
cargo build --release
14+
15+
.PHONY: build
16+
build: debug
17+
18+
.PHONY: test
19+
test:
20+
cargo test --all-features --verbose
21+
22+
.PHONY: check
23+
check:
24+
cargo fmt --all -- --check
25+
cargo clippy --all-targets --all-features -- -D warnings
26+
27+
.PHONY: deps
28+
deps:
29+
rustup update stable
30+
rustup default stable
31+
rustup component add rustfmt clippy

compiler/src/codegen.rs

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -271,23 +271,18 @@ impl<'a> MethodGen<'a> {
271271

272272
fn write_client(&self, w: &mut CodeWriter) {
273273
let method_name = self.name();
274-
match self.method_type().0 {
275-
// Unary
276-
MethodType::Unary => {
277-
w.pub_fn(&self.unary(&method_name), |w| {
278-
w.write_line(&format!("let mut cres = {}::new();", self.output()));
279-
w.write_line(&format!(
280-
"::ttrpc::client_request!(self, ctx, req, \"{}.{}\", \"{}\", cres);",
281-
self.package_name,
282-
self.service_name,
283-
&self.proto.get_name(),
284-
));
285-
w.write_line("Ok(cres)");
286-
});
287-
}
288-
289-
_ => {}
290-
};
274+
if let MethodType::Unary = self.method_type().0 {
275+
w.pub_fn(&self.unary(&method_name), |w| {
276+
w.write_line(&format!("let mut cres = {}::new();", self.output()));
277+
w.write_line(&format!(
278+
"::ttrpc::client_request!(self, ctx, req, \"{}.{}\", \"{}\", cres);",
279+
self.package_name,
280+
self.service_name,
281+
&self.proto.get_name(),
282+
));
283+
w.write_line("Ok(cres)");
284+
});
285+
}
291286
}
292287

293288
fn write_async_client(&self, w: &mut CodeWriter) {
@@ -456,7 +451,7 @@ impl<'a> ServiceGen<'a> {
456451
file.get_package().to_string(),
457452
util::to_camel_case(proto.get_name()),
458453
root_scope,
459-
&customize,
454+
customize,
460455
)
461456
})
462457
.collect();
@@ -546,7 +541,7 @@ impl<'a> ServiceGen<'a> {
546541
trait_name = format!("{}: Sync", &self.service_name());
547542
}
548543

549-
w.pub_trait(&trait_name.to_owned(), |w| {
544+
w.pub_trait(&trait_name, |w| {
550545
for method in &self.methods {
551546
method.write_service(w);
552547
}
@@ -767,8 +762,8 @@ where
767762
{
768763
let req = CodeGeneratorRequest::parse_from_reader(&mut stdin()).unwrap();
769764
let result = gen(&GenRequest {
770-
file_descriptors: &req.get_proto_file(),
771-
files_to_generate: &req.get_file_to_generate(),
765+
file_descriptors: req.get_proto_file(),
766+
files_to_generate: req.get_file_to_generate(),
772767
parameter: req.get_parameter(),
773768
});
774769
let mut resp = CodeGeneratorResponse::new();

compiler/src/util.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ impl<'a> Iterator for NameSpliter<'a> {
4848
let mut meet_lower = false;
4949
for i in self.pos..self.name.len() {
5050
let c = self.name[i];
51-
if b'A' <= c && c <= b'Z' {
51+
if (b'A'..=b'Z').contains(&c) {
5252
if meet_lower {
5353
// So it should be AaA or aaA
5454
pos = i;
@@ -171,7 +171,7 @@ mod test {
171171
];
172172

173173
for (origin, exp) in cases {
174-
let res = super::to_snake_case(&origin);
174+
let res = super::to_snake_case(origin);
175175
assert_eq!(res, exp);
176176
}
177177
}
@@ -193,7 +193,7 @@ mod test {
193193
];
194194

195195
for (origin, exp) in cases {
196-
let res = super::to_camel_case(&origin);
196+
let res = super::to_camel_case(origin);
197197
assert_eq!(res, exp);
198198
}
199199
}

example/Makefile

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@
44

55
.PHONY: build
66
build:
7+
cargo build
8+
9+
.PHONY: build-examples
10+
build-examples: build
711
cargo build --example server
812
cargo build --example client
913
cargo build --example async-server

ttrpc-codegen/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
all: debug check test
1+
all: debug test
22

33
#
44
# Build

0 commit comments

Comments
 (0)