From 16fc9a856c7c553e49ef8bb6c66fd3db7be7ac0a Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Wed, 4 Oct 2023 18:21:21 +0200 Subject: [PATCH 01/22] Update publish.rs --- cli/src/commands/publish.rs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/cli/src/commands/publish.rs b/cli/src/commands/publish.rs index 4af29891..d210388e 100644 --- a/cli/src/commands/publish.rs +++ b/cli/src/commands/publish.rs @@ -25,6 +25,8 @@ pub struct PublishCommand { name: Option, #[arg(short = 'e', long = "extension_name")] extension_name: Option, + #[arg(short = 'x', long = "extension_dependencies")] + extension_dependencies: Option>, #[arg(short = 's', long = "preload_libraries")] preload_libraries: Option>, #[arg(long = "version", short = 'v')] @@ -63,6 +65,7 @@ pub struct Category { pub struct PublishSettings { name: String, extension_name: Option, + extension_dependencies: Option>, preload_libraries: Option>, version: String, file: Option, @@ -104,6 +107,12 @@ impl PublishCommand { &trunk_toml, ); + let extension_dependencies = cli_or_trunk_opt( + &self.extension_dependencies, + |toml| &toml.extension.extension_dependencies, + &trunk_toml, + ); + let preload_libraries = cli_or_trunk_opt( &self.preload_libraries, |toml| &toml.extension.preload_libraries, @@ -185,6 +194,7 @@ impl PublishCommand { repository, name, extension_name, + extension_dependencies, system_dependencies, categories, preload_libraries, @@ -347,6 +357,7 @@ impl SubCommand for PublishCommand { let m = json!({ "name": publish_settings.name, "extension_name": publish_settings.extension_name, + "extension_dependencies": publish_settings.extension_dependencies, "vers": publish_settings.version, "description": publish_settings.description, "documentation": publish_settings.documentation, From 48b3d5b010a620bd3b736e463b86f9da8b6c3ee9 Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Wed, 4 Oct 2023 20:56:26 +0200 Subject: [PATCH 02/22] Update build.rs --- cli/src/commands/build.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/cli/src/commands/build.rs b/cli/src/commands/build.rs index 40ba2d24..2f363408 100644 --- a/cli/src/commands/build.rs +++ b/cli/src/commands/build.rs @@ -26,6 +26,8 @@ pub struct BuildCommand { name: Option, #[arg(short = 'e', long = "extension_name")] extension_name: Option, + #[arg(short = 'x', long = "extension_dependencies")] + extension_dependencies: Option>, #[arg(short = 's', long = "preload-libraries")] preload_libraries: Option>, #[arg(short = 'P', long = "platform")] @@ -42,6 +44,7 @@ pub struct BuildSettings { pub version: Option, pub name: Option, pub extension_name: Option, + pub extension_dependencies: Option>, pub preload_libraries: Option>, pub system_dependencies: Option, pub glob_patterns_to_include: Vec, @@ -88,6 +91,12 @@ impl BuildCommand { &trunk_toml, ); + let extension_dependencies = cli_or_trunk_opt( + &self.extension_dependencies, + |toml| &toml.extension.extension_dependencies, + &trunk_toml, + ); + let preload_libraries = cli_or_trunk_opt( &self.preload_libraries, |toml| &toml.extension.preload_libraries, @@ -143,6 +152,7 @@ impl BuildCommand { version, name, extension_name, + extension_dependencies, preload_libraries, system_dependencies, glob_patterns_to_include, @@ -216,6 +226,7 @@ impl SubCommand for BuildCommand { path, &build_settings.output_path, build_settings.extension_name, + build_settings.extension_dependencies, build_settings.preload_libraries, cargo_toml, build_settings.system_dependencies, @@ -261,6 +272,7 @@ impl SubCommand for BuildCommand { &build_settings.output_path, build_settings.name.clone().unwrap().as_str(), build_settings.extension_name, + build_settings.extension_dependencies, build_settings.preload_libraries, build_settings.system_dependencies, build_settings.version.clone().unwrap().as_str(), From 78ea99aa4d6295d93729be4d1b6ef6ba715337c3 Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Wed, 4 Oct 2023 21:10:29 +0200 Subject: [PATCH 03/22] Update pgrx.rs --- cli/src/commands/pgrx.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/src/commands/pgrx.rs b/cli/src/commands/pgrx.rs index 0e751a58..dfce0b7d 100644 --- a/cli/src/commands/pgrx.rs +++ b/cli/src/commands/pgrx.rs @@ -102,6 +102,7 @@ pub async fn build_pgrx( path: &Path, output_path: &str, extension_name: Option, + extension_dependencies: Option>, preload_libraries: Option>, cargo_toml: toml::Table, system_dependencies: Option, @@ -233,6 +234,7 @@ pub async fn build_pgrx( name, extension_name, extension_version, + extension_dependencies, inclusion_patterns, ) .await?; From 4d0e0c80eeb804cbf3de6d208dd7c1eb3b38a6a1 Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Wed, 4 Oct 2023 22:02:51 +0200 Subject: [PATCH 04/22] Update generic_build.rs --- cli/src/commands/generic_build.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/src/commands/generic_build.rs b/cli/src/commands/generic_build.rs index 370d4f21..336f48b0 100644 --- a/cli/src/commands/generic_build.rs +++ b/cli/src/commands/generic_build.rs @@ -69,6 +69,7 @@ pub async fn build_generic( output_path: &str, name: &str, extension_name: Option, + extension_dependencies: Option>, preload_libraries: Option>, system_dependencies: Option, extension_version: &str, @@ -142,6 +143,7 @@ pub async fn build_generic( name, extension_name, extension_version, + extension_dependencies, inclusion_patterns, ) .await?; From 8e3bbaf9e104401b1d82e65ef3f11edb61286980 Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Wed, 4 Oct 2023 22:07:29 +0200 Subject: [PATCH 05/22] Update containers.rs --- cli/src/commands/containers.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cli/src/commands/containers.rs b/cli/src/commands/containers.rs index 3b7c2088..2d9c62ad 100644 --- a/cli/src/commands/containers.rs +++ b/cli/src/commands/containers.rs @@ -397,6 +397,7 @@ pub async fn package_installed_extension_files( name: &str, mut extension_name: Option, extension_version: &str, + extension_dependencies: Option>, inclusion_patterns: Vec, ) -> Result<(), anyhow::Error> { let name = name.to_owned(); @@ -485,6 +486,7 @@ pub async fn package_installed_extension_files( name, extension_name, extension_version, + extension_dependencies, manifest_version: 2, preload_libraries, architecture: target_arch, From 845d2dbb2f2cc914bacc8a0ad7fc6af06f8583c5 Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Wed, 4 Oct 2023 22:09:25 +0200 Subject: [PATCH 06/22] Update trunk_toml.rs --- cli/src/trunk_toml.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/src/trunk_toml.rs b/cli/src/trunk_toml.rs index c3901489..745f1fe3 100644 --- a/cli/src/trunk_toml.rs +++ b/cli/src/trunk_toml.rs @@ -19,6 +19,7 @@ pub struct TomlExtensionData { pub name: String, pub file: Option, pub extension_name: Option, + pub extension_dependencies: Option>, pub version: String, pub license: String, pub repository: Option, From 81b31d165ca8e0023d22d6f506cbff1f6049d43c Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Wed, 4 Oct 2023 22:12:41 +0200 Subject: [PATCH 07/22] Update manifest.rs --- cli/src/manifest.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/cli/src/manifest.rs b/cli/src/manifest.rs index 6b9e72d4..c726cf4d 100644 --- a/cli/src/manifest.rs +++ b/cli/src/manifest.rs @@ -49,6 +49,7 @@ pub struct Manifest { /// 'apt': ['libgroonga-dev'], /// } /// ``` + pub extension_dependencies: Option>, pub dependencies: Option>>, #[serde(rename = "version")] pub extension_version: String, From 2d49cba4b14bda22befacf4e398b2695a628748f Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Thu, 5 Oct 2023 13:42:14 +0200 Subject: [PATCH 08/22] Update install.rs --- cli/src/commands/install.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cli/src/commands/install.rs b/cli/src/commands/install.rs index 5b7d7287..d3871eb8 100644 --- a/cli/src/commands/install.rs +++ b/cli/src/commands/install.rs @@ -414,6 +414,13 @@ fn print_post_installation_guide(manifest: &Manifest) { } } } + // If the manifest has extension_dependencies, then we need to install and enable the + // appropriate extension + if let Some(extension_dependencies) = &manifest.extension_dependencies { + let extension_dependencies = extension_dependencies.join(","); + println!("\nInstall and enable the following extensions:"); + println!("\textension_dependencies = '{}'", extension_dependencies) + } // If the manifest has preload_libraries, then we need to add the extension to preload_libraries // Output will look like preload_libraries = 'spl1,spl2,spl3' if let Some(preload_libraries) = &manifest.preload_libraries { From e153ee2af6cd311e32e6efe57ecf7570455c175e Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Mon, 9 Oct 2023 13:19:57 +0200 Subject: [PATCH 09/22] Update integration tests --- cli/src/commands/install.rs | 16 ++++++++ cli/tests/integration_tests.rs | 40 +++++++++++++++++++ .../test_trunk_toml_dirs/pg_cron/Trunk.toml | 3 +- 3 files changed, 58 insertions(+), 1 deletion(-) diff --git a/cli/src/commands/install.rs b/cli/src/commands/install.rs index d3871eb8..b52eac2d 100644 --- a/cli/src/commands/install.rs +++ b/cli/src/commands/install.rs @@ -11,6 +11,7 @@ use reqwest::Url; use std::ffi::OsStr; use std::fs::File; use std::io::{Read, Seek, Write}; +use std::ops::Not; use std::path::{Path, PathBuf}; use tar::{Archive, EntryType}; use tokio_task_manager::Task; @@ -254,6 +255,7 @@ async fn install_file( extensions_to_install.push(ext); let deps = parsed_control_file.dependencies(); + // For each dependency, check if it's not in depenedent_extensions_to_install and not in extensions_to_install. // If not, add to depenedent_extensions_to_install. // We don't want to install dependencies that are already present in the tar.gz @@ -270,6 +272,20 @@ async fn install_file( } } + let maybe_manifest_deps = manifest + .as_ref() + .map(|manifest| manifest.extension_dependencies.as_ref()) + .flatten(); + if let Some(manifest_deps) = maybe_manifest_deps { + for dep in manifest_deps { + // If the extension is not in dependent_extensions_to_install, + // it wasn't specified in the control file + if dependent_extensions_to_install.contains(&dep).not() { + dependent_extensions_to_install.push(dep.to_string()); + } + } + } + println!("Dependent extensions to be installed: {dependent_extensions_to_install:?}"); for dependency in dependent_extensions_to_install { // check a control file is present in sharedir for each dependency diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 9b950f20..c184f0c5 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -827,6 +827,46 @@ fn build_auto_explain() -> Result<(), Box> { Ok(()) } +#[test] +fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box> { + let mut rng = rand::thread_rng(); + let output_dir = format!("/tmp/btree_gin_test_{}", rng.gen_range(0..1000000)); + + let extension_path = "todo"; + + // Run trunk build + let mut cmd = Command::cargo_bin(CARGO_BIN)?; + cmd.arg("build"); + cmd.arg("--path"); + cmd.arg(extension_path); + cmd.arg("--output-path"); + cmd.arg(&output_dir); + + // Assert that the dependencies were written to manifest + let manifest = Command::new("cat") + .arg(format!("{output_dir}/manifest.json").as_str()) + .output() + .expect("failed to run cat command"); + + let stdout = String::from_utf8(manifest.stdout).unwrap(); + assert!(stdout.contains("\"extension_dependencies\": \"btree_gin\"")); + + // assert post installation steps contain correct shared_preload_libraries command + let mut cmd = Command::cargo_bin(CARGO_BIN)?; + cmd.arg("install"); + cmd.arg("--file"); + cmd.arg(format!("{output_dir}/btree_gin.tar.gz").as_str()); + cmd.arg("btree_gin"); + let output = cmd.output()?; + let stdout = String::from_utf8(output.stdout)?; + cmd.assert().code(0); + + // Assert `` was installed + assert!(stdout.contains("Installing extension btree_gin")); + + Ok(()) +} + #[test] fn build_pg_unit() -> Result<(), Box> { let mut rng = rand::thread_rng(); diff --git a/cli/tests/test_trunk_toml_dirs/pg_cron/Trunk.toml b/cli/tests/test_trunk_toml_dirs/pg_cron/Trunk.toml index 973c2070..dc7c4bd8 100644 --- a/cli/tests/test_trunk_toml_dirs/pg_cron/Trunk.toml +++ b/cli/tests/test_trunk_toml_dirs/pg_cron/Trunk.toml @@ -1,6 +1,7 @@ [extension] name = "pg_cron" extension_name = "extension_name_from_toml" +extension_dependencies = ["btree_gin"] preload_libraries = ["shared_preload_libraries_from_toml"] version = "1.5.2" repository = "https://github.com/tembo-io/trunk" @@ -14,4 +15,4 @@ platform = "linux/amd64" [dependencies] apt = ["libpq5"] -dnf = ["libpq-devel"] \ No newline at end of file +dnf = ["libpq-devel"] From 156a186cfbdf4852157b46972bf086dfde9a6758 Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Mon, 9 Oct 2023 23:46:41 +0200 Subject: [PATCH 10/22] Add btree_gin dockerfile and update intregration_tests.rs --- cli/tests/integration_tests.rs | 9 ++++++- cli/tests/test_builders/Dockerfile.btree_gin | 28 ++++++++++++++++++++ 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 cli/tests/test_builders/Dockerfile.btree_gin diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index c184f0c5..7c43f516 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -832,7 +832,14 @@ fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box Date: Mon, 9 Oct 2023 23:57:54 +0200 Subject: [PATCH 11/22] Update integration_tests.rs --- cli/tests/integration_tests.rs | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 7c43f516..2fc82fb0 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -841,13 +841,26 @@ fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box Date: Wed, 11 Oct 2023 20:30:26 +0200 Subject: [PATCH 12/22] Update --- cli/tests/integration_tests.rs | 23 +++++++++++++++-------- contrib/pg_cron/Trunk.toml | 1 + 2 files changed, 16 insertions(+), 8 deletions(-) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 2fc82fb0..7be60d66 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -565,6 +565,7 @@ fn build_pg_cron_trunk_toml() -> Result<(), Box> { let output = cmd.output()?; let stdout = String::from_utf8(output.stdout)?; cmd.assert().code(0); + println!("PRINTING STD OUT: {}", stdout); assert!(stdout.contains("CREATE EXTENSION IF NOT EXISTS extension_name_from_toml CASCADE;")); assert!(stdout.contains("Install the following system-level dependencies:")); assert!(stdout.contains("On systems using apt:")); @@ -572,6 +573,15 @@ fn build_pg_cron_trunk_toml() -> Result<(), Box> { assert!(stdout.contains("On systems using dnf:")); assert!(stdout.contains("libpq-devel")); + // assert that the dependencies were written to manifest + let manifest = Command::new("cat") + .arg(format!("{output_dir}/manifest.json").as_str()) + .output() + .expect("failed to run cat command"); + + let stdout = String::from_utf8(manifest.stdout).unwrap(); + assert!(stdout.contains("\"extension_dependencies\": \"btree_gin\"")); + // delete the temporary file std::fs::remove_dir_all(output_dir)?; @@ -830,15 +840,15 @@ fn build_auto_explain() -> Result<(), Box> { #[test] fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box> { let mut rng = rand::thread_rng(); - let output_dir = format!("/tmp/btree_gin_test_{}", rng.gen_range(0..1000000)); + let output_dir = format!("/tmp/pg_cron_test_{}", rng.gen_range(0..1000000)); let mut extension_path = std::path::PathBuf::from(file!()); extension_path.pop(); // Remove the file name from the path - extension_path.push("postgres_btree_gin"); + extension_path.push("pg_cron"); let mut dockerfile_path = std::path::PathBuf::from(file!()); dockerfile_path.pop(); // Remove the file name from the path - dockerfile_path.push("test_builders"); + dockerfile_path.push("test_trunk_toml_dirs/pg_cron"); dockerfile_path.push("Dockerfile.btree_gin"); let mut cmd = Command::cargo_bin(CARGO_BIN)?; @@ -875,15 +885,12 @@ fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box` was installed - assert!(stdout.contains("Installing extension btree_gin")); - Ok(()) } diff --git a/contrib/pg_cron/Trunk.toml b/contrib/pg_cron/Trunk.toml index 2a60b7ad..0da69338 100644 --- a/contrib/pg_cron/Trunk.toml +++ b/contrib/pg_cron/Trunk.toml @@ -7,6 +7,7 @@ description = "Job scheduler for PostgreSQL." homepage = "https://www.citusdata.com/" categories = ["orchestration"] preload_libraries = ["pg_cron"] +extension_dependencies = ["btree_gin"] [dependencies] apt = ["libpq5", "libc6"] From 2cdaea970d774689bafb2087efebaa9924ebfe22 Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Thu, 19 Oct 2023 23:56:30 +0200 Subject: [PATCH 13/22] comment-out function --- cli/tests/integration_tests.rs | 114 ++++++++++++++++----------------- 1 file changed, 57 insertions(+), 57 deletions(-) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 7be60d66..cd064fc0 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -718,7 +718,7 @@ fn build_pgrx_with_trunk_toml_bad_version() -> Result<(), Box Result<(), Box> { Ok(()) } -#[test] -fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box> { - let mut rng = rand::thread_rng(); - let output_dir = format!("/tmp/pg_cron_test_{}", rng.gen_range(0..1000000)); - - let mut extension_path = std::path::PathBuf::from(file!()); - extension_path.pop(); // Remove the file name from the path - extension_path.push("pg_cron"); - - let mut dockerfile_path = std::path::PathBuf::from(file!()); - dockerfile_path.pop(); // Remove the file name from the path - dockerfile_path.push("test_trunk_toml_dirs/pg_cron"); - dockerfile_path.push("Dockerfile.btree_gin"); - - let mut cmd = Command::cargo_bin(CARGO_BIN)?; - cmd.arg("build"); - cmd.arg("--path"); - cmd.arg(extension_path.as_os_str()); - cmd.arg("--output-path"); - cmd.arg(output_dir.clone()); - cmd.arg("--dockerfile"); - cmd.arg(dockerfile_path.clone()); - cmd.arg("--install-command"); - cmd.arg("cd contrib/btree_gin && make install && set -x && mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension && mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib"); - cmd.arg("--version"); - cmd.arg("15.3.0"); - cmd.arg("--name"); - cmd.arg("btree_gin"); - // cmd.arg("--preload-libraries"); - // cmd.arg("auto_explain_spl"); - cmd.assert().code(0); - assert!( - std::path::Path::new(format!("{output_dir}/btree_gin-15.3.0.tar.gz").as_str()).exists() - ); - - // Assert that the dependencies were written to manifest - let manifest = Command::new("cat") - .arg(format!("{output_dir}/manifest.json").as_str()) - .output() - .expect("failed to run cat command"); - - let stdout = String::from_utf8(manifest.stdout).unwrap(); - assert!(stdout.contains("\"extension_dependencies\": \"btree_gin\"")); - - // assert post installation steps contain correct shared_preload_libraries command - let mut cmd = Command::cargo_bin(CARGO_BIN)?; - cmd.arg("install"); - cmd.arg("--file"); - cmd.arg(format!("{output_dir}/pg_cron.tar.gz").as_str()); - cmd.arg("pg_cron"); - let output = cmd.output()?; - let stdout = String::from_utf8(output.stdout)?; - cmd.assert().code(0); - - Ok(()) -} +//#[test] +//fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box> { +// let mut rng = rand::thread_rng(); +// let output_dir = format!("/tmp/pg_cron_test_{}", rng.gen_range(0..1000000)); +// +// let mut extension_path = std::path::PathBuf::from(file!()); +// extension_path.pop(); // Remove the file name from the path +// extension_path.push("pg_cron"); +// +// let mut dockerfile_path = std::path::PathBuf::from(file!()); +// dockerfile_path.pop(); // Remove the file name from the path +// dockerfile_path.push("test_trunk_toml_dirs/pg_cron"); +// dockerfile_path.push("Dockerfile.btree_gin"); +// +// let mut cmd = Command::cargo_bin(CARGO_BIN)?; +// cmd.arg("build"); +// cmd.arg("--path"); +// cmd.arg(extension_path.as_os_str()); +// cmd.arg("--output-path"); +// cmd.arg(output_dir.clone()); +// cmd.arg("--dockerfile"); +// cmd.arg(dockerfile_path.clone()); +// cmd.arg("--install-command"); +// cmd.arg("cd contrib/btree_gin && make install && set -x && mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension && mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib"); +// cmd.arg("--version"); +// cmd.arg("15.3.0"); +// cmd.arg("--name"); +// cmd.arg("btree_gin"); +// // cmd.arg("--preload-libraries"); +// // cmd.arg("auto_explain_spl"); +// cmd.assert().code(0); +// assert!( +// std::path::Path::new(format!("{output_dir}/btree_gin-15.3.0.tar.gz").as_str()).exists() +// ); +// +// // Assert that the dependencies were written to manifest +// let manifest = Command::new("cat") +// .arg(format!("{output_dir}/manifest.json").as_str()) +// .output() +// .expect("failed to run cat command"); +// +// let stdout = String::from_utf8(manifest.stdout).unwrap(); +// assert!(stdout.contains("\"extension_dependencies\": \"btree_gin\"")); +// +// // assert post installation steps contain correct shared_preload_libraries command +// let mut cmd = Command::cargo_bin(CARGO_BIN)?; +// cmd.arg("install"); +// cmd.arg("--file"); +// cmd.arg(format!("{output_dir}/pg_cron.tar.gz").as_str()); +// cmd.arg("pg_cron"); +// let output = cmd.output()?; +// let stdout = String::from_utf8(output.stdout)?; +// cmd.assert().code(0); +// +// Ok(()) +//} #[test] fn build_pg_unit() -> Result<(), Box> { From 5f834992b5a83935a0c8910f07457fbd2f8482cf Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 09:21:13 -0400 Subject: [PATCH 14/22] Cleanup test file --- cli/tests/integration_tests.rs | 59 +--------------------------------- 1 file changed, 1 insertion(+), 58 deletions(-) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index cd064fc0..f052490d 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -718,7 +718,7 @@ fn build_pgrx_with_trunk_toml_bad_version() -> Result<(), Box Result<(), Box> { Ok(()) } -//#[test] -//fn assert_respects_trunk_toml_extension_depencies() -> Result<(), Box> { -// let mut rng = rand::thread_rng(); -// let output_dir = format!("/tmp/pg_cron_test_{}", rng.gen_range(0..1000000)); -// -// let mut extension_path = std::path::PathBuf::from(file!()); -// extension_path.pop(); // Remove the file name from the path -// extension_path.push("pg_cron"); -// -// let mut dockerfile_path = std::path::PathBuf::from(file!()); -// dockerfile_path.pop(); // Remove the file name from the path -// dockerfile_path.push("test_trunk_toml_dirs/pg_cron"); -// dockerfile_path.push("Dockerfile.btree_gin"); -// -// let mut cmd = Command::cargo_bin(CARGO_BIN)?; -// cmd.arg("build"); -// cmd.arg("--path"); -// cmd.arg(extension_path.as_os_str()); -// cmd.arg("--output-path"); -// cmd.arg(output_dir.clone()); -// cmd.arg("--dockerfile"); -// cmd.arg(dockerfile_path.clone()); -// cmd.arg("--install-command"); -// cmd.arg("cd contrib/btree_gin && make install && set -x && mv /usr/local/pgsql/share/extension/* /usr/share/postgresql/15/extension && mv /usr/local/pgsql/lib/* /usr/lib/postgresql/15/lib"); -// cmd.arg("--version"); -// cmd.arg("15.3.0"); -// cmd.arg("--name"); -// cmd.arg("btree_gin"); -// // cmd.arg("--preload-libraries"); -// // cmd.arg("auto_explain_spl"); -// cmd.assert().code(0); -// assert!( -// std::path::Path::new(format!("{output_dir}/btree_gin-15.3.0.tar.gz").as_str()).exists() -// ); -// -// // Assert that the dependencies were written to manifest -// let manifest = Command::new("cat") -// .arg(format!("{output_dir}/manifest.json").as_str()) -// .output() -// .expect("failed to run cat command"); -// -// let stdout = String::from_utf8(manifest.stdout).unwrap(); -// assert!(stdout.contains("\"extension_dependencies\": \"btree_gin\"")); -// -// // assert post installation steps contain correct shared_preload_libraries command -// let mut cmd = Command::cargo_bin(CARGO_BIN)?; -// cmd.arg("install"); -// cmd.arg("--file"); -// cmd.arg(format!("{output_dir}/pg_cron.tar.gz").as_str()); -// cmd.arg("pg_cron"); -// let output = cmd.output()?; -// let stdout = String::from_utf8(output.stdout)?; -// cmd.assert().code(0); -// -// Ok(()) -//} - #[test] fn build_pg_unit() -> Result<(), Box> { let mut rng = rand::thread_rng(); From 0a899ba6d5e537ded2cfc7382208749420b7863d Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 09:34:49 -0400 Subject: [PATCH 15/22] Revert change to pg_cron in contrib --- contrib/pg_cron/Trunk.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/contrib/pg_cron/Trunk.toml b/contrib/pg_cron/Trunk.toml index 0da69338..2a60b7ad 100644 --- a/contrib/pg_cron/Trunk.toml +++ b/contrib/pg_cron/Trunk.toml @@ -7,7 +7,6 @@ description = "Job scheduler for PostgreSQL." homepage = "https://www.citusdata.com/" categories = ["orchestration"] preload_libraries = ["pg_cron"] -extension_dependencies = ["btree_gin"] [dependencies] apt = ["libpq5", "libc6"] From b3042b50609bf5c43158472db6087d6fb25f6521 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 09:41:31 -0400 Subject: [PATCH 16/22] Fix gitignore skip in CLI workflow --- .github/workflows/cli.yml | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/.github/workflows/cli.yml b/.github/workflows/cli.yml index c3731554..bd4786de 100644 --- a/.github/workflows/cli.yml +++ b/.github/workflows/cli.yml @@ -13,8 +13,7 @@ on: - ".github/workflows/cli.yml" - "cli/**" - "!cli/README.md" - paths-ignore: - - "cli/.gitignore" + - "!cli/.gitignore" push: branches: - main @@ -22,8 +21,7 @@ on: - ".github/workflows/cli.yml" - "cli/**" - "!cli/README.md" - paths-ignore: - - "cli/.gitignore" + - "!cli/.gitignore" jobs: lint: From e496ef3b4801072f8ae204be04d6f0837e200483 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 09:45:54 -0400 Subject: [PATCH 17/22] Bump crate --- cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 8cbc3a08..4b85994c 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pg-trunk" -version = "0.11.3" +version = "0.11.4" edition = "2021" authors = ["Steven Miller", "Ian Stanton", "Vinícius Miguel"] description = "A package manager for PostgreSQL extensions" From 1052625893209a74d05939b7ab83d959cb0e1a39 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 13:00:47 -0400 Subject: [PATCH 18/22] Bump crate --- cli/Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/Cargo.toml b/cli/Cargo.toml index 4b85994c..a3723192 100644 --- a/cli/Cargo.toml +++ b/cli/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "pg-trunk" -version = "0.11.4" +version = "0.11.5" edition = "2021" authors = ["Steven Miller", "Ian Stanton", "Vinícius Miguel"] description = "A package manager for PostgreSQL extensions" From ebbdcb9303e557c98ee74c6612e9b4307ceea95a Mon Sep 17 00:00:00 2001 From: Evan Stanton Date: Fri, 20 Oct 2023 21:25:31 +0200 Subject: [PATCH 19/22] Update ln583 assertion --- cli/tests/integration_tests.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index 858ca1ce..c179ab86 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -580,7 +580,7 @@ fn build_pg_cron_trunk_toml() -> Result<(), Box> { .expect("failed to run cat command"); let stdout = String::from_utf8(manifest.stdout).unwrap(); - assert!(stdout.contains("\"extension_dependencies\": \"btree_gin\"")); + assert!(stdout.contains("\"extension_dependencies\": [\"btree_gin\"]")); // delete the temporary file std::fs::remove_dir_all(output_dir)?; From 19e7b53f409c82830e2c3d6d987a95069ca76764 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 16:39:19 -0400 Subject: [PATCH 20/22] Fix assertion --- cli/tests/integration_tests.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/cli/tests/integration_tests.rs b/cli/tests/integration_tests.rs index c179ab86..f5dc6cfe 100644 --- a/cli/tests/integration_tests.rs +++ b/cli/tests/integration_tests.rs @@ -565,7 +565,6 @@ fn build_pg_cron_trunk_toml() -> Result<(), Box> { let output = cmd.output()?; let stdout = String::from_utf8(output.stdout)?; cmd.assert().code(0); - println!("PRINTING STD OUT: {}", stdout); assert!(stdout.contains("CREATE EXTENSION IF NOT EXISTS extension_name_from_toml CASCADE;")); assert!(stdout.contains("Install the following system-level dependencies:")); assert!(stdout.contains("On systems using apt:")); @@ -580,7 +579,7 @@ fn build_pg_cron_trunk_toml() -> Result<(), Box> { .expect("failed to run cat command"); let stdout = String::from_utf8(manifest.stdout).unwrap(); - assert!(stdout.contains("\"extension_dependencies\": [\"btree_gin\"]")); + assert!(stdout.contains("\"extension_dependencies\": [\n \"btree_gin\"\n ],")); // delete the temporary file std::fs::remove_dir_all(output_dir)?; From 337706a070f48d2087edf83154a1c5cc9a9e6aa8 Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 17:09:03 -0400 Subject: [PATCH 21/22] Add TODO --- cli/src/commands/containers.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cli/src/commands/containers.rs b/cli/src/commands/containers.rs index 8cde559e..e03a5c8c 100644 --- a/cli/src/commands/containers.rs +++ b/cli/src/commands/containers.rs @@ -443,6 +443,9 @@ pub async fn package_installed_extension_files( let options_usrdir = Some(DownloadFromContainerOptions { path: "/usr" }); let file_stream = docker.download_from_container(container_id, options_usrdir); + // TODO: If extension_dependencies is none, check for control file and fetch 'requires' field (similar to below) + // example: https://github.com/paradedb/paradedb/blob/9a0b1601a9c7026e5c89eef51a422b9d284b3058/pg_search/pg_search.control#L6C1-L6C9 + if let Some(control) = sharedir_list.iter().find(|path| path.contains(".control")) { // If extension_name parameter is none, check for control file and fetch extension_name if extension_name.is_none() { From 38bfbf28a36af3a40149acd1a91217e20886276c Mon Sep 17 00:00:00 2001 From: Ian Stanton Date: Fri, 20 Oct 2023 17:14:34 -0400 Subject: [PATCH 22/22] Remove unused Dockerfile.btree_gin --- cli/tests/test_builders/Dockerfile.btree_gin | 28 -------------------- 1 file changed, 28 deletions(-) delete mode 100644 cli/tests/test_builders/Dockerfile.btree_gin diff --git a/cli/tests/test_builders/Dockerfile.btree_gin b/cli/tests/test_builders/Dockerfile.btree_gin deleted file mode 100644 index cd70055e..00000000 --- a/cli/tests/test_builders/Dockerfile.btree_gin +++ /dev/null @@ -1,28 +0,0 @@ -ARG PG_VERSION=15 -FROM quay.io/coredb/c-builder:pg${PG_VERSION} -USER root - -# Extension build dependencies -RUN apt-get update && apt-get install -y \ - build-essential \ - libreadline-dev \ - zlib1g-dev \ - flex bison \ - libxml2-dev \ - libxslt-dev \ - libssl-dev \ - libxml2-utils \ - xsltproc \ - ccache - -# Clone repository -RUN git clone https://github.com/postgres/postgres.git - -ARG PG_RELEASE=REL_15_3 - -RUN cd postgres && \ - git fetch origin ${PG_RELEASE} && \ - git checkout ${PG_RELEASE} && \ - ./configure && \ - cd contrib/btree_gin && \ - make