diff --git a/.github/workflows/checks.yaml b/.github/workflows/checks.yaml index 56bfc341..539bca0c 100644 --- a/.github/workflows/checks.yaml +++ b/.github/workflows/checks.yaml @@ -63,6 +63,9 @@ jobs: - name: Test run: make test + - name: Validate config files + run: make validate-config + integration: name: Integration tests runs-on: warp-ubuntu-latest-x64-16x diff --git a/Makefile b/Makefile index db52f033..b019ae53 100644 --- a/Makefile +++ b/Makefile @@ -79,3 +79,8 @@ bench-prettify: ## Prettifies the latest Criterion report ./scripts/ci/criterion-prettify-report.sh target/criterion target/benchmark-html-dev @echo "\nopen target/benchmark-html-dev/report/index.html" +.PHONY: validate-config +validate-config: ## Validate the correctness of the configuration files + @for CONFIG in $(shell ls config-*.toml); do \ + cargo run --bin validate-config -- --config $$CONFIG; \ + done diff --git a/crates/rbuilder/src/bin/validate-config.rs b/crates/rbuilder/src/bin/validate-config.rs new file mode 100644 index 00000000..328d121a --- /dev/null +++ b/crates/rbuilder/src/bin/validate-config.rs @@ -0,0 +1,23 @@ +//! CLI tool to validate a rbuilder config file + +use clap::Parser; +use rbuilder::live_builder::{base_config::load_config_toml_and_env, config::Config}; +use std::path::PathBuf; + +#[derive(Parser, Debug)] +struct Cli { + #[clap(long, help = "Config file path", env = "RBUILDER_CONFIG")] + config: PathBuf, +} + +#[tokio::main] +async fn main() -> eyre::Result<()> { + let cli = Cli::parse(); + + let config_path = &cli.config; + let _: Config = load_config_toml_and_env(config_path)?; + + println!("Config file '{}' is valid", config_path.display()); + + Ok(()) +}