Skip to content

Commit 13b1a6a

Browse files
committed
Improved CI and check script.
1 parent a1a67b7 commit 13b1a6a

File tree

6 files changed

+138
-57
lines changed

6 files changed

+138
-57
lines changed

.github/workflows/ci.yml

+18-2
Original file line numberDiff line numberDiff line change
@@ -28,12 +28,15 @@ jobs:
2828
- name: Install cargo plugins
2929
run: |
3030
cargo install cargo-rdme
31+
cargo install cargo-machete
32+
cargo install taplo-cli
33+
cargo install cargo-deadlinks
3134
3235
- name: Checkout repository
3336
uses: actions/checkout@v4
3437

3538
- name: Check everything
36-
run: bash ./tools/check.sh
39+
run: bash ./tools/check.sh basic doc_url_links unused_deps packaging fmt toml_fmt readme
3740

3841
msrv:
3942
runs-on: ubuntu-latest
@@ -49,4 +52,17 @@ jobs:
4952
uses: actions/checkout@v4
5053

5154
- name: Check the minimum supported rust version
52-
run: cargo msrv verify
55+
run: bash ./tools/check.sh msrv
56+
57+
clippy:
58+
runs-on: ubuntu-latest
59+
60+
steps:
61+
- name: Install rust
62+
uses: dtolnay/rust-toolchain@stable
63+
64+
- name: Checkout repository
65+
uses: actions/checkout@v4
66+
67+
- name: Run clippy
68+
run: bash ./tools/check.sh clippy

.taplo.toml

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
include = ["**/*.toml"]
2+
exclude = ["target/**", "testdata/**"]
3+
4+
[formatting]
5+
column_width = 100
6+
indent_string = ' '
7+
allowed_blank_lines = 1
8+
9+
[[rule]]
10+
formatting = { reorder_keys = true }
11+
keys = [
12+
"workspace.dependencies",
13+
"dependencies",
14+
"dev-dependencies",
15+
"build-dependencies",
16+
"lints.clippy",
17+
]

Cargo.toml

+7-13
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,9 @@ repository = "https://github.com/cloudflare/wildcard"
1212
documentation = "https://docs.rs/wildcard"
1313
readme = "README.md"
1414

15-
keywords = [
16-
"wildcard",
17-
"matching",
18-
]
15+
keywords = ["wildcard", "matching"]
1916

20-
categories = [
21-
"text-processing",
22-
"algorithms",
23-
]
17+
categories = ["text-processing", "algorithms"]
2418

2519
license = "Apache-2.0"
2620

@@ -40,12 +34,12 @@ thiserror = "2.0.3"
4034

4135
[dev-dependencies]
4236
criterion = "0.5.1"
43-
regex = "1.10.5"
44-
wildmatch = "2.3.4"
45-
toml = "0.8.14"
46-
serde = "1.0.203"
4737
quickcheck = "1.0.3"
4838
quickcheck_macros = "1.0.0"
39+
regex = "1.10.5"
40+
serde = "1.0.203"
41+
toml = "0.8.14"
42+
wildmatch = "2.3.4"
4943

5044
[features]
5145
fatal-warnings = []
@@ -65,8 +59,8 @@ missing-docs = "warn"
6559

6660
[lints.clippy]
6761
all = { level = "warn", priority = -1 }
68-
pedantic = { level = "warn", priority = -1 }
6962
correctness = { level = "deny", priority = 1 }
63+
pedantic = { level = "warn", priority = -1 }
7064

7165
explicit-deref-methods = "allow"
7266
if-not-else = "allow"

benches/benchmark.rs

+11-11
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#![allow(missing_docs)]
1616
#![allow(clippy::must_use_candidate)]
1717
#![allow(clippy::missing_panics_doc)]
18+
#![allow(clippy::too_many_lines)]
1819

