Skip to content

Commit

Permalink
Validate builder configs in CI (#294)
Browse files Browse the repository at this point in the history
## 📝 Summary

Add a CLI tool to validate the builder config and run it in CI to
validate all configs found in the root of the repo.

## 💡 Motivation and Context

Fix #278

---

## ✅ I have completed the following steps:

* [x] Run `make lint`
* [x] Run `make test`
* [ ] Added tests (if applicable)
  • Loading branch information
0xmichalis authored Dec 18, 2024
1 parent 2e4c1ab commit 8989fca
Show file tree
Hide file tree
Showing 3 changed files with 31 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/checks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
5 changes: 5 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -78,3 +78,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
23 changes: 23 additions & 0 deletions crates/rbuilder/src/bin/validate-config.rs
Original file line number Diff line number Diff line change
@@ -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(())
}

0 comments on commit 8989fca

Please sign in to comment.