Skip to content

Commit d5344dc

Browse files
committed
Add rustfmt to CI, ignore all files
We add the previously discussed `rustfmt.toml` and enforce it in CI for any files that are not contained in an exclusion list. To start, we add all current Rust files to this exclusion list. This means that formatter rules will be enforced for any newly introduced files, and we'll then start going through the codebase file-by-file, removing them from the list as we go.
1 parent a9d73c2 commit d5344dc

File tree

4 files changed

+312
-1
lines changed

4 files changed

+312
-1
lines changed

.github/workflows/build.yml

+17
Original file line numberDiff line numberDiff line change
@@ -216,3 +216,20 @@ jobs:
216216
- name: Run default clippy linting
217217
run: |
218218
cargo clippy -- -Aclippy::erasing_op -Aclippy::never_loop -Aclippy::if_same_then_else -Dclippy::try_err
219+
220+
rustfmt:
221+
runs-on: ubuntu-latest
222+
env:
223+
TOOLCHAIN: 1.63.0
224+
steps:
225+
- name: Checkout source code
226+
uses: actions/checkout@v3
227+
- name: Install Rust ${{ env.TOOLCHAIN }} toolchain
228+
run: |
229+
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh -s -- -y --profile=minimal --default-toolchain ${{ env.TOOLCHAIN }}
230+
rustup override set ${{ env.TOOLCHAIN }}
231+
- name: Install rustfmt
232+
run: |
233+
rustup component add rustfmt
234+
- name: Run rustfmt checks
235+
run: ci/rustfmt.sh

ci/rustfmt.sh

+13
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
set -eox pipefail
3+
4+
# Generate initial exclusion list
5+
#find . -name '*.rs' -type f |sort >rustfmt_excluded_files
6+
7+
# Run fmt
8+
TMP_FILE=$(mktemp)
9+
find . -name '*.rs' -type f |sort >$TMP_FILE
10+
for file in $(comm -23 $TMP_FILE rustfmt_excluded_files); do
11+
echo "Checking formatting of $file"
12+
rustfmt +1.63.0 --check $file
13+
done

rustfmt.toml

+12-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
1-
disable_all_formatting = true
1+
use_small_heuristics = "Max"
2+
fn_args_layout = "Compressed"
3+
hard_tabs = true
4+
use_field_init_shorthand = true
5+
max_width = 100
6+
match_block_trailing_comma = true
7+
# UNSTABLE: format_code_in_doc_comments = true
8+
# UNSTABLE: overflow_delimited_expr = true
9+
# UNSTABLE: comment_width = 100
10+
# UNSTABLE: format_macro_matchers = true
11+
# UNSTABLE: format_strings = true
12+
# UNSTABLE: group_imports = "StdExternalCrate"

rustfmt_excluded_files

