Skip to content

Commit 494f2c2

Browse files
authored
Merge pull request #1194 from epage/template
chore: Update from '_rust/main' template
2 parents dcd1668 + 7d4b8e6 commit 494f2c2

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+567
-316
lines changed

.clippy.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
msrv = "1.76" # MSRV
2-
warn-on-all-wildcard-imports = true
1+
allow-print-in-tests = true
32
allow-expect-in-tests = true
43
allow-unwrap-in-tests = true
54
allow-dbg-in-tests = true

.github/renovate.json5

+8-7
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,29 +18,28 @@
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: '126 days', // 3 releases * 6 weeks per release * 7 days per week
38-
internalChecksFilter: 'strict',
3938
extractVersion: '^(?<version>\\d+\\.\\d+)', // Drop the patch version
4039
schedule: [
4140
'* * * * *',
4241
],
42+
automerge: true,
4343
},
4444
// Goals:
4545
// - Rollup safe upgrades to reduce CI runner load
@@ -62,6 +62,7 @@
6262
matchCurrentVersion: '>=1.0.0',
6363
matchUpdateTypes: [
6464
'minor',
65+
'patch',
6566
],
6667
automerge: true,
6768
groupName: 'compatible',

.github/settings.yml

+15-11
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,18 @@ labels:
4242
color: '#c2e0c6'
4343
description: "Help wanted!"
4444

45-
branches:
46-
- name: master
47-
protection:
48-
required_pull_request_reviews: null
49-
required_conversation_resolution: true
50-
required_status_checks:
51-
# Required. Require branches to be up to date before merging.
52-
strict: false
53-
contexts: ["CI", "Lint Commits", "Spell Check with Typos"]
54-
enforce_admins: false
55-
restrictions: null
45+
# This serves more as documentation.
46+
# Branch protection API was replaced by rulesets but settings isn't updated.
47+
# See https://github.com/repository-settings/app/issues/825
48+
#
49+
# branches:
50+
# - name: master
51+
# protection:
52+
# required_pull_request_reviews: null
53+
# required_conversation_resolution: true
54+
# required_status_checks:
55+
# # Required. Require branches to be up to date before merging.
56+
# strict: false
57+
# contexts: ["CI", "Spell Check with Typos"]
58+
# enforce_admins: false
59+
# restrictions: null

.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

+40-19
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,22 @@ env:
1313
CARGO_TERM_COLOR: always
1414
CLICOLOR: 1
1515

16+
concurrency:
17+
group: "${{ github.workflow }}-${{ github.ref }}"
18+
cancel-in-progress: true
19+
1620
jobs:
1721
ci:
1822
permissions:
1923
contents: none
2024
name: CI
21-
needs: [test, msrv, docs, rustfmt, clippy]
25+
needs: [test, msrv, lockfile, docs, rustfmt, clippy]
2226
runs-on: ubuntu-latest
27+
if: "always()"
2328
steps:
24-
- name: Done
25-
run: exit 0
29+
- name: Failed
30+
run: exit 1
31+
if: "contains(needs.*.result, 'failure') || contains(needs.*.result, 'cancelled') || contains(needs.*.result, 'skipped')"
2632
test:
2733
name: Test
2834
strategy:
@@ -40,29 +46,27 @@ 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
51+
run: cargo test --workspace --no-run
4552
- name: Default features
4653
run: cargo test --workspace
4754
- name: No-default features
4855
run: cargo test --workspace --no-default-features
4956
msrv:
50-
name: "Check MSRV: 1.76"
57+
name: "Check MSRV"
5158
runs-on: ubuntu-latest
5259
steps:
5360
- name: Checkout repository
5461
uses: actions/checkout@v4
5562
- name: Install Rust
5663
uses: dtolnay/rust-toolchain@stable
5764
with:
58-
toolchain: "1.76" # MSRV
65+
toolchain: stable
5966
- uses: Swatinem/rust-cache@v2
67+
- uses: taiki-e/install-action@cargo-hack
6068
- name: Default features
61-
run: cargo check --workspace --all-targets
62-
- name: All features
63-
run: cargo check --workspace --all-targets --all-features
64-
- name: No-default features
65-
run: cargo check --workspace --all-targets --no-default-features
69+
run: cargo hack check --feature-powerset --locked --rust-version --ignore-private --workspace --all-targets
6670
lockfile:
6771
runs-on: ubuntu-latest
6872
steps:
@@ -74,7 +78,7 @@ jobs:
7478
toolchain: stable
7579
- uses: Swatinem/rust-cache@v2
7680
- name: "Is lockfile updated?"
77-
run: cargo fetch --locked
81+
run: cargo update --workspace --locked
7882
docs:
7983
name: Docs
8084
runs-on: ubuntu-latest
@@ -84,7 +88,7 @@ jobs:
8488
- name: Install Rust
8589
uses: dtolnay/rust-toolchain@stable
8690
with:
87-
toolchain: stable
91+
toolchain: "1.76" # STABLE
8892
- uses: Swatinem/rust-cache@v2
8993
- name: Check documentation
9094
env:
@@ -99,9 +103,7 @@ jobs:
99103
- name: Install Rust
100104
uses: dtolnay/rust-toolchain@stable
101105
with:
102-
# Not MSRV because its harder to jump between versions and people are
103-
# more likely to have stable
104-
toolchain: stable
106+
toolchain: "1.76" # STABLE
105107
components: rustfmt
106108
- uses: Swatinem/rust-cache@v2
107109
- name: Check formatting
@@ -117,13 +119,13 @@ jobs:
117119
- name: Install Rust
118120
uses: dtolnay/rust-toolchain@stable
119121
with:
120-
toolchain: "1.76" # MSRV
122+
toolchain: "1.76" # STABLE
121123
components: clippy
122124
- uses: Swatinem/rust-cache@v2
123125
- name: Install SARIF tools
124-
run: cargo install clippy-sarif --version 0.3.4 --locked # Held back due to msrv
126+
run: cargo install clippy-sarif --locked
125127
- name: Install SARIF tools
126-
run: cargo install sarif-fmt --version 0.3.4 --locked # Held back due to msrv
128+
run: cargo install sarif-fmt --locked
127129
- name: Check
128130
run: >
129131
cargo clippy --workspace --all-features --all-targets --message-format=json -- -D warnings --allow deprecated
@@ -138,3 +140,22 @@ jobs:
138140
wait-for-processing: true
139141
- name: Report status
140142
run: cargo clippy --workspace --all-features --all-targets -- -D warnings --allow deprecated
143+
coverage:
144+
name: Coverage
145+
runs-on: ubuntu-latest
146+
steps:
147+
- name: Checkout repository
148+
uses: actions/checkout@v4
149+
- name: Install Rust
150+
uses: dtolnay/rust-toolchain@stable
151+
with:
152+
toolchain: stable
153+
- uses: Swatinem/rust-cache@v2
154+
- name: Install cargo-tarpaulin
155+
run: cargo install cargo-tarpaulin
156+
- name: Gather coverage
157+
run: cargo tarpaulin --output-dir coverage --out lcov
158+
- name: Publish to Coveralls
159+
uses: coverallsapp/github-action@master
160+
with:
161+
github-token: ${{ secrets.GITHUB_TOKEN }}

