Skip to content

Commit 713d96f

Browse files
authored
Merge pull request #124 from epage/template
chore: Update from epage/_rust template
2 parents dce69df + 9c43a84 commit 713d96f

16 files changed

+329
-136
lines changed

.clippy.toml

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
allow-print-in-tests = true
2+
allow-expect-in-tests = true
3+
allow-unwrap-in-tests = true
4+
allow-dbg-in-tests = true

.github/renovate.json5

+16-8
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
'before 5am on the first day of the month',
44
],
55
semanticCommits: 'enabled',
6+
commitMessageLowerCase: 'never',
67
configMigration: true,
78
dependencyDashboard: true,
89
customManagers: [
@@ -17,30 +18,35 @@
1718
'^\\.github/workflows/rust-next.yml$',
1819
],
1920
matchStrings: [
20-
'MSRV.*?(?<currentValue>\\d+\\.\\d+(\\.\\d+)?)',
21-
'(?<currentValue>\\d+\\.\\d+(\\.\\d+)?).*?MSRV',
21+
'STABLE.*?(?<currentValue>\\d+\\.\\d+(\\.\\d+)?)',
22+
'(?<currentValue>\\d+\\.\\d+(\\.\\d+)?).*?STABLE',
2223
],
23-
depNameTemplate: 'rust',
24+
depNameTemplate: 'STABLE',
2425
packageNameTemplate: 'rust-lang/rust',
2526
datasourceTemplate: 'github-releases',
2627
},
2728
],
2829
packageRules: [
2930
{
30-
commitMessageTopic: 'MSRV',
31+
commitMessageTopic: 'Rust Stable',
3132
matchManagers: [
3233
'custom.regex',
3334
],
3435
matchPackageNames: [
35-
'rust',
36+
'STABLE',
3637
],
37-
minimumReleaseAge: '84 days',
38-
internalChecksFilter: 'strict',
39-
extractVersion: '^(?<version>\\d+\\.\\d+)',
38+
extractVersion: '^(?<version>\\d+\\.\\d+)', // Drop the patch version
4039
schedule: [
4140
'* * * * *',
4241
],
42+
automerge: true,
4343
},
44+
// Goals:
45+
// - Keep version reqs low, ignoring compatible normal/build dependencies
46+
// - Take advantage of latest dev-dependencies
47+
// - Rollup safe upgrades to reduce CI runner load
48+
// - Help keep number of versions down by always using latest breaking change
49+
// - Have lockfile and manifest in-sync
4450
{
4551
matchManagers: [
4652
'cargo',
@@ -66,6 +72,7 @@
6672
matchCurrentVersion: '>=1.0.0',
6773
matchUpdateTypes: [
6874
'minor',
75+
'patch',
6976
],
7077
enabled: false,
7178
},
@@ -93,6 +100,7 @@
93100
matchCurrentVersion: '>=1.0.0',
94101
matchUpdateTypes: [
95102
'minor',
103+
'patch',
96104
],
97105
automerge: true,
98106
groupName: 'compatible (dev)',

.github/workflows/audit.yml

+4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ env:
1717
CARGO_TERM_COLOR: always
1818
CLICOLOR: 1
1919

20+
concurrency:
21+
group: "${{ github.workflow }}-${{ github.ref }}"
22+
cancel-in-progress: true
23+
2024
jobs:
2125
security_audit:
2226
permissions:

.github/workflows/ci.yml

+24-26
Original file line numberDiff line numberDiff line change
@@ -14,21 +14,27 @@ env:
1414
CARGO_TERM_COLOR: always
1515
CLICOLOR: 1
1616

17+
concurrency:
18+
group: "${{ github.workflow }}-${{ github.ref }}"
19+
cancel-in-progress: true
20+
1721
jobs:
1822
ci:
1923
permissions:
2024
contents: none
2125
name: CI
22-
needs: [test, msrv, docs, rustfmt, clippy]
26+
needs: [test, msrv, lockfile, docs, rustfmt, clippy]
2327
runs-on: ubuntu-latest
28+
if: "always()"
2429
steps:
25-
- name: Done
26-
run: exit 0
30+
- name: Failed
31+
run: exit 1
32+
if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')"
2733
test:
2834
name: Test
2935
strategy:
3036
matrix:
31-
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
37+
os: ["ubuntu-latest", "windows-latest", "macos-14"]
3238
rust: ["stable"]
3339
continue-on-error: ${{ matrix.rust != 'stable' }}
3440
runs-on: ${{ matrix.os }}
@@ -40,31 +46,25 @@ jobs:
4046
with:
4147
toolchain: ${{ matrix.rust }}
4248
- uses: Swatinem/rust-cache@v2
49+
- uses: taiki-e/install-action@cargo-hack
4350
- name: Build
44-
run: cargo test --no-run --workspace --all-features
45-
- name: Default features
46-
run: cargo test --workspace
47-
- name: All features
48-
run: cargo test --workspace --all-features
49-
- name: No-default features
50-
run: cargo test --workspace --no-default-features
51+
run: cargo test --workspace --no-run
52+
- name: Test
53+
run: cargo hack test --feature-powerset --workspace
5154
msrv:
52-
name: "Check MSRV: 1.73" # MSRV
55+
name: "Check MSRV"
5356
runs-on: ubuntu-latest
5457
steps:
5558
- name: Checkout repository
5659
uses: actions/checkout@v4
5760
- name: Install Rust
5861
uses: dtolnay/rust-toolchain@stable
5962
with:
60-
toolchain: "1.73" # MSRV
63+
toolchain: stable
6164
- uses: Swatinem/rust-cache@v2
65+
- uses: taiki-e/install-action@cargo-hack
6266
- name: Default features
63-
run: cargo check --workspace --all-targets
64-
- name: All features
65-
run: cargo check --workspace --all-targets --all-features
66-
- name: No-default features
67-
run: cargo check --workspace --all-targets --no-default-features
67+
run: cargo hack check --feature-powerset --locked --rust-version --ignore-private --workspace --all-targets
6868
lockfile:
6969
runs-on: ubuntu-latest
7070
steps:
@@ -76,7 +76,7 @@ jobs:
7676
toolchain: stable
7777
- uses: Swatinem/rust-cache@v2
7878
- name: "Is lockfile updated?"
79-
run: cargo fetch --locked
79+
run: cargo update --workspace --locked
8080
docs:
8181
name: Docs
8282
runs-on: ubuntu-latest
@@ -86,7 +86,7 @@ jobs:
8686
- name: Install Rust
8787
uses: dtolnay/rust-toolchain@stable
8888
with:
89-
toolchain: stable
89+
toolchain: "1.76" # STABLE
9090
- uses: Swatinem/rust-cache@v2
9191
- name: Check documentation
9292
env:
@@ -101,9 +101,7 @@ jobs:
101101
- name: Install Rust
102102
uses: dtolnay/rust-toolchain@stable
103103
with:
104-
# Not MSRV because its harder to jump between versions and people are
105-
# more likely to have stable
106-
toolchain: stable
104+
toolchain: "1.76" # STABLE
107105
components: rustfmt
108106
- uses: Swatinem/rust-cache@v2
109107
- name: Check formatting
@@ -119,13 +117,13 @@ jobs:
119117
- name: Install Rust
120118
uses: dtolnay/rust-toolchain@stable
121119
with:
122-
toolchain: "1.73" # MSRV
120+
toolchain: "1.76" # STABLE
123121
components: clippy
124122
- uses: Swatinem/rust-cache@v2
125123
- name: Install SARIF tools
126-
run: cargo install clippy-sarif --version 0.3.4 --locked # Held back due to msrv
124+
run: cargo install clippy-sarif --locked
127125
- name: Install SARIF tools
128-
run: cargo install sarif-fmt --version 0.3.4 --locked # Held back due to msrv
126+
run: cargo install sarif-fmt --locked
129127
- name: Check
130128
run: >
131129
cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated

.github/workflows/committed.yml

+4
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,10 @@ env:
1111
CARGO_TERM_COLOR: always
1212
CLICOLOR: 1
1313

14+
concurrency:
15+
group: "${{ github.workflow }}-${{ github.ref }}"
16+
cancel-in-progress: true
17+
1418
jobs:
1519
committed:
1620
name: Lint Commits

.github/workflows/pre-commit.yml

+5-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,17 @@ permissions: {} # none
55
on:
66
pull_request:
77
push:
8-
branches: [main]
8+
branches: [master]
99

1010
env:
1111
RUST_BACKTRACE: 1
1212
CARGO_TERM_COLOR: always
1313
CLICOLOR: 1
1414

15+
concurrency:
16+
group: "${{ github.workflow }}-${{ github.ref }}"
17+
cancel-in-progress: true
18+
1519
jobs:
1620
pre-commit:
1721
permissions:

.github/workflows/rust-next.yml

+16-14
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,16 @@ env:
1212
CARGO_TERM_COLOR: always
1313
CLICOLOR: 1
1414

15+
concurrency:
16+
group: "${{ github.workflow }}-${{ github.ref }}"
17+
cancel-in-progress: true
18+
1519
jobs:
1620
test:
1721
name: Test
1822
strategy:
1923
matrix:
20-
os: ["ubuntu-latest", "windows-latest", "macos-latest"]
24+
os: ["ubuntu-latest", "windows-latest", "macos-latest", "macos-14"]
2125
rust: ["stable", "beta"]
2226
include:
2327
- os: ubuntu-latest
@@ -32,12 +36,11 @@ jobs:
3236
with:
3337
toolchain: ${{ matrix.rust }}
3438
- uses: Swatinem/rust-cache@v2
35-
- name: Default features
36-
run: cargo test --workspace
37-
- name: All features
38-
run: cargo test --workspace --all-features
39-
- name: No-default features
40-
run: cargo test --workspace --no-default-features
39+
- uses: taiki-e/install-action@cargo-hack
40+
- name: Build
41+
run: cargo test --workspace --no-run
42+
- name: Test
43+
run: cargo hack test --feature-powerset --workspace
4144
latest:
4245
name: "Check latest dependencies"
4346
runs-on: ubuntu-latest
@@ -49,11 +52,10 @@ jobs:
4952
with:
5053
toolchain: stable
5154
- uses: Swatinem/rust-cache@v2
52-
- name: Update dependencues
55+
- uses: taiki-e/install-action@cargo-hack
56+
- name: Update dependencies
5357
run: cargo update
54-
- name: Default features
55-
run: cargo test --workspace --all-targets
56-
- name: All features
57-
run: cargo test --workspace --all-targets --all-features
58-
- name: No-default features
59-
run: cargo test --workspace --all-targets --no-default-features
58+
- name: Build
59+
run: cargo test --workspace --no-run
60+
- name: Test
61+
run: cargo hack test --feature-powerset --workspace

.github/workflows/spelling.yml

+4
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,10 @@ env:
1010
CARGO_TERM_COLOR: always
1111
CLICOLOR: 1
1212

13+
concurrency:
14+
group: "${{ github.workflow }}-${{ github.ref }}"
15+
cancel-in-progress: true
16+
1317
jobs:
1418
spelling:
1519
name: Spell Check with Typos

Cargo.toml

+67
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,70 @@ harness = false
4848
[features]
4949
default = []
5050
testing-colors = []
51+
52+
[lints.rust]
53+
rust_2018_idioms = { level = "warn", priority = -1 }
54+
unreachable_pub = "warn"
55+
unsafe_op_in_unsafe_fn = "warn"
56+
unused_lifetimes = "warn"
57+
unused_macro_rules = "warn"
58+
unused_qualifications = "warn"
59+
60+
[lints.clippy]
61+
bool_assert_comparison = "allow"
62+
branches_sharing_code = "allow"
63+
checked_conversions = "warn"
64+
collapsible_else_if = "allow"
65+
create_dir = "warn"
66+
dbg_macro = "warn"
67+
debug_assert_with_mut_call = "warn"
68+
doc_markdown = "warn"
69+
empty_enum = "warn"
70+
enum_glob_use = "warn"
71+
expl_impl_clone_on_copy = "warn"
72+
explicit_deref_methods = "warn"
73+
explicit_into_iter_loop = "warn"
74+
fallible_impl_from = "warn"
75+
filter_map_next = "warn"
76+
flat_map_option = "warn"
77+
float_cmp_const = "warn"
78+
fn_params_excessive_bools = "warn"
79+
from_iter_instead_of_collect = "warn"
80+
if_same_then_else = "allow"
81+
implicit_clone = "warn"
82+
imprecise_flops = "warn"
83+
inconsistent_struct_constructor = "warn"
84+
inefficient_to_string = "warn"
85+
infinite_loop = "warn"
86+
invalid_upcast_comparisons = "warn"
87+
large_digit_groups = "warn"
88+
large_stack_arrays = "warn"
89+
large_types_passed_by_value = "warn"
90+
let_and_return = "allow" # sometimes good to name what you are returning
91+
linkedlist = "warn"
92+
lossy_float_literal = "warn"
93+
macro_use_imports = "warn"
94+
mem_forget = "warn"
95+
mutex_integer = "warn"
96+
needless_continue = "warn"
97+
needless_for_each = "warn"
98+
negative_feature_names = "warn"
99+
path_buf_push_overwrite = "warn"
100+
ptr_as_ptr = "warn"
101+
rc_mutex = "warn"
102+
redundant_feature_names = "warn"
103+
ref_option_ref = "warn"
104+
rest_pat_in_fully_bound_structs = "warn"
105+
same_functions_in_if_condition = "warn"
106+
self_named_module_files = "warn"
107+
semicolon_if_nothing_returned = "warn"
108+
str_to_string = "warn"
109+
string_add = "warn"
110+
string_add_assign = "warn"
111+
string_lit_as_bytes = "warn"
112+
string_to_string = "warn"
113+
todo = "warn"
114+
trait_duplication_in_bounds = "warn"
115+
verbose_file_reads = "warn"
116+
wildcard_imports = "warn"
117+
zero_sized_map_values = "warn"

benches/simple.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ fn create_snippet(renderer: Renderer) {
5050

5151
pub fn criterion_benchmark(c: &mut Criterion) {
5252
c.bench_function("format", |b| {
53-
b.iter(|| black_box(create_snippet(Renderer::plain())))
53+
b.iter(|| black_box(create_snippet(Renderer::plain())));
5454
});
5555
}
5656

0 commit comments

Comments
 (0)