1920
use criterion::{criterion_group, criterion_main, Criterion, Throughput};
2021
use std::time::Duration;
@@ -316,9 +317,8 @@ struct Benchmarks {
316317
const BENCHDATA_SIZES: &[usize] = &[1, 2, 4, 8, 16, 32, 64, 128];
317318

318319
fn read_benchmark(size_kib: usize) -> Benchmarks {
319-
let benches =
320-
std::fs::read_to_string(format!("benches/benchdata/benchmarks_{}k.toml", size_kib))
321-
.expect("failed to read benchmark data");
320+
let benches = std::fs::read_to_string(format!("benches/benchdata/benchmarks_{size_kib}k.toml"))
321+
.expect("failed to read benchmark data");
322322

323323
toml::from_str(&benches).expect("failed to parse benchmark file")
324324
}
@@ -357,7 +357,7 @@ fn benchmark_benchdata_comparison_matches(c: &mut Criterion) {
357357

358358
for input in benchmark.inputs.match_.iter().chain(&benchmark.inputs.no_match) {
359359
criterion::black_box(engine_regex_bytes::matches(
360-
&pattern,
360+
pattern,
361361
input.as_bytes(),
362362
));
363363
}
@@ -377,7 +377,7 @@ fn benchmark_benchdata_comparison_matches(c: &mut Criterion) {
377377
benchmark.inputs.match_.iter().chain(benchmark.inputs.no_match.iter())
378378
{
379379
criterion::black_box(engine_regex_bytes::matches_compiled(
380-
&regex_compiled,
380+
regex_compiled,
381381
input.as_bytes(),
382382
));
383383
}
@@ -391,7 +391,7 @@ fn benchmark_benchdata_comparison_matches(c: &mut Criterion) {
391391
let pattern = &benchmark.pattern;
392392

393393
for input in benchmark.inputs.match_.iter().chain(&benchmark.inputs.no_match) {
394-
criterion::black_box(engine_wildmatch::matches(&pattern, input));
394+
criterion::black_box(engine_wildmatch::matches(pattern, input));
395395
}
396396
}
397397
});
@@ -409,7 +409,7 @@ fn benchmark_benchdata_comparison_matches(c: &mut Criterion) {
409409
benchmark.inputs.match_.iter().chain(benchmark.inputs.no_match.iter())
410410
{
411411
criterion::black_box(engine_wildmatch::matches_compiled(
412-
&wildmatch_compiled,
412+
wildmatch_compiled,
413413
input,
414414
));
415415
}
@@ -447,7 +447,7 @@ fn benchmark_benchdata_comparison_matches(c: &mut Criterion) {
447447
benchmark.inputs.match_.iter().chain(benchmark.inputs.no_match.iter())
448448
{
449449
criterion::black_box(engine_wildcard::matches_compiled(
450-
&wildcard_compiled,
450+
wildcard_compiled,
451451
input.as_bytes(),
452452
));
453453
}
@@ -489,7 +489,7 @@ fn benchmark_benchdata_comparison_captures(c: &mut Criterion) {
489489

490490
for input in benchmark.inputs.match_.iter().chain(&benchmark.inputs.no_match) {
491491
criterion::black_box(engine_regex_bytes::captures(
492-
&pattern,
492+
pattern,
493493
input.as_bytes(),
494494
));
495495
}
@@ -509,7 +509,7 @@ fn benchmark_benchdata_comparison_captures(c: &mut Criterion) {
509509
benchmark.inputs.match_.iter().chain(benchmark.inputs.no_match.iter())
510510
{
511511
criterion::black_box(engine_regex_bytes::captures_compiled(
512-
&regex_compiled,
512+
regex_compiled,
513513
input.as_bytes(),
514514
));
515515
}
@@ -547,7 +547,7 @@ fn benchmark_benchdata_comparison_captures(c: &mut Criterion) {
547547
benchmark.inputs.match_.iter().chain(benchmark.inputs.no_match.iter())
548548
{
549549
criterion::black_box(engine_wildcard::captures_compiled(
550-
&wildcard_compiled,
550+
wildcard_compiled,
551551
input.as_bytes(),
552552
));
553553
}

fuzz/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ cargo-fuzz = true
99

1010
[dependencies]
1111
libfuzzer-sys = "0.4.7"
12-
wildcard = { path = ".." }
1312
regex = "1.10.5"
13+
wildcard = { path = ".." }
1414

1515
[profile.release]
1616
debug = true

tools/check.sh

+84-30
Original file line numberDiff line numberDiff line change
@@ -16,39 +16,93 @@ function on_failure {
1616
echo -e "${RED}Whoopsie-daisy: something failed!$NC" >&2
1717
}
1818

19-
assert_installed "cargo-fmt"
20-
assert_installed "cargo-clippy"
21-
assert_installed "cargo-rdme"
19+
assert_installed "cargo"
2220

2321
trap on_failure ERR
2422

25-
echo 'Building:'
26-
cargo build --all-features --all-targets
27-
echo 'Testing:'
28-
SHORT_BENCH=1 cargo test --all-features --all-targets --benches
29-
30-
# We test property-based tests will a much higher number of testcases. We need to compile this with the release profile,
31-
# otherwise this would be very slow.
32-
echo 'Testing property-based tests for longer:'
33-
QUICKCHECK_TESTS=200000 cargo test --all-features --release property_
34-
35-
# Weirdly, the `cargo test ... --all-targets ...` above does not run the tests in the documentation, so we run the
36-
# doc tests like this.
37-
# See https://github.com/rust-lang/cargo/issues/6669.
38-
echo 'Testing doc:'
39-
cargo test --all-features --doc
40-
echo 'Checking documentation:'
41-
cargo doc --all-features --no-deps --document-private-items
42-
43-
echo 'Checking clippy:'
44-
cargo clippy --all-features --all-targets
45-
46-
echo 'Checking packaging:'
47-
cargo package --allow-dirty
48-
echo 'Checking code style:'
49-
cargo fmt -- --check
50-
echo 'Checking readme:'
51-
cargo rdme --check
23+
function check_basic {
24+
echo 'Building:'
25+
cargo build --features fatal-warnings --all-targets
26+
echo 'Testing:'
27+
SHORT_BENCH=1 cargo test --all-features --all-targets --benches
28+
# We test property-based tests will a much higher number of testcases. We need to compile this with the release profile,
29+
# otherwise this would be very slow.
30+
echo 'Testing property-based tests for longer:'
31+
QUICKCHECK_TESTS=200000 cargo test --all-features --release property_
32+
# Weirdly, the `cargo test ... --all-targets ...` above does not run the tests in the documentation, so we run the
33+
# doc tests like this.
34+
# See https://github.com/rust-lang/cargo/issues/6669.
35+
echo 'Testing doc:'
36+
cargo test --features fatal-warnings --doc
37+
echo 'Checking the benchmarks:'
38+
cargo bench --features fatal-warnings -- --test
39+
echo 'Checking documentation:'
40+
cargo doc --features fatal-warnings --no-deps
41+
}
42+
43+
function check_doc_url_links {
44+
assert_installed "cargo-deadlinks"
45+
46+
echo 'Checking doc url links:'
47+
cargo deadlinks
48+
}
49+
50+
function check_unused_deps {
51+
assert_installed "cargo-machete"
52+
53+
echo 'Checking unused dependencies:'
54+
cargo machete
55+
}
56+
57+
function check_packaging {
58+
echo 'Checking packaging:'
59+
cargo package --allow-dirty
60+
}
61+
62+
function check_fmt {
63+
assert_installed "cargo-fmt"
64+
65+
echo 'Checking code format:'
66+
cargo fmt -- --check
67+
}
68+
69+
function check_toml_fmt {
70+
assert_installed "taplo"
71+
72+
echo 'Checking toml format:'
73+
taplo fmt --check
74+
}
75+
76+
function check_readme {
77+
assert_installed "cargo-rdme"
78+
79+
echo 'Checking readme:'
80+
cargo rdme --check
81+
}
82+
83+
function check_msrv {
84+
assert_installed "cargo-msrv"
85+
86+
echo 'Checking the minimum supported rust version:'
87+
cargo msrv verify
88+
}
89+
90+
function check_clippy {
91+
assert_installed "cargo-clippy"
92+
93+
echo 'Checking with clippy:'
94+
cargo clippy --all-targets -- -D warnings
95+
}
96+
97+
to_run=(basic doc_url_links unused_deps packaging fmt toml_fmt readme msrv clippy)
98+
99+
if [ $# -ge 1 ]; then
100+
to_run=("$@")
101+
fi
102+
103+
for check in "${to_run[@]}"; do
104+
check_$check
105+
done
52106

53107
echo
54108
echo -e "${GREEN}Everything looks lovely!$NC"

0 commit comments

Comments
 (0)