.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

+4
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ 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
pre-commit:
1721
permissions:

.github/workflows/rust-next.yml

+13-7
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
test:
1620
name: Test
@@ -32,6 +36,9 @@ jobs:
3236
with:
3337
toolchain: ${{ matrix.rust }}
3438
- uses: Swatinem/rust-cache@v2
39+
- uses: taiki-e/install-action@cargo-hack
40+
- name: Build
41+
run: cargo test --workspace --no-run
3542
- name: Default features
3643
run: cargo test --workspace
3744
- name: No-default features
@@ -47,11 +54,10 @@ jobs:
4754
with:
4855
toolchain: stable
4956
- uses: Swatinem/rust-cache@v2
50-
- name: Update dependencues
57+
- uses: taiki-e/install-action@cargo-hack
58+
- name: Update dependencies
5159
run: cargo update
52-
- name: Default features
53-
run: cargo test --workspace --all-targets
54-
- name: All features
55-
run: cargo test --workspace --all-targets --all-features
56-
- name: No-default features
57-
run: cargo test --workspace --all-targets --no-default-features
60+
- name: Build
61+
run: cargo test --workspace --no-run
62+
- name: Test
63+
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

CONTRIBUTING.md

+30-15
Original file line numberDiff line numberDiff line change
@@ -29,27 +29,42 @@ to re-work some of it and the discouragement that goes along with that.
2929

3030
### Process
3131

32-
Before posting a PR, we request that the commit history get cleaned up.
33-
However, we recommend avoiding this during the review to make it easier to
34-
check how feedback was handled. Once the PR is ready, we'll ask you to clean up
35-
the commit history from the review. Once you let us know this is done, we can
36-
move forward with merging! If you are uncomfortable with these parts of git,
37-
let us know and we can help.
38-
39-
For commit messages, we use [Conventional](https://www.conventionalcommits.org)
40-
style. If you already wrote your commits and don't feel comfortable changing
41-
them, don't worry and go ahead and create your PR. We'll work with you on the
42-
best route forward. You can check your branch locally with
43-
[`committed`](https://github.com/crate-ci/committed).
44-
4532
As a heads up, we'll be running your PR through the following gauntlet:
4633
- warnings turned to compile errors
4734
- `cargo test`
4835
- `rustfmt`
4936
- `clippy`
5037
- `rustdoc`
51-
- [`committed`](https://github.com/crate-ci/committed)
52-
- [`typos`](https://github.com/crate-ci/typos)
38+
- [`committed`](https://github.com/crate-ci/committed) as we use [Conventional](https://www.conventionalcommits.org) commit style
39+
- [`typos`](https://github.com/crate-ci/typos) to check spelling
40+
41+
Not everything can be checked automatically though.
42+
43+
We request that the commit history gets cleaned up.
44+
We ask that commits are atomic, meaning they are complete and have a single responsibility.
45+
PRs should tell a cohesive story, with test and refactor commits that keep the
46+
fix or feature commits simple and clear.
47+
48+
Specifically, we would encouage
49+
- File renames be isolated into their own commit
50+
- Add tests in a commit before their feature or fix, showing the current behavior.
51+
The diff for the feature/fix commit will then show how the behavior changed,
52+
making it clearer to reviewrs and the community and showing people that the
53+
test is verifying the expected state.
54+
- e.g. [clap#5520](https://github.com/clap-rs/clap/pull/5520)
55+
56+
Note that we are talking about ideals.
57+
We understand having a clean history requires more advanced git skills;
58+
feel free to ask us for help!
59+
We might even suggest where it would work to be lax.
60+
We also understand that editing some early commits may cause a lot of churn
61+
with merge conflicts which can make it not worth editing all of the history.
62+
63+
For code organization, we recommend
64+
- Grouping `impl` blocks next to their type (or trait)
65+
- Grouping private items after the `pub` item that uses them.
66+
- The intent is to help people quickly find the "relevant" details, allowing them to "dig deeper" as needed. Or put another way, the `pub` items serve as a table-of-contents.
67+
- The exact order is fuzzy; do what makes sense
5368

5469
## Releasing
5570

0 commit comments

Comments
 (0)