Skip to content
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
5 changes: 0 additions & 5 deletions .github/workflows/test-python.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ name: "[tower] Test python"

on:
pull_request:
push:
branches:
- '*'
tags-ignore:
- '**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
5 changes: 0 additions & 5 deletions .github/workflows/test-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ name: "[tower] Test rust"

on:
pull_request:
push:
branches:
- '*'
tags-ignore:
- '**'

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
Expand Down
14 changes: 6 additions & 8 deletions crates/config/src/towerfile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use serde::{Deserialize, Serialize};
use std::path::PathBuf;

#[derive(Deserialize, Serialize, Debug)]
pub struct Parameter{
pub struct Parameter {
#[serde(default)]
pub name: String,

Expand Down Expand Up @@ -116,7 +116,6 @@ impl Towerfile {
Ok(())
}


/// add_parameter adds a new parameter to the Towerfile
pub fn add_parameter(&mut self, name: String, description: String, default: String) {
self.parameters.push(Parameter {
Expand Down Expand Up @@ -277,20 +276,19 @@ mod test {
fn test_add_parameter() {
let mut towerfile = crate::Towerfile::default();
assert_eq!(towerfile.parameters.len(), 0);

towerfile.add_parameter(
"test-param".to_string(),
"A test parameter".to_string(),
"default-value".to_string()
"default-value".to_string(),
);

assert_eq!(towerfile.parameters.len(), 1);
assert_eq!(towerfile.parameters[0].name, "test-param");
assert_eq!(towerfile.parameters[0].description, "A test parameter");
assert_eq!(towerfile.parameters[0].default, "default-value");
}


#[test]
fn test_roundtrip_serialization() {
let original_toml = r#"[app]
Expand All @@ -310,11 +308,11 @@ name = "param2"
description = "Second parameter"
default = "value2"
"#;

let towerfile = crate::Towerfile::from_toml(original_toml).unwrap();
let serialized = toml::to_string_pretty(&towerfile).unwrap();
let reparsed = crate::Towerfile::from_toml(&serialized).unwrap();

assert_eq!(towerfile.app.name, reparsed.app.name);
assert_eq!(towerfile.app.script, reparsed.app.script);
assert_eq!(towerfile.app.source, reparsed.app.source);
Expand Down
1 change: 0 additions & 1 deletion crates/tower-cmd/src/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -729,7 +729,6 @@ impl ResponseEntity for tower_api::apis::default_api::ListEnvironmentsSuccess {
}
}


pub async fn list_environments(
config: &Config,
) -> Result<
Expand Down
4 changes: 1 addition & 3 deletions crates/tower-cmd/src/environments.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,7 @@ pub async fn do_list(config: Config) {
let envs_data: Vec<Vec<String>> = resp
.environments
.into_iter()
.map(|env| {
vec![env.name]
})
.map(|env| vec![env.name])
.collect();

// Display the table using the existing table function
Expand Down
14 changes: 8 additions & 6 deletions crates/tower-cmd/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@ mod apps;
mod deploy;
mod environments;
pub mod error;
mod package;
mod mcp;
pub mod output;
mod package;
mod run;
mod schedules;
mod secrets;
Expand All @@ -16,7 +17,6 @@ mod teams;
mod towerfile_gen;
mod util;
mod version;
mod mcp;

pub use error::Error;

Expand Down Expand Up @@ -165,10 +165,12 @@ impl App {
}
}
}
Some(("mcp-server", args)) => mcp::do_mcp_server(sessionized_config, args).await.unwrap_or_else(|e| {
eprintln!("MCP server error: {}", e);
std::process::exit(1);
}),
Some(("mcp-server", args)) => mcp::do_mcp_server(sessionized_config, args)
.await
.unwrap_or_else(|e| {
eprintln!("MCP server error: {}", e);
std::process::exit(1);
}),
_ => {
cmd_clone.print_help().unwrap();
std::process::exit(2);
Expand Down
35 changes: 24 additions & 11 deletions crates/tower-cmd/src/package.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,10 @@ pub fn package_cmd() -> Command {

pub async fn do_package(_config: Config, args: &ArgMatches) {
// Determine the directory to build the package from
let dir = PathBuf::from(args.get_one::<String>("dir").expect("dir argument should have default value"));
let dir = PathBuf::from(
args.get_one::<String>("dir")
.expect("dir argument should have default value"),
);
debug!("Building package from directory: {:?}", dir);

let path = dir.join("Towerfile");
Expand All @@ -43,14 +46,19 @@ pub async fn do_package(_config: Config, args: &ArgMatches) {
match Package::build(spec).await {
Ok(package) => {
spinner.success();

// Get the output path
let output_path = args.get_one::<String>("output").expect("output path is required");

let output_path = args
.get_one::<String>("output")
.expect("output path is required");

// Save the package
match save_package(&package, output_path).await {
Ok(_) => {
output::success(&format!("Package created successfully: {}", output_path));
output::success(&format!(
"Package created successfully: {}",
output_path
));
}
Err(err) => {
output::error(&format!("Failed to save package: {}", err));
Expand All @@ -69,19 +77,24 @@ pub async fn do_package(_config: Config, args: &ArgMatches) {
}
}

async fn save_package(package: &Package, output_path: &str) -> Result<(), Box<dyn std::error::Error>> {
let package_path = package.package_file_path.as_ref()
async fn save_package(
package: &Package,
output_path: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let package_path = package
.package_file_path
.as_ref()
.ok_or("No package file path found")?;

let output_path = PathBuf::from(output_path);

// Create parent directories if they don't exist
if let Some(parent) = output_path.parent() {
fs::create_dir_all(parent).await?;
}

// Copy the package file to the specified location
fs::copy(package_path, &output_path).await?;

Ok(())
}
20 changes: 8 additions & 12 deletions crates/tower-cmd/src/towerfile_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,12 +180,10 @@ name = "custom-script-project"
let result =
TowerfileGenerator::from_pyproject(Some("/nonexistent/path/pyproject.toml"), None);
assert!(result.is_err());
assert!(
result
.unwrap_err()
.to_string()
.contains("pyproject.toml not found")
);
assert!(result
.unwrap_err()
.to_string()
.contains("pyproject.toml not found"));
}

#[test]
Expand All @@ -205,12 +203,10 @@ requires = ["setuptools"]
let result =
TowerfileGenerator::from_pyproject(Some(pyproject_path.to_str().unwrap()), None);
assert!(result.is_err());
assert!(
result
.unwrap_err()
.to_string()
.contains("No [project] section found")
);
assert!(result
.unwrap_err()
.to_string()
.contains("No [project] section found"));
}

#[test]
Expand Down
5 changes: 4 additions & 1 deletion crates/tower-runtime/tests/local_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,10 @@ async fn test_running_hello_world() {
}

let found_hello = outputs.iter().any(|line| line.contains("Hello, world!"));
assert!(found_hello, "Should have received 'Hello, world!' output from the application");
assert!(
found_hello,
"Should have received 'Hello, world!' output from the application"
);

// check the status once more, should be done.
let status = app.status().await.expect("Failed to get app status");
Expand Down
Loading