Skip to content

[Feature]: Check TOML formatting #404

Open
@no30bit

Description

@no30bit

Summary

TOML files are currently arbitrarily formatted. This is not good for git diff and specifically for Cargo.toml consistency. For example, a snippet from Hermes Cargo.toml:

tokio = { version = "1.45.1", features = ["macros", "sync", "rt-multi-thread", "rt", "net"] } # Good formatting
libsqlite3-sys = {version="0.34.0", features = ["bundled"] } # Bad formatting

An extra CI check validating TOML files would be nice.

Description

Validating TOML files can be done with Taplo tool. It's available through cargo install, NPM, as a binary, etc. Precise formatting rules can be controlled with taplo.toml file.

CI install & check

In catalyst-ci/earthly/rust/tools/Earthfile add:

tool-taplo-cli:
    DO +CARGO_BINSTALL --package=taplo-cli --version=0.14.0

Then run it from catalyst-ci/earthly/rust/scripts/std_checks.py.

Configuration example

As one of the features, dependencies in Cargo.toml can be forced to be lexicographically ordered:

[formatting]
reorder_keys = false

[[rule]]
include = ["**/Cargo.toml"]
keys = ["dependencies"]

[rule.formatting]
reorder_keys = true

Note

Depending on the chosen configuration, some of the TOML files would need to be re-formatted.

Metadata

Metadata

Assignees

No one assigned

    Labels

    ci/cdCI/CD Fixes or Improvements.enhancementNew feature or requestsquad: gatekeepersCatalyst App Backend, System Development & Integration Teamsquad: hermeticsHermes Backend, System Development & Integration Team

    Type

    Projects

    Status

    📋 Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions