Skip to content

Commit 1d03f15

Browse files
committed
Merge #268: Lint non-workspace crates in CI
2858e46 CI: Lint non-member crates in CI (Tobin C. Harding) 72bf308 verify: Simplify nested if statements (Tobin C. Harding) dd27d09 verify: Use matches macro (Tobin C. Harding) 1f71c59 just: Add lint commands (Tobin C. Harding) c2060fb Add script to lint verify (Tobin C. Harding) f1ccc17 CI: Fix doc for number of jobs (Tobin C. Harding) Pull request description: Do a bunch of preparation and then add commands to the already present lint job in CI to lint `verify` and `integration_tests`. Close: #236 ACKs for top commit: jamillambert: ACK 2858e46 Tree-SHA512: 3f2712ae69129b628e2f418987c6526772a02c425509e3af533fde31061b4e4481634d695c6827b94a74f9de01f539eec8e0b6b9fba53cdeba95a0c8ffd448b0
2 parents face30a + 2858e46 commit 1d03f15

File tree

6 files changed

+42
-29
lines changed

6 files changed

+42
-29
lines changed

.github/workflows/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,6 @@ Run from `rust.yml` unless stated otherwise. Total 11 jobs.
2424
10. `Format`
2525
11. `Verify`
2626

27-
+15 jobs - 1 for each supported version of Core.
27+
+16 jobs - 1 for each supported version of Core.
2828

2929

.github/workflows/rust.yaml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,10 @@ jobs:
119119
- name: "Set dependencies"
120120
run: cp Cargo-${{ matrix.dep }}.lock Cargo.lock
121121
- name: "Run test script"
122-
run: ./maintainer-tools/ci/run_task.sh lint
122+
run: |
123+
./maintainer-tools/ci/run_task.sh lint
124+
./contrib/lint-integtation-tests.sh
125+
./contrib/lint-verify.sh
123126
124127
Docs:
125128
name: Docs - stable toolchain

contrib/lint-verify.sh

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#!/usr/bin/env bash
2+
#
3+
# The `verify` crate is not part of the workspace because it is a dev tool.
4+
5+
set -euox pipefail
6+
7+
REPO_DIR=$(git rev-parse --show-toplevel)
8+
9+
cargo +"$(cat ./nightly-version)" clippy \
10+
--manifest-path "$REPO_DIR/verify/Cargo.toml" \
11+
--config ./rustfmt.toml \
12+
--all-targets --all-features \
13+
-- --deny warnings
14+

justfile

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@ set export
33
REPO_DIR := `git rev-parse --show-toplevel`
44

55
alias ulf := update-lock-files
6+
alias l := lint
7+
alias li := lint-integration-tests
8+
alias lv := lint-verify
69

710
default:
811
@just --list
@@ -16,9 +19,15 @@ check:
1619
cargo check --workspace --all-targets --all-features
1720

1821
# Lint everything.
19-
lint:
22+
lint: lint-verify lint-integration-tests
2023
cargo +$(cat ./nightly-version) clippy --workspace --all-targets --all-features -- --deny warnings
2124

25+
lint-verify:
26+
$REPO_DIR/contrib/lint-verify.sh
27+
28+
lint-integration-tests:
29+
$REPO_DIR/contrib/lint-integtation-tests.sh
30+
2231
# Run cargo fmt
2332
fmt:
2433
cargo +$(cat ./nightly-version) fmt --all

verify/src/main.rs

Lines changed: 12 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,13 @@ fn verify_status(version: Version, test_output: Option<&String>) -> Result<()> {
135135
let out =
136136
Method::from_name(version, &method.name).expect("guaranteed by methods_and_status()");
137137

138-
if !versioned::requires_type(version, &method.name)? {
139-
if versioned::type_exists(version, &method.name)? {
140-
eprintln!("return type found but method is omitted or TODO: {}", output_method(out));
141-
}
142-
}
143-
if !model::requires_type(version, &method.name)? {
144-
if model::type_exists(version, &method.name)? {
145-
eprintln!("model type found but method is omitted or TODO: {}", output_method(out));
146-
}
138+
if versioned::type_exists(version, &method.name)? && !versioned::requires_type(version, &method.name)? {
139+
eprintln!("return type found but method is omitted or TODO: {}", output_method(out));
147140
}
148141

142+
if model::type_exists(version, &method.name)? && !model::requires_type(version, &method.name)? {
143+
eprintln!("model type found but method is omitted or TODO: {}", output_method(out));
144+
}
149145
}
150146
}
151147
}
@@ -156,19 +152,14 @@ fn verify_status(version: Version, test_output: Option<&String>) -> Result<()> {
156152
fn check_types_exist_if_required(version: Version, method_name: &str) -> Result<()> {
157153
let out = Method::from_name(version, method_name).expect("guaranteed by methods_and_status()");
158154

159-
if versioned::requires_type(version, method_name)? {
160-
if !versioned::type_exists(version, method_name)? {
161-
eprintln!("missing return type: {}", output_method(out));
162-
}
155+
if versioned::requires_type(version, method_name)? && !versioned::type_exists(version, method_name)? {
156+
eprintln!("missing return type: {}", output_method(out));
163157
}
164-
if model::requires_type(version, method_name)? {
165-
if !model::type_exists(version, method_name)? {
166-
eprintln!("missing model type: {}", output_method(out));
167-
}
168-
} else {
169-
if model::type_exists(version, method_name)? {
170-
eprintln!("found model type when none expected: {}", output_method(out));
171-
}
158+
if model::requires_type(version, method_name)? && !model::type_exists(version, method_name)? {
159+
eprintln!("missing model type: {}", output_method(out));
160+
}
161+
if model::type_exists(version, method_name)? && !model::requires_type(version, method_name)? {
162+
eprintln!("found model type when none expected: {}", output_method(out));
172163
}
173164
Ok(())
174165
}

verify/src/versioned.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,7 @@ pub fn requires_type(version: Version, method_name: &str) -> Result<bool> {
7575
))),
7676
};
7777

78-
let requires = match method.ret {
79-
Some(Return::Type(_)) => true,
80-
_ => false,
81-
};
82-
Ok(requires)
78+
Ok(matches!(method.ret, Some(Return::Type(_))))
8379
}
8480

8581
/// Checks that a type exists in version specific module.

0 commit comments

Comments
 (0)