+270
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,270 @@
1+
./bench/benches/bench.rs
2+
./fuzz/src/base32.rs
3+
./fuzz/src/bech32_parse.rs
4+
./fuzz/src/bin/base32_target.rs
5+
./fuzz/src/bin/bech32_parse_target.rs
6+
./fuzz/src/bin/chanmon_consistency_target.rs
7+
./fuzz/src/bin/chanmon_deser_target.rs
8+
./fuzz/src/bin/fromstr_to_netaddress_target.rs
9+
./fuzz/src/bin/full_stack_target.rs
10+
./fuzz/src/bin/indexedmap_target.rs
11+
./fuzz/src/bin/invoice_deser_target.rs
12+
./fuzz/src/bin/invoice_request_deser_target.rs
13+
./fuzz/src/bin/msg_accept_channel_target.rs
14+
./fuzz/src/bin/msg_accept_channel_v2_target.rs
15+
./fuzz/src/bin/msg_announcement_signatures_target.rs
16+
./fuzz/src/bin/msg_channel_announcement_target.rs
17+
./fuzz/src/bin/msg_channel_details_target.rs
18+
./fuzz/src/bin/msg_channel_ready_target.rs
19+
./fuzz/src/bin/msg_channel_reestablish_target.rs
20+
./fuzz/src/bin/msg_channel_update_target.rs
21+
./fuzz/src/bin/msg_closing_signed_target.rs
22+
./fuzz/src/bin/msg_commitment_signed_target.rs
23+
./fuzz/src/bin/msg_decoded_onion_error_packet_target.rs
24+
./fuzz/src/bin/msg_error_message_target.rs
25+
./fuzz/src/bin/msg_funding_created_target.rs
26+
./fuzz/src/bin/msg_funding_signed_target.rs
27+
./fuzz/src/bin/msg_gossip_timestamp_filter_target.rs
28+
./fuzz/src/bin/msg_init_target.rs
29+
./fuzz/src/bin/msg_node_announcement_target.rs
30+
./fuzz/src/bin/msg_open_channel_target.rs
31+
./fuzz/src/bin/msg_open_channel_v2_target.rs
32+
./fuzz/src/bin/msg_ping_target.rs
33+
./fuzz/src/bin/msg_pong_target.rs
34+
./fuzz/src/bin/msg_query_channel_range_target.rs
35+
./fuzz/src/bin/msg_query_short_channel_ids_target.rs
36+
./fuzz/src/bin/msg_reply_channel_range_target.rs
37+
./fuzz/src/bin/msg_reply_short_channel_ids_end_target.rs
38+
./fuzz/src/bin/msg_revoke_and_ack_target.rs
39+
./fuzz/src/bin/msg_shutdown_target.rs
40+
./fuzz/src/bin/msg_splice_ack_target.rs
41+
./fuzz/src/bin/msg_splice_locked_target.rs
42+
./fuzz/src/bin/msg_splice_target.rs
43+
./fuzz/src/bin/msg_stfu_target.rs
44+
./fuzz/src/bin/msg_tx_abort_target.rs
45+
./fuzz/src/bin/msg_tx_ack_rbf_target.rs
46+
./fuzz/src/bin/msg_tx_add_input_target.rs
47+
./fuzz/src/bin/msg_tx_add_output_target.rs
48+
./fuzz/src/bin/msg_tx_complete_target.rs
49+
./fuzz/src/bin/msg_tx_init_rbf_target.rs
50+
./fuzz/src/bin/msg_tx_remove_input_target.rs
51+
./fuzz/src/bin/msg_tx_remove_output_target.rs
52+
./fuzz/src/bin/msg_tx_signatures_target.rs
53+
./fuzz/src/bin/msg_update_add_htlc_target.rs
54+
./fuzz/src/bin/msg_update_fail_htlc_target.rs
55+
./fuzz/src/bin/msg_update_fail_malformed_htlc_target.rs
56+
./fuzz/src/bin/msg_update_fee_target.rs
57+
./fuzz/src/bin/msg_update_fulfill_htlc_target.rs
58+
./fuzz/src/bin/offer_deser_target.rs
59+
./fuzz/src/bin/onion_hop_data_target.rs
60+
./fuzz/src/bin/onion_message_target.rs
61+
./fuzz/src/bin/peer_crypt_target.rs
62+
./fuzz/src/bin/process_network_graph_target.rs
63+
./fuzz/src/bin/refund_deser_target.rs
64+
./fuzz/src/bin/router_target.rs
65+
./fuzz/src/bin/zbase32_target.rs
66+
./fuzz/src/chanmon_consistency.rs
67+
./fuzz/src/chanmon_deser.rs
68+
./fuzz/src/fromstr_to_netaddress.rs
69+
./fuzz/src/full_stack.rs
70+
./fuzz/src/indexedmap.rs
71+
./fuzz/src/invoice_deser.rs
72+
./fuzz/src/invoice_request_deser.rs
73+
./fuzz/src/lib.rs
74+
./fuzz/src/msg_targets/mod.rs
75+
./fuzz/src/msg_targets/msg_accept_channel.rs
76+
./fuzz/src/msg_targets/msg_accept_channel_v2.rs
77+
./fuzz/src/msg_targets/msg_announcement_signatures.rs
78+
./fuzz/src/msg_targets/msg_channel_announcement.rs
79+
./fuzz/src/msg_targets/msg_channel_details.rs
80+
./fuzz/src/msg_targets/msg_channel_ready.rs
81+
./fuzz/src/msg_targets/msg_channel_reestablish.rs
82+
./fuzz/src/msg_targets/msg_channel_update.rs
83+
./fuzz/src/msg_targets/msg_closing_signed.rs
84+
./fuzz/src/msg_targets/msg_commitment_signed.rs
85+
./fuzz/src/msg_targets/msg_decoded_onion_error_packet.rs
86+
./fuzz/src/msg_targets/msg_error_message.rs
87+
./fuzz/src/msg_targets/msg_funding_created.rs
88+
./fuzz/src/msg_targets/msg_funding_signed.rs
89+
./fuzz/src/msg_targets/msg_gossip_timestamp_filter.rs
90+
./fuzz/src/msg_targets/msg_init.rs
91+
./fuzz/src/msg_targets/msg_node_announcement.rs
92+
./fuzz/src/msg_targets/msg_open_channel.rs
93+
./fuzz/src/msg_targets/msg_open_channel_v2.rs
94+
./fuzz/src/msg_targets/msg_ping.rs
95+
./fuzz/src/msg_targets/msg_pong.rs
96+
./fuzz/src/msg_targets/msg_query_channel_range.rs
97+
./fuzz/src/msg_targets/msg_query_short_channel_ids.rs
98+
./fuzz/src/msg_targets/msg_reply_channel_range.rs
99+
./fuzz/src/msg_targets/msg_reply_short_channel_ids_end.rs
100+
./fuzz/src/msg_targets/msg_revoke_and_ack.rs
101+
./fuzz/src/msg_targets/msg_shutdown.rs
102+
./fuzz/src/msg_targets/msg_splice.rs
103+
./fuzz/src/msg_targets/msg_splice_ack.rs
104+
./fuzz/src/msg_targets/msg_splice_locked.rs
105+
./fuzz/src/msg_targets/msg_stfu.rs
106+
./fuzz/src/msg_targets/msg_tx_abort.rs
107+
./fuzz/src/msg_targets/msg_tx_ack_rbf.rs
108+
./fuzz/src/msg_targets/msg_tx_add_input.rs
109+
./fuzz/src/msg_targets/msg_tx_add_output.rs
110+
./fuzz/src/msg_targets/msg_tx_complete.rs
111+
./fuzz/src/msg_targets/msg_tx_init_rbf.rs
112+
./fuzz/src/msg_targets/msg_tx_remove_input.rs
113+
./fuzz/src/msg_targets/msg_tx_remove_output.rs
114+
./fuzz/src/msg_targets/msg_tx_signatures.rs
115+
./fuzz/src/msg_targets/msg_update_add_htlc.rs
116+
./fuzz/src/msg_targets/msg_update_fail_htlc.rs
117+
./fuzz/src/msg_targets/msg_update_fail_malformed_htlc.rs
118+
./fuzz/src/msg_targets/msg_update_fee.rs
119+
./fuzz/src/msg_targets/msg_update_fulfill_htlc.rs
120+
./fuzz/src/msg_targets/msg_warning_message.rs
121+
./fuzz/src/msg_targets/utils.rs
122+
./fuzz/src/offer_deser.rs
123+
./fuzz/src/onion_hop_data.rs
124+
./fuzz/src/onion_message.rs
125+
./fuzz/src/peer_crypt.rs
126+
./fuzz/src/process_network_graph.rs
127+
./fuzz/src/refund_deser.rs
128+
./fuzz/src/router.rs
129+
./fuzz/src/utils/mod.rs
130+
./fuzz/src/utils/test_logger.rs
131+
./fuzz/src/utils/test_persister.rs
132+
./fuzz/src/zbase32.rs
133+
./lightning-background-processor/src/lib.rs
134+
./lightning-block-sync/src/convert.rs
135+
./lightning-block-sync/src/gossip.rs
136+
./lightning-block-sync/src/http.rs
137+
./lightning-block-sync/src/init.rs
138+
./lightning-block-sync/src/lib.rs
139+
./lightning-block-sync/src/poll.rs
140+
./lightning-block-sync/src/rest.rs
141+
./lightning-block-sync/src/rpc.rs
142+
./lightning-block-sync/src/test_utils.rs
143+
./lightning-block-sync/src/utils.rs
144+
./lightning-custom-message/src/lib.rs
145+
./lightning-invoice/fuzz/fuzz_targets/serde_data_part.rs
146+
./lightning-invoice/src/de.rs
147+
./lightning-invoice/src/lib.rs
148+
./lightning-invoice/src/payment.rs
149+
./lightning-invoice/src/ser.rs
150+
./lightning-invoice/src/tb.rs
151+
./lightning-invoice/src/utils.rs
152+
./lightning-invoice/tests/ser_de.rs
153+
./lightning-net-tokio/src/lib.rs
154+
./lightning-persister/src/fs_store.rs
155+
./lightning-persister/src/lib.rs
156+
./lightning-persister/src/test_utils.rs
157+
./lightning-persister/src/utils.rs
158+
./lightning-rapid-gossip-sync/src/error.rs
159+
./lightning-rapid-gossip-sync/src/lib.rs
160+
./lightning-rapid-gossip-sync/src/processing.rs
161+
./lightning-transaction-sync/src/common.rs
162+
./lightning-transaction-sync/src/electrum.rs
163+
./lightning-transaction-sync/src/error.rs
164+
./lightning-transaction-sync/src/esplora.rs
165+
./lightning-transaction-sync/src/lib.rs
166+
./lightning-transaction-sync/tests/integration_tests.rs
167+
./lightning/src/blinded_path/message.rs
168+
./lightning/src/blinded_path/mod.rs
169+
./lightning/src/blinded_path/payment.rs
170+
./lightning/src/blinded_path/utils.rs
171+
./lightning/src/chain/chaininterface.rs
172+
./lightning/src/chain/chainmonitor.rs
173+
./lightning/src/chain/channelmonitor.rs
174+
./lightning/src/chain/mod.rs
175+
./lightning/src/chain/onchaintx.rs
176+
./lightning/src/chain/package.rs
177+
./lightning/src/chain/transaction.rs
178+
./lightning/src/crypto/chacha20.rs
179+
./lightning/src/crypto/chacha20poly1305rfc.rs
180+
./lightning/src/crypto/mod.rs
181+
./lightning/src/crypto/poly1305.rs
182+
./lightning/src/crypto/streams.rs
183+
./lightning/src/crypto/utils.rs
184+
./lightning/src/events/bump_transaction.rs
185+
./lightning/src/events/mod.rs
186+
./lightning/src/lib.rs
187+
./lightning/src/ln/async_signer_tests.rs
188+
./lightning/src/ln/blinded_payment_tests.rs
189+
./lightning/src/ln/chan_utils.rs
190+
./lightning/src/ln/chanmon_update_fail_tests.rs
191+
./lightning/src/ln/channel.rs
192+
./lightning/src/ln/channel_id.rs
193+
./lightning/src/ln/channel_keys.rs
194+
./lightning/src/ln/channelmanager.rs
195+
./lightning/src/ln/features.rs
196+
./lightning/src/ln/functional_test_utils.rs
197+
./lightning/src/ln/functional_tests.rs
198+
./lightning/src/ln/inbound_payment.rs
199+
./lightning/src/ln/mod.rs
200+
./lightning/src/ln/monitor_tests.rs
201+
./lightning/src/ln/msgs.rs
202+
./lightning/src/ln/offers_tests.rs
203+
./lightning/src/ln/onion_payment.rs
204+
./lightning/src/ln/onion_route_tests.rs
205+
./lightning/src/ln/onion_utils.rs
206+
./lightning/src/ln/outbound_payment.rs
207+
./lightning/src/ln/payment_tests.rs
208+
./lightning/src/ln/peer_channel_encryptor.rs
209+
./lightning/src/ln/peer_handler.rs
210+
./lightning/src/ln/priv_short_conf_tests.rs
211+
./lightning/src/ln/reload_tests.rs
212+
./lightning/src/ln/reorg_tests.rs
213+
./lightning/src/ln/script.rs
214+
./lightning/src/ln/shutdown_tests.rs
215+
./lightning/src/ln/wire.rs
216+
./lightning/src/offers/invoice.rs
217+
./lightning/src/offers/invoice_error.rs
218+
./lightning/src/offers/invoice_request.rs
219+
./lightning/src/offers/merkle.rs
220+
./lightning/src/offers/mod.rs
221+
./lightning/src/offers/offer.rs
222+
./lightning/src/offers/parse.rs
223+
./lightning/src/offers/payer.rs
224+
./lightning/src/offers/refund.rs
225+
./lightning/src/offers/signer.rs
226+
./lightning/src/offers/test_utils.rs
227+
./lightning/src/onion_message/functional_tests.rs
228+
./lightning/src/onion_message/messenger.rs
229+
./lightning/src/onion_message/mod.rs
230+
./lightning/src/onion_message/offers.rs
231+
./lightning/src/onion_message/packet.rs
232+
./lightning/src/routing/gossip.rs
233+
./lightning/src/routing/mod.rs
234+
./lightning/src/routing/router.rs
235+
./lightning/src/routing/scoring.rs
236+
./lightning/src/routing/test_utils.rs
237+
./lightning/src/routing/utxo.rs
238+
./lightning/src/sign/ecdsa.rs
239+
./lightning/src/sign/mod.rs
240+
./lightning/src/sign/taproot.rs
241+
./lightning/src/sign/type_resolver.rs
242+
./lightning/src/sync/debug_sync.rs
243+
./lightning/src/sync/fairrwlock.rs
244+
./lightning/src/sync/mod.rs
245+
./lightning/src/sync/nostd_sync.rs
246+
./lightning/src/sync/test_lockorder_checks.rs
247+
./lightning/src/util/atomic_counter.rs
248+
./lightning/src/util/base32.rs
249+
./lightning/src/util/byte_utils.rs
250+
./lightning/src/util/config.rs
251+
./lightning/src/util/errors.rs
252+
./lightning/src/util/fuzz_wrappers.rs
253+
./lightning/src/util/indexed_map.rs
254+
./lightning/src/util/invoice.rs
255+
./lightning/src/util/logger.rs
256+
./lightning/src/util/macro_logger.rs
257+
./lightning/src/util/message_signing.rs
258+
./lightning/src/util/mod.rs
259+
./lightning/src/util/persist.rs
260+
./lightning/src/util/scid_utils.rs
261+
./lightning/src/util/ser.rs
262+
./lightning/src/util/ser_macros.rs
263+
./lightning/src/util/string.rs
264+
./lightning/src/util/test_channel_signer.rs
265+
./lightning/src/util/test_utils.rs
266+
./lightning/src/util/time.rs
267+
./lightning/src/util/transaction_utils.rs
268+
./lightning/src/util/wakers.rs
269+
./msrv-no-dev-deps-check/src/lib.rs
270+
./no-std-check/src/lib.rs

0 commit comments

Comments
 (0)