mirror of
https://github.com/katanemo/plano.git
synced 2026-07-02 15:51:02 +02:00
add validate command, remove Python dependency from CI
This commit is contained in:
parent
eb30c65796
commit
6efb152cec
4 changed files with 49 additions and 13 deletions
11
.github/workflows/ci.yml
vendored
11
.github/workflows/ci.yml
vendored
|
|
@ -133,13 +133,12 @@ jobs:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v6
|
uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up Python
|
- name: Install Rust
|
||||||
uses: actions/setup-python@v6
|
uses: dtolnay/rust-toolchain@stable
|
||||||
with:
|
|
||||||
python-version: "3.14"
|
|
||||||
|
|
||||||
- name: Install planoai
|
- name: Build planoai CLI
|
||||||
run: pip install -e ./cli
|
working-directory: ./crates
|
||||||
|
run: cargo build --release -p plano-cli
|
||||||
|
|
||||||
- name: Validate plano config
|
- name: Validate plano config
|
||||||
run: bash config/validate_plano_config.sh
|
run: bash config/validate_plano_config.sh
|
||||||
|
|
|
||||||
|
|
@ -8,13 +8,7 @@ for file in $(find . -name config.yaml -o -name plano_config_full_reference.yaml
|
||||||
rendered_file="$(pwd)/${file}_rendered"
|
rendered_file="$(pwd)/${file}_rendered"
|
||||||
touch "$rendered_file"
|
touch "$rendered_file"
|
||||||
|
|
||||||
PLANO_CONFIG_FILE="$(pwd)/${file}" \
|
planoai validate "$(pwd)/${file}" 2>&1 > /dev/null
|
||||||
PLANO_CONFIG_SCHEMA_FILE="${SCRIPT_DIR}/plano_config_schema.yaml" \
|
|
||||||
TEMPLATE_ROOT="${SCRIPT_DIR}" \
|
|
||||||
ENVOY_CONFIG_TEMPLATE_FILE="envoy.template.yaml" \
|
|
||||||
PLANO_CONFIG_FILE_RENDERED="$rendered_file" \
|
|
||||||
ENVOY_CONFIG_FILE_RENDERED="/dev/null" \
|
|
||||||
python -m planoai.config_generator 2>&1 > /dev/null
|
|
||||||
|
|
||||||
if [ $? -ne 0 ]; then
|
if [ $? -ne 0 ]; then
|
||||||
echo "Validation failed for $file"
|
echo "Validation failed for $file"
|
||||||
|
|
|
||||||
|
|
@ -5,6 +5,7 @@ pub mod init;
|
||||||
pub mod logs;
|
pub mod logs;
|
||||||
pub mod self_update;
|
pub mod self_update;
|
||||||
pub mod up;
|
pub mod up;
|
||||||
|
pub mod validate;
|
||||||
|
|
||||||
use clap::{Parser, Subcommand};
|
use clap::{Parser, Subcommand};
|
||||||
|
|
||||||
|
|
@ -134,6 +135,16 @@ pub enum Command {
|
||||||
list_templates: bool,
|
list_templates: bool,
|
||||||
},
|
},
|
||||||
|
|
||||||
|
/// Validate a Plano configuration file
|
||||||
|
Validate {
|
||||||
|
/// Config file path
|
||||||
|
file: Option<String>,
|
||||||
|
|
||||||
|
/// Path to the directory containing config.yaml
|
||||||
|
#[arg(long, default_value = ".")]
|
||||||
|
path: String,
|
||||||
|
},
|
||||||
|
|
||||||
/// Update planoai to the latest version
|
/// Update planoai to the latest version
|
||||||
#[command(name = "self-update")]
|
#[command(name = "self-update")]
|
||||||
SelfUpdate {
|
SelfUpdate {
|
||||||
|
|
@ -261,6 +272,7 @@ pub async fn run(cli: Cli) -> anyhow::Result<()> {
|
||||||
force,
|
force,
|
||||||
list_templates,
|
list_templates,
|
||||||
}) => init::run(template, clean, output, force, list_templates).await,
|
}) => init::run(template, clean, output, force, list_templates).await,
|
||||||
|
Some(Command::Validate { file, path }) => validate::run(file, &path).await,
|
||||||
Some(Command::SelfUpdate { version }) => self_update::run(version.as_deref()).await,
|
Some(Command::SelfUpdate { version }) => self_update::run(version.as_deref()).await,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
31
crates/plano-cli/src/commands/validate.rs
Normal file
31
crates/plano-cli/src/commands/validate.rs
Normal file
|
|
@ -0,0 +1,31 @@
|
||||||
|
use anyhow::Result;
|
||||||
|
|
||||||
|
use crate::native::runner::validate_config;
|
||||||
|
use crate::utils::find_config_file;
|
||||||
|
|
||||||
|
pub async fn run(file: Option<String>, path: &str) -> Result<()> {
|
||||||
|
let green = console::Style::new().green();
|
||||||
|
let red = console::Style::new().red();
|
||||||
|
|
||||||
|
let config_path = find_config_file(path, file.as_deref());
|
||||||
|
if !config_path.exists() {
|
||||||
|
eprintln!(
|
||||||
|
"{} Config file not found: {}",
|
||||||
|
red.apply_to("✗"),
|
||||||
|
config_path.display()
|
||||||
|
);
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
match validate_config(&config_path) {
|
||||||
|
Ok(()) => {
|
||||||
|
eprintln!("{} Configuration valid", green.apply_to("✓"));
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
Err(e) => {
|
||||||
|
eprintln!("{} Validation failed", red.apply_to("✗"));
|
||||||
|
eprintln!(" {e:#}");
|
||||||
|
std::process::exit(1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue