Skip to content

Commit 6bb1d0f

Browse files
committed
CI: Require TOML to be formatted
tombi is a pretty good TOML formatter/LSP with support for TOML in general, and Rust Cargo.toml in particular. Using a unified format is nice. In particular, tombi sorts not just properties within a section, but also sections and tables. Apparently some TOML parsers may fail if tables are not correctly sorted.
1 parent dfb2602 commit 6bb1d0f

File tree

3 files changed

+14
-0
lines changed

3 files changed

+14
-0
lines changed

.github/actions/setup/action.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,9 @@ inputs:
1919
rustfmt:
2020
description: Install Rustfmt if `true`. Defaults to `false`.
2121
required: false
22+
tombi:
23+
description: Install tombi if `true`. Defaults to `false`.
24+
required: false
2225
solana:
2326
description: Install Solana if `true`. Defaults to `false`.
2427
required: false
@@ -95,6 +98,10 @@ runs:
9598
toolchain: ${{ env.TOOLCHAIN_LINT }}
9699
components: clippy
97100

101+
- name: Install tombi
102+
if: ${{ inputs.tombi == 'true' }}
103+
uses: tombi-toml/setup-tombi@v1
104+
98105
- name: Install Solana
99106
if: ${{ inputs.solana == 'true' }}
100107
uses: solana-program/actions/install-solana@v1

.github/workflows/main.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ jobs:
3535
with:
3636
clippy: true
3737
rustfmt: true
38+
tombi: true
3839

3940
- name: Format Client Rust
4041
run: pnpm clients:rust:format
@@ -54,6 +55,7 @@ jobs:
5455
with:
5556
clippy: true
5657
rustfmt: true
58+
tombi: true
5759

5860
- name: Format
5961
run: pnpm programs:format
@@ -73,6 +75,7 @@ jobs:
7375
with:
7476
clippy: true
7577
rustfmt: true
78+
tombi: true
7679

7780
- name: Format
7881
run: pnpm p-interface:format
@@ -92,6 +95,7 @@ jobs:
9295
with:
9396
clippy: true
9497
rustfmt: true
98+
tombi: true
9599

96100
- name: Format
97101
run: pnpm p-token:format
@@ -111,6 +115,7 @@ jobs:
111115
with:
112116
clippy: true
113117
rustfmt: true
118+
tombi: true
114119

115120
- name: Format
116121
run: pnpm interface:format

scripts/rust/format.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@ const manifestPath = path.join(workingDirectory, folder, 'Cargo.toml');
1818

1919
// Format the client.
2020
if (fix) {
21+
await $`tombi format ${formatArgs} ${folder}`;
2122
await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- ${fmtArgs}`;
2223
} else {
24+
await $`tombi lint ${formatArgs} ${folder}`;
2325
await $`cargo ${toolchain} fmt --manifest-path ${manifestPath} ${cargoArgs} -- --check ${fmtArgs}`;
2426
}

0 commit comments

Comments
 (0)