Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Validate builder configs in CI #294

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@ -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
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(())
}
Loading