diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4a7c4e6..67fe9bc 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,8 +1,9 @@ name: CI on: push: + # Ignore non top-level branches. branches-ignore: - - dependabot/** + - '*/**' pull_request: defaults: run: diff --git a/CHANGES.md b/CHANGES.md index 5dc9672..ec380fa 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,10 @@ # Release Notes +## 0.10.8 + +Redirect pants install messages to a `pants-install.log` file in pants venv directory to not pollute +stdout/stderr. + ## 0.10.7 This release upgrades `pex` to `v2.1.163` and the bootstrap Python to `3.9.18`. diff --git a/Cargo.lock b/Cargo.lock index 8ac58d9..0202f50 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -573,7 +573,7 @@ dependencies = [ [[package]] name = "scie-pants" -version = "0.10.7" +version = "0.10.8" dependencies = [ "anyhow", "dirs", diff --git a/Cargo.toml b/Cargo.toml index f0ddbae..2af549a 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -6,7 +6,7 @@ members = [ [package] name = "scie-pants" description = "Protects your Pants from the elements." -version = "0.10.7" +version = "0.10.8" edition = "2021" authors = [ "John Sirois ", diff --git a/README.md b/README.md index 3b6f27c..6ac526b 100644 --- a/README.md +++ b/README.md @@ -125,6 +125,15 @@ That will update to the latest available stable release if there is a newer one there is not. You can also supply a `scie-pants` version as the sole argument to downgrade or switch to a specific version. +### Check pants installation logs + +When the Python virtual environment (venv) for Pants is created, any logged output during that +process is saved in a `pants-install.log` file in the venv root. The path to the venv root is logged +during bootstrapping on a line with this pattern: + + New virtual environment successfully created at /.../nce//bindings/venvs/ + + ### Report an issue You can report an issue directly at https://github.com/pantsbuild/scie-pants/issues. Please include diff --git a/package/src/test.rs b/package/src/test.rs index 08c4f51..5a2d9d7 100644 --- a/package/src/test.rs +++ b/package/src/test.rs @@ -29,8 +29,17 @@ macro_rules! integration_test { }; } -fn issue_link(issue: usize) -> String { - format!("https://github.com/pantsbuild/scie-pants/issues/{issue}") +macro_rules! issue_link { + ($issue: expr) => { + issue_link($issue, "pantsbuild/scie-pants") + }; + ($issue: expr, $repo: expr) => { + issue_link($issue, $repo) + }; +} + +fn issue_link(issue: usize, repo: &str) -> String { + format!("https://github.com/{repo}/issues/{issue}") } fn decode_output(output: Vec) -> Result { @@ -99,6 +108,7 @@ pub(crate) fn run_integration_tests( test_tools(scie_pants_scie, check); test_pants_bin_name_handling(scie_pants_scie); test_pants_bootstrap_handling(scie_pants_scie); + test_pants_bootstrap_stdout_silent(scie_pants_scie); test_tools_pex_reproducibility(workspace_root, tools_pex_path, tools_pex_mismatch_warn); test_pants_bootstrap_tools(scie_pants_scie); @@ -238,7 +248,7 @@ fn test_pants_bin_name_handling(scie_pants_scie: &Path) { false, r#" [GLOBAL] - pants_version = "2.15.0rc5" + pants_version = "2.18.0" [anonymous-telemetry] enabled = false "#, @@ -408,7 +418,7 @@ fn test_ignore_empty_pants_version_pants_sha(scie_pants_scie: &Path) { let tmpdir = create_tempdir().unwrap(); - let pants_release = "2.15.0"; + let pants_release = "2.18.0"; let pants_toml_content = format!( r#" [GLOBAL] @@ -437,7 +447,7 @@ fn test_pants_from_pex_version(scie_pants_scie: &Path) { let tmpdir = create_tempdir().unwrap(); - let pants_release = "2.18.0.dev5"; + let pants_release = "2.18.0"; let pants_toml_content = format!( r#" [GLOBAL] @@ -816,7 +826,7 @@ fn test_self_downgrade(scie_pants_scie: &Path) { fn test_caching_issue_129(scie_pants_scie: &Path) { integration_test!( "Verifying the build root does not influence caching ({issue})", - issue = issue_link(129) + issue = issue_link!(129) ); let tmpdir = create_tempdir().unwrap(); @@ -824,7 +834,7 @@ fn test_caching_issue_129(scie_pants_scie: &Path) { let pants_toml = r#" [GLOBAL] - pants_version = "2.15.0" + pants_version = "2.18.0" [anonymous-telemetry] enabled = false "#; @@ -894,7 +904,7 @@ fn test_caching_issue_129(scie_pants_scie: &Path) { fn test_custom_pants_toml_issue_153(scie_pants_scie: &Path) { integration_test!( "Verifying the PANTS_TOML env var is respected ({issue})", - issue = issue_link(153) + issue = issue_link!(153) ); let tmpdir = create_tempdir().unwrap(); @@ -978,7 +988,7 @@ fn test_pants_native_client_perms_issue_182(scie_pants_scie: &Path) { integration_test!( "Verifying scie-pants sets executable perms on the Pants native client binary when \ present ({issue})", - issue = issue_link(182) + issue = issue_link!(182) ); let tmpdir = create_tempdir().unwrap(); @@ -1009,7 +1019,7 @@ fn test_pants_native_client_perms_issue_182(scie_pants_scie: &Path) { fn test_non_utf8_env_vars_issue_198(scie_pants_scie: &Path) { integration_test!( "Verifying scie-pants is robust to environments with non-utf8 env vars present ({issue})", - issue = issue_link(198) + issue = issue_link!(198) ); let tmpdir = create_tempdir().unwrap(); @@ -1112,7 +1122,7 @@ fn test_bad_boot_error_text(scie_pants_scie: &Path) { fn test_pants_bootstrap_urls(scie_pants_scie: &Path) { integration_test!( "Verifying PANTS_BOOTSTRAP_URLS is used for both CPython interpreter and Pants PEX ({issue})", - issue = issue_link(243) + issue = issue_link!(243) ); // This test runs in 4 parts: @@ -1224,3 +1234,30 @@ fn test_pants_bootstrap_urls(scie_pants_scie: &Path) { let stdout = decode_output(output.stdout).unwrap(); assert!(stdout.contains(pants_release)); } + +fn test_pants_bootstrap_stdout_silent(scie_pants_scie: &Path) { + integration_test!( + "Verifying scie-pants bootstraps Pants without any output on stdout ({issue})", + issue = issue_link!(20315, "pantsbuild/pants") + ); + // Bootstrap a new unseen version of Pants to verify there is no extra output on stdout besides + // the requested output from the pants command. + let (output, _stderr) = assert_stderr_output( + Command::new(scie_pants_scie) + .arg("-V") + .env("PANTS_VERSION", "2.19.1") + .stdout(Stdio::piped()), + // Expect bootstrap messages to ensure we actually bootstrapped pants during this execution. + vec![ + "Bootstrapping Pants 2.19.1", + "Installing pantsbuild.pants==2.19.1 into a virtual environment at ", + "New virtual environment successfully created at ", + ], + ExpectedResult::Success, + ); + let stdout = decode_output(output.stdout).unwrap(); + assert!( + stdout.eq("2.19.1\n"), + "STDOUT was not '2.19.1':\n{stdout}\n" + ); +} diff --git a/tools/src/scie_pants/install_pants.py b/tools/src/scie_pants/install_pants.py index 4846b11..c240800 100644 --- a/tools/src/scie_pants/install_pants.py +++ b/tools/src/scie_pants/install_pants.py @@ -120,23 +120,37 @@ def install_pants_from_pex( " or file an issue on GitHub: https://github.com/pantsbuild/pants/issues/new/choose.\n\n" f"Exception:\n\n{e}" ) - subprocess.run( - args=[ - sys.executable, - pants_pex.name, - "venv", - "--prompt", - prompt, - "--compile", - "--pip", - "--collisions-ok", - "--no-emit-warnings", # Silence `PEXWarning: You asked for --pip ...` - "--disable-cache", - str(venv_dir), - ], - env={"PEX_TOOLS": "1"}, - check=True, - ) + try: + pants_venv_result = subprocess.run( + args=[ + sys.executable, + pants_pex.name, + "venv", + "--prompt", + prompt, + "--compile", + "--pip", + "--collisions-ok", + "--no-emit-warnings", # Silence `PEXWarning: You asked for --pip ...` + "--disable-cache", + str(venv_dir), + ], + env={"PEX_TOOLS": "1"}, + check=True, + stdout=subprocess.PIPE, + stderr=subprocess.STDOUT, + ) + except subprocess.CalledProcessError as e: + fatal( + f"Failed to create Pants virtual environment.\nError: {e}, output:" + f"\n-----\n{e.stdout}\n-----\n" + ) + else: + with open(str(venv_dir / "pants-install.log"), "a") as fp: + print(f"Installed {pex_name}", file=fp) + if pants_venv_result.stdout: + print(pants_venv_result.stdout.decode(), file=fp) + print("\n-----", file=fp) if extra_requirements: venv_pip_install(