mirror of https://github.com/kitsune-soc/kitsune
Add TOML formatter and checks (#507)
* introduce toml formatter * add formatting check * Remove SCSS subcommand
This commit is contained in:
parent
2b0da5d039
commit
96de9876c3
|
@ -0,0 +1,23 @@
|
|||
name: "TOML checks"
|
||||
|
||||
on:
|
||||
merge_group:
|
||||
pull_request:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
fmt-check:
|
||||
name: "Formatting"
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: dtolnay/rust-toolchain@stable
|
||||
- run: |
|
||||
cargo xtask fmt-toml
|
||||
CHANGES_IN_REPO=$(git status --porcelain)
|
||||
if [[ -n "$CHANGES_IN_REPO" ]]; then
|
||||
exit 1
|
||||
fi
|
|
@ -1050,9 +1050,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
|||
|
||||
[[package]]
|
||||
name = "bytes"
|
||||
version = "1.5.0"
|
||||
version = "1.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a2bd12c1caf447e69cd4528f47f94d203fd2582878ecb9e9465484c4148a8223"
|
||||
checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9"
|
||||
dependencies = [
|
||||
"serde",
|
||||
]
|
||||
|
@ -1456,6 +1456,12 @@ version = "0.8.6"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f"
|
||||
|
||||
[[package]]
|
||||
name = "countme"
|
||||
version = "3.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "7704b5fdd17b18ae31c4c1da5a2e0305a2bf17b5249300a9ee9ed7b72114c636"
|
||||
|
||||
[[package]]
|
||||
name = "cpufeatures"
|
||||
version = "0.2.12"
|
||||
|
@ -2714,7 +2720,7 @@ dependencies = [
|
|||
"bstr",
|
||||
"log",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -3051,7 +3057,7 @@ dependencies = [
|
|||
"http 1.1.0",
|
||||
"httpdate",
|
||||
"itertools 0.12.1",
|
||||
"logos",
|
||||
"logos 0.14.0",
|
||||
"miette",
|
||||
"pkcs8",
|
||||
"proptest",
|
||||
|
@ -4450,13 +4456,22 @@ version = "0.4.21"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "90ed8c1e510134f979dbc4f070f87d4313098b704861a105fe34231c70a3901c"
|
||||
|
||||
[[package]]
|
||||
name = "logos"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bf8b031682c67a8e3d5446840f9573eb7fe26efe7ec8d195c9ac4c0647c502f1"
|
||||
dependencies = [
|
||||
"logos-derive 0.12.1",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "logos"
|
||||
version = "0.14.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "161971eb88a0da7ae0c333e1063467c5b5727e7fb6b710b8db4814eade3a42e8"
|
||||
dependencies = [
|
||||
"logos-derive",
|
||||
"logos-derive 0.14.0",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -4470,10 +4485,24 @@ dependencies = [
|
|||
"lazy_static",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.2",
|
||||
"syn 2.0.53",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "logos-derive"
|
||||
version = "0.12.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "a1d849148dbaf9661a6151d1ca82b13bb4c4c128146a88d05253b38d4e2f496c"
|
||||
dependencies = [
|
||||
"beef",
|
||||
"fnv",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex-syntax 0.6.29",
|
||||
"syn 1.0.109",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "logos-derive"
|
||||
version = "0.14.0"
|
||||
|
@ -5776,7 +5805,7 @@ dependencies = [
|
|||
"criterion",
|
||||
"futures",
|
||||
"insta",
|
||||
"logos",
|
||||
"logos 0.14.0",
|
||||
"pretty_assertions",
|
||||
]
|
||||
|
||||
|
@ -5907,7 +5936,7 @@ dependencies = [
|
|||
"rand 0.8.5",
|
||||
"rand_chacha 0.3.1",
|
||||
"rand_xorshift",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.2",
|
||||
"unarray",
|
||||
]
|
||||
|
||||
|
@ -6279,7 +6308,7 @@ dependencies = [
|
|||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-automata",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
@ -6290,9 +6319,15 @@ checksum = "86b83b8b9847f9bf95ef68afb0b8e6cdb80f498442f5179a29fad448fcc1eaea"
|
|||
dependencies = [
|
||||
"aho-corasick",
|
||||
"memchr",
|
||||
"regex-syntax",
|
||||
"regex-syntax 0.8.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.6.29"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f162c6dd7b008981e4d40210aca20b4bd0f9b60ca9271061b07f78537722f2e1"
|
||||
|
||||
[[package]]
|
||||
name = "regex-syntax"
|
||||
version = "0.8.2"
|
||||
|
@ -6405,6 +6440,19 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rowan"
|
||||
version = "0.15.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "32a58fa8a7ccff2aec4f39cc45bf5f985cec7125ab271cf681c279fd00192b49"
|
||||
dependencies = [
|
||||
"countme",
|
||||
"hashbrown 0.14.3",
|
||||
"memoffset",
|
||||
"rustc-hash",
|
||||
"text-size",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rsa"
|
||||
version = "0.9.6"
|
||||
|
@ -7479,6 +7527,26 @@ version = "1.0.1"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "55937e1799185b12863d447f42597ed69d9928686b8d88a1df17376a097d8369"
|
||||
|
||||
[[package]]
|
||||
name = "taplo"
|
||||
version = "0.13.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "52af7500383164409ea5e18ca813f70ded8dcb4ad044638dea8f0a43cd797942"
|
||||
dependencies = [
|
||||
"ahash 0.8.11",
|
||||
"arc-swap",
|
||||
"either",
|
||||
"globset",
|
||||
"itertools 0.10.5",
|
||||
"logos 0.12.1",
|
||||
"once_cell",
|
||||
"rowan",
|
||||
"serde_json",
|
||||
"thiserror",
|
||||
"time",
|
||||
"tracing",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "target-lexicon"
|
||||
version = "0.12.14"
|
||||
|
@ -7546,6 +7614,12 @@ dependencies = [
|
|||
"testcontainers",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "text-size"
|
||||
version = "1.1.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f18aa187839b2bdb1ad2fa35ead8c4c2976b64e4363c386d45ac0f7ee85c9233"
|
||||
|
||||
[[package]]
|
||||
name = "textwrap"
|
||||
version = "0.16.1"
|
||||
|
@ -9261,7 +9335,8 @@ version = "0.0.0"
|
|||
dependencies = [
|
||||
"anyhow",
|
||||
"argh",
|
||||
"kitsune-scss-compiler",
|
||||
"glob",
|
||||
"taplo",
|
||||
"tracing",
|
||||
"tracing-subscriber",
|
||||
]
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
[profile.dev.package]
|
||||
backtrace = { opt-level = 3 }
|
||||
num-bigint-dig = { opt-level = 3 }
|
||||
taplo = { debug-assertions = false } # A debug assertion will make the xtask panic with too long trailing comments
|
||||
|
||||
# The profile that 'cargo dist' will build with
|
||||
[profile.dist]
|
||||
|
@ -101,13 +102,13 @@ cargo-dist-version = "0.12.0"
|
|||
# CI backends to support
|
||||
ci = ["github"]
|
||||
# The installers to generate for each app
|
||||
installers = ["shell", "powershell"]
|
||||
installers = ["powershell", "shell"]
|
||||
# Target platforms to build apps for (Rust target-triple syntax)
|
||||
targets = [
|
||||
"aarch64-apple-darwin",
|
||||
"x86_64-apple-darwin",
|
||||
"x86_64-unknown-linux-musl",
|
||||
"x86_64-pc-windows-msvc",
|
||||
"x86_64-unknown-linux-musl",
|
||||
]
|
||||
# Publish jobs to run in CI
|
||||
pr-run-mode = "plan"
|
||||
|
|
|
@ -1,8 +1,8 @@
|
|||
doc-valid-idents = [
|
||||
"ActivityPub",
|
||||
"gRPC",
|
||||
"OAuth",
|
||||
"OAuth2",
|
||||
"PostgreSQL",
|
||||
"PubSub",
|
||||
"gRPC",
|
||||
]
|
||||
|
|
|
@ -31,7 +31,7 @@ testcontainers-modules = { version = "0.3.5", features = [
|
|||
] }
|
||||
tokio = { version = "1.36.0", features = ["time"] }
|
||||
url = "2.5.0"
|
||||
uuid = { version = "1.8.0", features = ["v4", "fast-rng"] }
|
||||
uuid = { version = "1.8.0", features = ["fast-rng", "v4"] }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
@ -26,8 +26,8 @@ axum = { version = "0.7.4", features = ["macros", "multipart"] }
|
|||
axum-extra = { version = "0.9.2", features = [
|
||||
"cookie",
|
||||
"cookie-signed",
|
||||
"typed-header",
|
||||
"query",
|
||||
"typed-header",
|
||||
] }
|
||||
axum-flash = "0.8.0"
|
||||
blowocking = { path = "../lib/blowocking" }
|
||||
|
@ -151,7 +151,7 @@ graphql-api = [
|
|||
"speedy-uuid/async-graphql",
|
||||
]
|
||||
mastodon-api = ["dep:kitsune-mastodon"]
|
||||
meilisearch = ["kitsune-service/meilisearch", "kitsune-search/meilisearch"]
|
||||
meilisearch = ["kitsune-search/meilisearch", "kitsune-service/meilisearch"]
|
||||
oidc = ["dep:kitsune-oidc"]
|
||||
|
||||
[lints]
|
||||
|
|
|
@ -24,8 +24,8 @@ wat = "1.201.0"
|
|||
|
||||
[features]
|
||||
decode = [
|
||||
"dep:miette",
|
||||
"dep:leb128",
|
||||
"dep:miette",
|
||||
"dep:serde_json",
|
||||
"dep:thiserror",
|
||||
"dep:wasmparser",
|
||||
|
|
|
@ -8,7 +8,8 @@ publish = false
|
|||
[dependencies]
|
||||
anyhow = "1.0.81"
|
||||
argh = "0.1.12"
|
||||
kitsune-scss-compiler = { path = "../crates/kitsune-scss-compiler" }
|
||||
glob = "0.3.1"
|
||||
taplo = { version = "0.13.0", default-features = false }
|
||||
tracing = { version = "0.1.40", default-features = false }
|
||||
tracing-subscriber = { version = "0.3.18", default-features = false, features = [
|
||||
"ansi",
|
||||
|
|
|
@ -1,9 +0,0 @@
|
|||
use std::path::PathBuf;
|
||||
|
||||
#[inline]
|
||||
pub fn build_scss(path: PathBuf) -> anyhow::Result<()> {
|
||||
info!("Building backend SCSS..");
|
||||
kitsune_scss_compiler::compile(path)?;
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -0,0 +1,22 @@
|
|||
use glob::glob;
|
||||
use std::fs;
|
||||
|
||||
fn formatter_settings() -> taplo::formatter::Options {
|
||||
taplo::formatter::Options {
|
||||
indent_string: " ".repeat(4),
|
||||
reorder_arrays: true,
|
||||
..Default::default()
|
||||
}
|
||||
}
|
||||
|
||||
pub fn fmt() -> anyhow::Result<()> {
|
||||
let mut path_iter = glob("**/*.toml")?;
|
||||
while let Some(toml_path) = path_iter.next().transpose()? {
|
||||
info!(path = %toml_path.display(), "formatting TOML file");
|
||||
let toml_data = fs::read_to_string(&toml_path)?;
|
||||
let formatted = taplo::formatter::format(&toml_data, formatter_settings());
|
||||
fs::write(&toml_path, formatted)?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
|
@ -2,27 +2,22 @@
|
|||
extern crate tracing;
|
||||
|
||||
use argh::FromArgs;
|
||||
use std::path::PathBuf;
|
||||
|
||||
mod build_scss;
|
||||
mod clean;
|
||||
mod fmt_toml;
|
||||
mod util;
|
||||
mod watch;
|
||||
|
||||
#[derive(FromArgs)]
|
||||
#[argh(subcommand, name = "build-scss")]
|
||||
/// Build a directory of SCSS files
|
||||
struct BuildScss {
|
||||
#[argh(option)]
|
||||
/// path to the directory
|
||||
path: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
#[argh(subcommand, name = "clean")]
|
||||
/// Clean all target directories
|
||||
struct Clean {}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
#[argh(subcommand, name = "fmt-toml")]
|
||||
/// Format TOML across the workspace
|
||||
struct FmtToml {}
|
||||
|
||||
#[derive(FromArgs)]
|
||||
#[argh(subcommand, name = "watch")]
|
||||
/// Watch for source changes and automatically check the code and run the server
|
||||
|
@ -39,8 +34,8 @@ struct Watch {
|
|||
#[derive(FromArgs)]
|
||||
#[argh(subcommand)]
|
||||
enum Subcommand {
|
||||
BuildScss(BuildScss),
|
||||
Clean(Clean),
|
||||
FmtToml(FmtToml),
|
||||
Watch(Watch),
|
||||
}
|
||||
|
||||
|
@ -56,8 +51,8 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
let command: Command = argh::from_env();
|
||||
match command.subcommand {
|
||||
Subcommand::BuildScss(BuildScss { path }) => build_scss::build_scss(path)?,
|
||||
Subcommand::Clean(..) => clean::clean()?,
|
||||
Subcommand::FmtToml(..) => fmt_toml::fmt()?,
|
||||
Subcommand::Watch(Watch { config, bin }) => watch::watch(&config, &bin)?,
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue