Skip to content

Commit e1fd929

Browse files
authored
Introduce treefmt-nix as a universal formatter infra (#1221)
2 parents 91db248 + 3fff1aa commit e1fd929

Some content is hidden

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

48 files changed

+1554
-1164
lines changed

.cargo/mutants.toml

Lines changed: 27 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,34 @@
11
additional_cargo_args = ["--all-features"]
22
gitignore = true
3-
examine_globs = [
4-
"payjoin/src/**/*.rs"
5-
]
6-
exclude_globs = [
7-
]
3+
examine_globs = ["payjoin/src/**/*.rs"]
4+
exclude_globs = []
85
exclude_re = [
9-
"impl\\s+(std::fmt::|core::fmt::|fmt::)?(Display|Debug)",
10-
"deserialize",
11-
"Iterator",
12-
".*Error",
6+
"impl\\s+(std::fmt::|core::fmt::|fmt::)?(Display|Debug)",
7+
"deserialize",
8+
"Iterator",
9+
".*Error",
1310

14-
# ---------------------Crate-specific exclusions ---------------------
15-
# Timeout loops
16-
# src/receive/v1/mod.rs
17-
"interleave_shuffle", # Replacing index += 1 with index *= 1 in a loop causes a timeout due to an infinite loop
11+
# ---------------------Crate-specific exclusions ---------------------
12+
# Timeout loops
13+
# src/receive/v1/mod.rs
14+
"interleave_shuffle", # Replacing index += 1 with index *= 1 in a loop causes a timeout due to an infinite loop
1815

19-
# Trivial mutations
20-
# These exclusions are allowing code blocks to run with arithmetic involving zero and as a result are no-ops
21-
# payjoin/src/core/send/mod.rs
22-
"replace < with <= in PsbtContext::check_outputs",
23-
"replace > with >= in PsbtContext::check_fees",
24-
# payjoin/src/core/send/mod.rs
25-
"replace < with <= in PsbtContextBuilder::build_recommended", # clamping the fee contribution when the fee equals to the recommended fee does not do anything
26-
# payjoin/src/core/receive/v2/mod.rs
27-
"payjoin/src/core/receive/v2.mod.*replace \\* with [+/]$", # This targets mutations on the static TWENTY_FOUR_HOURS_DEFAULT_EXPIRATION that is not particularly useful to test for
16+
# Trivial mutations
17+
# These exclusions are allowing code blocks to run with arithmetic involving zero and as a result are no-ops
18+
# payjoin/src/core/send/mod.rs
19+
"replace < with <= in PsbtContext::check_outputs",
20+
"replace > with >= in PsbtContext::check_fees",
21+
# payjoin/src/core/send/mod.rs
22+
"replace < with <= in PsbtContextBuilder::build_recommended", # clamping the fee contribution when the fee equals to the recommended fee does not do anything
23+
# payjoin/src/core/receive/v2/mod.rs
24+
"payjoin/src/core/receive/v2.mod.*replace \\* with [+/]$", # This targets mutations on the static TWENTY_FOUR_HOURS_DEFAULT_EXPIRATION that is not particularly useful to test for
2825

29-
# TODO exclusions
30-
# payjoin/src/core/receive/v1/mod.rs
31-
"replace > with >= in WantsInputs::avoid_uih", # This mutation I am unsure about whether or not it is a trivial mutant and have not decided on how the best way to approach testing it is
32-
# payjoin/src/core/send/mod.rs
33-
"replace match guard proposed_txout.script_pubkey == original_output.script_pubkey with true in PsbtContext::check_outputs", # This non-deterministic mutation has a possible test to catch it
34-
# These will be removed following #1123
35-
# payjoin/src/core/send/v2/session.rs
36-
"SessionHistory::terminal_error",
26+
# TODO exclusions
27+
# payjoin/src/core/receive/v1/mod.rs
28+
"replace > with >= in WantsInputs::avoid_uih", # This mutation I am unsure about whether or not it is a trivial mutant and have not decided on how the best way to approach testing it is
29+
# payjoin/src/core/send/mod.rs
30+
"replace match guard proposed_txout.script_pubkey == original_output.script_pubkey with true in PsbtContext::check_outputs", # This non-deterministic mutation has a possible test to catch it
31+
# These will be removed following #1123
32+
# payjoin/src/core/send/v2/session.rs
33+
"SessionHistory::terminal_error",
3734
]

.git-blame-ignore-revs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
d9aa8187499a28f1244d8a57d2b474efabd3c1a1
2+
4157a3babacca1a63fac12364446d79aa464b378

.github/CONTRIBUTING.md

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,13 +85,14 @@ As a small exception, trivial tab-completion doesn't need to be disclosed,
8585
so long as it is limited to single keywords or short phrases.
8686

8787
An example disclosure:
88+
8889
> This PR was written primarily by Claude Code.
89-
Or a more detailed disclosure:
90+
> Or a more detailed disclosure:
9091
> I consulted ChatGPT to understand the codebase but the solution
9192
> was fully authored manually by myself.
92-
Failure to disclose this is impolite to the human operators
93-
on the other end of the pull request, and it also makes it difficult to
94-
determine how much scrutiny to apply to the contribution.
93+
> Failure to disclose this is impolite to the human operators
94+
> on the other end of the pull request, and it also makes it difficult to
95+
> determine how much scrutiny to apply to the contribution.
9596
9697
Please be respectful to maintainers and disclose AI assistance so that
9798
they may help you effectively contribute.

.github/ISSUE_TEMPLATE/minor-release.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,8 @@
22
name: Minor Release
33
about: Checklist for releasing a new minor version bump
44
title: Release MAJOR.MINOR+1.0
5-
labels: ''
6-
assignees: ''
7-
5+
labels: ""
6+
assignees: ""
87
---
98

109
## Create a new minor release
@@ -24,7 +23,7 @@ assignees: ''
2423
### Checklist
2524

2625
Release numbering must follow [Semantic Versioning]. These steps assume the current `master`
27-
branch **development** version is *MAJOR.MINOR.0*.
26+
branch **development** version is _MAJOR.MINOR.0_.
2827

2928
#### On the day of the feature freeze
3029

@@ -41,7 +40,7 @@ Change the `master` branch to the next MINOR+1 version:
4140
- Title PR "Bump CRATE version to MAJOR.MINOR+1.0".
4241
- [ ] Merge the `bump-CRATE-MAJOR-MINOR+1` branch to `master`.
4342

44-
If any issues need to be fixed before the *MAJOR.MINOR+1.0* version is released:
43+
If any issues need to be fixed before the _MAJOR.MINOR+1.0_ version is released:
4544

4645
- [ ] Merge fix PRs to the `master` branch.
4746
- [ ] Git cherry-pick fix commits to the `bump-CRATE-MAJOR.MINOR+1` branch.

.github/pull_request_template.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
Please confirm the following before requesting review:
55

66
- [ ] I have [disclosed my use of
7-
AI](https://github.com/payjoin/rust-payjoin/blob/master/.github/CONTRIBUTING.md#ai-assistance-notice)
8-
in the body of this PR.
7+
AI](https://github.com/payjoin/rust-payjoin/blob/master/.github/CONTRIBUTING.md#ai-assistance-notice)
8+
in the body of this PR.
99
- [ ] I have read [CONTRIBUTING.md](https://github.com/payjoin/rust-payjoin/blob/master/.github/CONTRIBUTING.md#commits) and **rebased my branch to produce [hygienic commits](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#committing-patches)**.
1010
</details>

.github/workflows/cron-directory-monitor.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name : Payjoin directory health check
1+
name: Payjoin directory health check
22
on:
33
schedule:
44
- cron: "*/15 * * * *" # Every 15 minutes

.github/workflows/cron-weekly-mutants.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name: Weekly cargo-mutants
2-
on:
3-
schedule:
2+
on:
3+
schedule:
44
- cron: "0 0 * * 0" # runs weekly on Sunday at 00:00
55
workflow_dispatch: # allows manual triggering
66
jobs:

.github/workflows/dart.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,3 @@ jobs:
4040

4141
- name: Run tests
4242
run: dart test
43-

.github/workflows/format.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Continuous integration
2+
3+
on: [push, pull_request]
4+
5+
jobs:
6+
Format:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- name: "Checkout repo"
10+
uses: actions/checkout@v4
11+
- name: "Install nix"
12+
uses: DeterminateSystems/determinate-nix-action@main
13+
- name: "Use nix cache"
14+
uses: DeterminateSystems/magic-nix-cache-action@main
15+
- name: Run treefmt
16+
run: |
17+
set -eo pipefail
18+
nix fmt -- --ci || {
19+
echo "❌ Code is not formatted. Showing diff:"
20+
git --no-pager diff
21+
exit 1
22+
}

.github/workflows/rust.yml

Lines changed: 3 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -40,34 +40,6 @@ jobs:
4040
- name: Run tests
4141
run: RUST_LOG=debug bash contrib/test.sh
4242

43-
Format:
44-
runs-on: ubuntu-latest
45-
steps:
46-
- name: "Checkout repo"
47-
uses: actions/checkout@v4
48-
- name: "Install nightly toolchain"
49-
uses: dtolnay/rust-toolchain@nightly
50-
with:
51-
components: rustfmt
52-
- name: "Use cache"
53-
uses: Swatinem/rust-cache@v2
54-
- name: "Run formatting check"
55-
run: cargo fmt --all -- --check
56-
57-
Format-FFI:
58-
runs-on: ubuntu-latest
59-
steps:
60-
- name: "Checkout repo"
61-
uses: actions/checkout@v4
62-
- name: "Install nightly toolchain"
63-
uses: dtolnay/rust-toolchain@nightly
64-
with:
65-
components: rustfmt
66-
- name: "Use cache"
67-
uses: Swatinem/rust-cache@v2
68-
- name: "Run formatting check"
69-
run: cd payjoin-ffi && cargo fmt --all -- --check
70-
7143
Lint-FFI:
7244
runs-on: ubuntu-latest
7345
steps:
@@ -131,15 +103,15 @@ jobs:
131103
run: bash contrib/coverage.sh
132104
- name: "Upload report to coveralls"
133105
uses: coverallsapp/github-action@v2
134-
135-
CodeSpell:
106+
107+
CodeSpell:
136108
name: Code spell check
137109
runs-on: ubuntu-latest
138110
steps:
139111
- uses: actions/checkout@v4
140112
- uses: codespell-project/actions-codespell@v2
141113

142-
DiffMutants:
114+
DiffMutants:
143115
name: Diff cargo-mutants
144116
runs-on: ubuntu-latest
145117
env:
@@ -172,4 +144,3 @@ jobs:
172144
with:
173145
name: mutants-incremental-cargo.out
174146
path: mutants.out
175-

0 commit comments

Comments
 (0)