From 49592e5533c6214761c60add3de04245eb02794b Mon Sep 17 00:00:00 2001 From: nichmor Date: Wed, 8 Jan 2025 12:40:11 +0200 Subject: [PATCH 01/20] feat: move cli params separatly --- crates/pixi_git/src/lib.rs | 16 ++ crates/pixi_git/src/url.rs | 4 + .../pixi_manifest/src/manifests/manifest.rs | 64 ++++--- crates/pixi_spec/src/git.rs | 56 +++++- crates/pixi_spec/src/lib.rs | 22 ++- src/cli/add.rs | 36 +++- src/cli/cli_config.rs | 65 +++++++ src/cli/init.rs | 11 +- src/cli/upgrade.rs | 2 + src/project/mod.rs | 45 ++++- tests/integration_rust/add_tests.rs | 167 +++++++++++++++++- tests/integration_rust/common/builders.rs | 25 ++- ...ation_rust__add_tests__add_git_deps-2.snap | 12 ++ ...gration_rust__add_tests__add_git_deps.snap | 31 ++++ ..._add_tests__add_git_deps_with_creds-2.snap | 12 ++ ...t__add_tests__add_git_deps_with_creds.snap | 31 ++++ ...tests__add_git_with_specific_commit-2.snap | 12 ++ ...d_tests__add_git_with_specific_commit.snap | 31 ++++ ...n_rust__add_tests__add_git_with_tag-2.snap | 12 ++ ...ion_rust__add_tests__add_git_with_tag.snap | 31 ++++ ...ration_rust__add_tests__add_plain_git.snap | 12 ++ ...on_rust__add_tests__add_plain_ssh_url.snap | 12 ++ 22 files changed, 658 insertions(+), 51 deletions(-) create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_git.snap create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap diff --git a/crates/pixi_git/src/lib.rs b/crates/pixi_git/src/lib.rs index 612cbbef2..b5dd20475 100644 --- a/crates/pixi_git/src/lib.rs +++ b/crates/pixi_git/src/lib.rs @@ -73,6 +73,22 @@ impl GitUrl { pub fn precise(&self) -> Option { self.precise } + + /// Determines if the given URL looks like a Git URL. + pub fn is_git_url(url: &Url) -> bool { + // Check if the scheme indicates it's a Git URL. + if url.scheme().starts_with("git+") { + // Check if the path ends with .git or has a Git-specific format. + return true; + } else if let Some(path) = url.path_segments() { + if path.clone().any(|segment| segment.ends_with(".git")) { + return true; + } + }; + + // If the URL doesn't match Git-specific patterns, return false. + false + } } impl TryFrom for GitUrl { diff --git a/crates/pixi_git/src/url.rs b/crates/pixi_git/src/url.rs index b0aa3dd11..1cf0d109c 100644 --- a/crates/pixi_git/src/url.rs +++ b/crates/pixi_git/src/url.rs @@ -126,6 +126,10 @@ impl RepositoryUrl { pub fn parse(url: &str) -> Result { Ok(Self::new(&Url::parse(url)?)) } + + pub fn looks_like_git_url(url: &str) -> bool { + url.starts_with("git+") || url.ends_with(".git") + } } /// Remove the credentials from a URL, allowing the generic `git` username (without a password) diff --git a/crates/pixi_manifest/src/manifests/manifest.rs b/crates/pixi_manifest/src/manifests/manifest.rs index c6a31ced9..5938fa8f0 100644 --- a/crates/pixi_manifest/src/manifests/manifest.rs +++ b/crates/pixi_manifest/src/manifests/manifest.rs @@ -12,7 +12,7 @@ use indexmap::{Equivalent, IndexSet}; use itertools::Itertools; use miette::{miette, IntoDiagnostic, NamedSource, Report, WrapErr}; use pixi_spec::PixiSpec; -use rattler_conda_types::{ChannelConfig, MatchSpec, PackageName, Platform, Version}; +use rattler_conda_types::{PackageName, Platform, Version}; use toml_edit::{DocumentMut, Value}; use crate::toml::FromTomlStr; @@ -372,34 +372,26 @@ impl Manifest { Ok(()) } - /// Add a matchspec to the manifest + /// Add a pixi spec to the manifest pub fn add_dependency( &mut self, - spec: &MatchSpec, + name: &PackageName, + spec: &PixiSpec, spec_type: SpecType, platforms: &[Platform], feature_name: &FeatureName, overwrite_behavior: DependencyOverwriteBehavior, - channel_config: &ChannelConfig, ) -> miette::Result { - // Determine the name of the package to add - let (Some(name), spec) = spec.clone().into_nameless() else { - miette::bail!( - "{} does not support wildcard dependencies", - pixi_utils::executable_name() - ); - }; - let spec = PixiSpec::from_nameless_matchspec(spec, channel_config); let mut any_added = false; for platform in to_options(platforms) { // Add the dependency to the manifest match self .get_or_insert_target_mut(platform, Some(feature_name)) - .try_add_dependency(&name, &spec, spec_type, overwrite_behavior) + .try_add_dependency(name, spec, spec_type, overwrite_behavior) { Ok(true) => { self.source - .add_dependency(&name, &spec, spec_type, platform, feature_name)?; + .add_dependency(name, spec, spec_type, platform, feature_name)?; any_added = true; } Ok(false) => {} @@ -814,8 +806,8 @@ mod tests { use insta::assert_snapshot; use miette::NarratableReportHandler; use rattler_conda_types::{ - NamedChannelOrUrl, ParseStrictness, - ParseStrictness::{Lenient, Strict}, + MatchSpec, NamedChannelOrUrl, + ParseStrictness::{self, Lenient, Strict}, VersionSpec, }; use rstest::*; @@ -2063,14 +2055,22 @@ bar = "*" "#; let channel_config = default_channel_config(); let mut manifest = Manifest::from_str(Path::new("pixi.toml"), file_contents).unwrap(); + // Determine the name of the package to add + let spec = &MatchSpec::from_str("baz >=1.2.3", Strict).unwrap(); + + let (name, spec) = spec.clone().into_nameless(); + let name = name.unwrap(); + + let spec = PixiSpec::from_nameless_matchspec(spec, &channel_config); + manifest .add_dependency( - &MatchSpec::from_str("baz >=1.2.3", Strict).unwrap(), + &name, + &spec, SpecType::Run, &[], &FeatureName::Default, DependencyOverwriteBehavior::Overwrite, - &channel_config, ) .unwrap(); assert_eq!( @@ -2086,14 +2086,20 @@ bar = "*" .as_version_spec(), Some(&VersionSpec::from_str(">=1.2.3", Strict).unwrap()) ); + + let (name, spec) = MatchSpec::from_str("qux >=1.2.3", Strict) + .unwrap() + .into_nameless(); + let pixi_spec = PixiSpec::from_nameless_matchspec(spec, &channel_config); + manifest .add_dependency( - &MatchSpec::from_str(" bal >=2.3", Strict).unwrap(), + &name.unwrap(), + &pixi_spec, SpecType::Run, &[], &FeatureName::Named("test".to_string()), DependencyOverwriteBehavior::Overwrite, - &channel_config, ) .unwrap(); @@ -2114,14 +2120,19 @@ bar = "*" ">=2.3".to_string() ); + let (package_name, nameless) = MatchSpec::from_str(" boef >=2.3", Strict) + .unwrap() + .into_nameless(); + let pixi_spec = PixiSpec::from_nameless_matchspec(nameless, &channel_config); + manifest .add_dependency( - &MatchSpec::from_str(" boef >=2.3", Strict).unwrap(), + &package_name.unwrap(), + &pixi_spec, SpecType::Run, &[Platform::Linux64], &FeatureName::Named("extra".to_string()), DependencyOverwriteBehavior::Overwrite, - &channel_config, ) .unwrap(); @@ -2143,14 +2154,19 @@ bar = "*" ">=2.3".to_string() ); + let matchspec = MatchSpec::from_str(" cmake >=2.3", ParseStrictness::Strict).unwrap(); + let (package_name, nameless) = matchspec.into_nameless(); + + let pixi_spec = PixiSpec::from_nameless_matchspec(nameless, &channel_config); + manifest .add_dependency( - &MatchSpec::from_str(" cmake >=2.3", ParseStrictness::Strict).unwrap(), + &package_name.unwrap(), + &pixi_spec, SpecType::Build, &[Platform::Linux64], &FeatureName::Named("build".to_string()), DependencyOverwriteBehavior::Overwrite, - &channel_config, ) .unwrap(); diff --git a/crates/pixi_spec/src/git.rs b/crates/pixi_spec/src/git.rs index 6aa57c0f8..877b58d87 100644 --- a/crates/pixi_spec/src/git.rs +++ b/crates/pixi_spec/src/git.rs @@ -1,6 +1,7 @@ use std::fmt::Display; use pixi_git::git::GitReference; +use serde::{Serialize, Serializer}; use thiserror::Error; use url::Url; @@ -12,7 +13,7 @@ pub struct GitSpec { pub git: Url, /// The git revision of the package - #[serde(skip_serializing_if = "Option::is_none", flatten)] + #[serde(skip_serializing_if = "Reference::is_default_branch", flatten)] pub rev: Option, /// The git subdirectory of the package @@ -21,9 +22,7 @@ pub struct GitSpec { } /// A reference to a specific commit in a git repository. -#[derive( - Debug, Clone, Hash, Eq, PartialEq, PartialOrd, Ord, ::serde::Serialize, ::serde::Deserialize, -)] +#[derive(Debug, Clone, Hash, Eq, PartialEq, PartialOrd, Ord, ::serde::Deserialize)] #[serde(rename_all = "kebab-case")] pub enum Reference { /// The HEAD commit of a branch. @@ -39,6 +38,16 @@ pub enum Reference { DefaultBranch, } +impl Reference { + /// Returns the reference as a string. + pub fn is_default_branch(reference: &Option) -> bool { + reference.is_none() + || reference + .as_ref() + .is_some_and(|reference| matches!(reference, Reference::DefaultBranch)) + } +} + impl Display for Reference { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { @@ -65,6 +74,45 @@ impl From for Reference { } } +impl Serialize for Reference { + fn serialize(&self, serializer: S) -> Result + where + S: Serializer, + { + #[derive(Serialize)] + struct RawReference<'a> { + tag: Option<&'a str>, + branch: Option<&'a str>, + rev: Option<&'a str>, + } + + let ser = match self { + Reference::Branch(name) => RawReference { + branch: Some(name), + tag: None, + rev: None, + }, + Reference::Tag(name) => RawReference { + branch: None, + tag: Some(name), + rev: None, + }, + Reference::Rev(name) => RawReference { + branch: None, + tag: None, + rev: Some(name), + }, + Reference::DefaultBranch => RawReference { + branch: None, + tag: None, + rev: None, + }, + }; + + ser.serialize(serializer) + } +} + #[derive(Error, Debug)] pub enum GitReferenceError { #[error("The commit string is invalid: \"{0}\"")] diff --git a/crates/pixi_spec/src/lib.rs b/crates/pixi_spec/src/lib.rs index 75f0e0792..4fbb80c02 100644 --- a/crates/pixi_spec/src/lib.rs +++ b/crates/pixi_spec/src/lib.rs @@ -20,6 +20,7 @@ pub use detailed::DetailedSpec; pub use git::{GitSpec, Reference}; use itertools::Either; pub use path::{PathBinarySpec, PathSourceSpec, PathSpec}; +use pixi_git::GitUrl; use rattler_conda_types::{ ChannelConfig, NamedChannelOrUrl, NamelessMatchSpec, ParseChannelError, VersionSpec, }; @@ -102,11 +103,21 @@ impl PixiSpec { channel_config: &ChannelConfig, ) -> Self { if let Some(url) = spec.url { - Self::Url(UrlSpec { - url, - md5: spec.md5, - sha256: spec.sha256, - }) + // check if it is a git url + if GitUrl::is_git_url(&url) { + let git_url = GitUrl::try_from(url.clone()).unwrap(); + Self::Git(GitSpec { + git: git_url.repository().clone(), + rev: Some(git_url.reference().clone().into()), + subdirectory: spec.subdir, + }) + } else { + Self::Url(UrlSpec { + url, + md5: spec.md5, + sha256: spec.sha256, + }) + } } else if spec.build.is_none() && spec.build_number.is_none() && spec.file_name.is_none() @@ -310,6 +321,7 @@ impl PixiSpec { /// Converts this instance into a [`toml_edit::Value`]. pub fn to_toml_value(&self) -> toml_edit::Value { + eprintln!("to_toml_value: {:?}", self); ::serde::Serialize::serialize(self, toml_edit::ser::ValueSerializer::new()) .expect("conversion to toml cannot fail") } diff --git a/src/cli/add.rs b/src/cli/add.rs index ee732a7a1..9fb254bfe 100644 --- a/src/cli/add.rs +++ b/src/cli/add.rs @@ -1,7 +1,9 @@ use clap::Parser; use indexmap::IndexMap; use miette::IntoDiagnostic; -use pixi_manifest::FeatureName; +use pixi_manifest::{FeatureName, SpecType}; +use pixi_spec::{GitSpec, SourceSpec}; +use rattler_conda_types::{MatchSpec, PackageName}; use super::has_specs::HasSpecs; use crate::{ @@ -98,24 +100,45 @@ pub async fn execute(args: Args) -> miette::Result<()> { .manifest .add_platforms(dependency_config.platforms.iter(), &FeatureName::Default)?; - let (match_specs, pypi_deps) = match dependency_config.dependency_type() { + let (match_specs, source_specs, pypi_deps) = match dependency_config.dependency_type() { DependencyType::CondaDependency(spec_type) => { - let match_specs = dependency_config + // now if user passed some git configuration + // we will use it to create pixi specs + let passed_specs: IndexMap = dependency_config .specs()? .into_iter() .map(|(name, spec)| (name, (spec, spec_type))) .collect(); - let pypi_deps = IndexMap::default(); - (match_specs, pypi_deps) + + if let Some(git) = &dependency_config.git { + let source_specs = passed_specs + .iter() + .map(|(name, (_spec, spec_type))| { + let git_reference = + dependency_config.rev.clone().unwrap_or_default().into(); + + let git_spec = GitSpec { + git: git.clone(), + rev: Some(git_reference), + subdirectory: dependency_config.subdir.clone(), + }; + (name.clone(), (SourceSpec::Git(git_spec), *spec_type)) + }) + .collect(); + (IndexMap::default(), source_specs, IndexMap::default()) + } else { + (passed_specs, IndexMap::default(), IndexMap::default()) + } } DependencyType::PypiDependency => { let match_specs = IndexMap::default(); + let source_specs = IndexMap::default(); let pypi_deps = dependency_config .pypi_deps(&project)? .into_iter() .map(|(name, req)| (name, (req, None))) .collect(); - (match_specs, pypi_deps) + (match_specs, source_specs, pypi_deps) } }; // TODO: add dry_run logic to add @@ -129,6 +152,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { .update_dependencies( match_specs, pypi_deps, + source_specs, prefix_update_config, &args.dependency_config.feature, &args.dependency_config.platforms, diff --git a/src/cli/cli_config.rs b/src/cli/cli_config.rs index 398f49c65..c057e3dcf 100644 --- a/src/cli/cli_config.rs +++ b/src/cli/cli_config.rs @@ -11,10 +11,12 @@ use pixi_config::{Config, ConfigCli}; use pixi_consts::consts; use pixi_manifest::FeaturesExt; use pixi_manifest::{FeatureName, SpecType}; +use pixi_spec::Reference; use rattler_conda_types::ChannelConfig; use rattler_conda_types::{Channel, NamedChannelOrUrl, Platform}; use std::collections::HashMap; use std::path::PathBuf; +use url::Url; /// Project configuration #[derive(Parser, Debug, Default, Clone)] @@ -129,6 +131,57 @@ impl PrefixUpdateConfig { } } } + +#[derive(Parser, Debug, Default, Clone)] +pub struct GitRev { + /// The git branch + #[clap(long, requires = "git")] + pub branch: Option, + + /// The git tag + #[clap(long, requires = "git")] + pub tag: Option, + + /// The git revision + #[clap(long, requires = "git")] + pub rev: Option, +} + +impl GitRev { + pub fn new() -> Self { + Default::default() + } + + pub fn with_branch(mut self, branch: String) -> GitRev { + self.branch = Some(branch); + self + } + + pub fn with_rev(mut self, rev: String) -> GitRev { + self.rev = Some(rev); + self + } + + pub fn with_tag(mut self, tag: String) -> GitRev { + self.tag = Some(tag); + self + } +} + +impl From for Reference { + fn from(git_rev: GitRev) -> Self { + if let Some(branch) = git_rev.branch { + Reference::Branch(branch) + } else if let Some(tag) = git_rev.tag { + Reference::Tag(tag) + } else if let Some(rev) = git_rev.rev { + Reference::Rev(rev) + } else { + Reference::DefaultBranch + } + } +} + #[derive(Parser, Debug, Default)] pub struct DependencyConfig { /// The dependencies as names, conda MatchSpecs or PyPi requirements @@ -157,6 +210,18 @@ pub struct DependencyConfig { /// The feature for which the dependency should be modified #[clap(long, short, default_value_t)] pub feature: FeatureName, + + /// The git url to use when adding a git dependency + #[clap(long, short, conflicts_with_all = ["pypi"])] + pub git: Option, + + #[clap(flatten)] + /// The git revisions to use when adding a git dependency + pub rev: Option, + + /// The subdirectory of the git repository to use + #[clap(long, short, requires = "git")] + pub subdir: Option, } impl DependencyConfig { diff --git a/src/cli/init.rs b/src/cli/init.rs index 900bafb93..6dc580969 100644 --- a/src/cli/init.rs +++ b/src/cli/init.rs @@ -14,6 +14,7 @@ use pixi_consts::consts; use pixi_manifest::{ pyproject::PyProjectManifest, DependencyOverwriteBehavior, FeatureName, SpecType, }; +use pixi_spec::PixiSpec; use pixi_utils::conda_environment_file::CondaEnvFile; use rattler_conda_types::{NamedChannelOrUrl, Platform}; use tokio::fs::OpenOptions; @@ -241,14 +242,22 @@ pub async fn execute(args: Args) -> miette::Result<()> { let mut project = Project::from_str(&pixi_manifest_path, &rv)?; let channel_config = project.channel_config(); for spec in conda_deps { + // Determine the name of the package to add + let (Some(name), spec) = spec.clone().into_nameless() else { + miette::bail!( + "{} does not support wildcard dependencies", + pixi_utils::executable_name() + ); + }; + let spec = PixiSpec::from_nameless_matchspec(spec, &channel_config); project.manifest.add_dependency( + &name, &spec, SpecType::Run, // No platforms required as you can't define them in the yaml &[], &FeatureName::default(), DependencyOverwriteBehavior::Overwrite, - &channel_config, )?; } for requirement in pypi_deps { diff --git a/src/cli/upgrade.rs b/src/cli/upgrade.rs index 5e7f17afb..c2eef1053 100644 --- a/src/cli/upgrade.rs +++ b/src/cli/upgrade.rs @@ -5,6 +5,7 @@ use crate::project::{MatchSpecs, PypiDeps}; use crate::Project; use clap::Parser; use fancy_display::FancyDisplay; +use indexmap::IndexMap; use itertools::Itertools; use miette::MietteDiagnostic; use miette::{Context, IntoDiagnostic}; @@ -76,6 +77,7 @@ pub async fn execute(args: Args) -> miette::Result<()> { .update_dependencies( match_specs, pypi_deps, + IndexMap::default(), &args.prefix_update_config, &args.specs.feature, &[], diff --git a/src/project/mod.rs b/src/project/mod.rs index 773932ccb..8c24a7d96 100644 --- a/src/project/mod.rs +++ b/src/project/mod.rs @@ -35,9 +35,12 @@ use pixi_manifest::{ FeaturesExt, HasFeaturesIter, HasManifestRef, KnownPreviewFeature, Manifest, PypiDependencyLocation, SpecType, WorkspaceManifest, }; +use pixi_spec::{PixiSpec, SourceSpec}; use pixi_utils::reqwest::build_reqwest_clients; use pypi_mapping::{ChannelName, CustomMapping, MappingLocation, MappingSource}; -use rattler_conda_types::{Channel, ChannelConfig, MatchSpec, PackageName, Platform, Version}; +use rattler_conda_types::{ + Channel, ChannelConfig, MatchSpec, NamelessMatchSpec, PackageName, Platform, Version, +}; use rattler_lock::{LockFile, LockedPackageRef}; use rattler_repodata_gateway::Gateway; use reqwest_middleware::ClientWithMiddleware; @@ -161,6 +164,8 @@ pub type PypiDeps = indexmap::IndexMap< pub type MatchSpecs = indexmap::IndexMap; +pub type SourceSpecs = indexmap::IndexMap; + impl Project { /// Constructs a new instance from an internal manifest representation pub(crate) fn from_manifest(manifest: Manifest) -> Self { @@ -687,6 +692,7 @@ impl Project { &mut self, match_specs: MatchSpecs, pypi_deps: PypiDeps, + source_specs: SourceSpecs, prefix_update_config: &PrefixUpdateConfig, feature_name: &FeatureName, platforms: &[Platform], @@ -699,22 +705,40 @@ impl Project { let mut pypi_packages = HashSet::new(); let channel_config = self.channel_config(); for (name, (spec, spec_type)) in match_specs { + let (_, nameless_spec) = spec.into_nameless(); + let pixi_spec = + PixiSpec::from_nameless_matchspec(nameless_spec.clone(), &channel_config); + let added = self.manifest.add_dependency( - &spec, + &name, + &pixi_spec, spec_type, platforms, feature_name, DependencyOverwriteBehavior::Overwrite, - &channel_config, )?; if added { - if spec.version.is_none() { - conda_specs_to_add_constraints_for.insert(name.clone(), (spec_type, spec)); + if nameless_spec.version.is_none() { + conda_specs_to_add_constraints_for + .insert(name.clone(), (spec_type, nameless_spec)); } conda_packages.insert(name); } } + for (name, (spec, spec_type)) in source_specs { + let pixi_spec = PixiSpec::from(spec); + + self.manifest.add_dependency( + &name, + &pixi_spec, + spec_type, + platforms, + feature_name, + DependencyOverwriteBehavior::Overwrite, + )?; + } + for (name, (spec, location)) in pypi_deps { let added = self.manifest.add_pep508_dependency( &spec, @@ -889,7 +913,7 @@ impl Project { fn update_conda_specs_from_lock_file( &mut self, updated_lock_file: &LockFile, - conda_specs_to_add_constraints_for: IndexMap, + conda_specs_to_add_constraints_for: IndexMap, affect_environment_and_platforms: Vec<(String, Platform)>, feature_name: &FeatureName, platforms: &[Platform], @@ -936,17 +960,20 @@ impl Project { if let Some(version_constraint) = version_constraint { implicit_constraints .insert(name.as_source().to_string(), version_constraint.to_string()); - let spec = MatchSpec { + let spec = NamelessMatchSpec { version: Some(version_constraint), ..spec }; + + let pixi_spec = PixiSpec::from_nameless_matchspec(spec.clone(), &channel_config); + self.manifest.add_dependency( - &spec, + &name, + &pixi_spec, spec_type, platforms, feature_name, DependencyOverwriteBehavior::Overwrite, - &channel_config, )?; } } diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index b4599b5c7..511f10d03 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -5,12 +5,13 @@ use crate::common::{ package_database::{Package, PackageDatabase}, LockFileExt, PixiControl, }; -use pixi::{DependencyType, Project}; +use pixi::{cli::cli_config::GitRev, DependencyType, Project}; use pixi_consts::consts; use pixi_manifest::pypi::VersionOrStar; use pixi_manifest::{pypi::PyPiPackageName, FeaturesExt, PyPiRequirement, SpecType}; use rattler_conda_types::{PackageName, Platform}; use tempfile::TempDir; +use url::Url; /// Test add functionality for different types of packages. /// Run, dev, build @@ -646,3 +647,167 @@ async fn add_dependency_pinning_strategy() { // Package should be automatically pinned to a major version assert_eq!(bar_spec, r#"">=1,<2""#); } + +/// Test adding a git dependency with a specific branch +#[tokio::test] +async fn add_git_deps() { + let pixi = PixiControl::from_manifest(&format!( + r#" +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["{platform}"] +preview = ['pixi-build'] +"#, + platform = Platform::current(), + )) + .unwrap(); + + // Add a package + pixi.add("boost-check") + .with_git_url(Url::parse("https://github.com/wolfv/pixi-build-examples").unwrap()) + .with_git_rev(GitRev::new().with_branch("main".to_string())) + .with_git_subdir("boost-check".to_string()) + .await + .unwrap(); + + let lock = pixi.lock_file().await.unwrap(); + insta::with_settings!({filters => vec![ + (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + ]}, { + insta::assert_snapshot!(lock.render_to_string().unwrap()); + }); + + // Check the manifest itself + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +} + +/// Test adding git dependencies with credentials +#[tokio::test] +async fn add_git_deps_with_creds() { + let pixi = PixiControl::from_manifest(&format!( + r#" +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["{platform}"] +preview = ['pixi-build'] +"#, + platform = Platform::current(), + )) + .unwrap(); + + // Add a package + // we want to make sure that the credentials are not exposed in the lock file + pixi.add("boost-check") + .with_git_url( + Url::parse("https://user:token123@github.com/wolfv/pixi-build-examples.git").unwrap(), + ) + .with_git_rev(GitRev::new().with_branch("main".to_string())) + .with_git_subdir("boost-check".to_string()) + .await + .unwrap(); + + let lock = pixi.lock_file().await.unwrap(); + insta::with_settings!({filters => vec![ + (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + ]}, { + insta::assert_snapshot!(lock.render_to_string().unwrap()); + }); + + // Check the manifest itself + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +} + +/// Test adding a git dependency with a specific commit +#[tokio::test] +async fn add_git_with_specific_commit() { + let pixi = PixiControl::from_manifest(&format!( + r#" +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["{platform}"] +preview = ['pixi-build']"#, + platform = Platform::current(), + )) + .unwrap(); + + // Add a package + pixi.add("boost-check") + .with_git_url(Url::parse("https://github.com/wolfv/pixi-build-examples").unwrap()) + .with_git_rev(GitRev::new().with_rev("9de9e1b".to_string())) + .with_git_subdir("boost-check".to_string()) + .await + .unwrap(); + + // Check the lock file + let lock = pixi.lock_file().await.unwrap(); + insta::with_settings!({filters => vec![ + (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + ]}, { + insta::assert_snapshot!(lock.render_to_string().unwrap()); + }); + + // Check the manifest itself + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +} + +/// Test adding a git dependency with a specific tag +#[tokio::test] +async fn add_git_with_tag() { + let pixi = PixiControl::from_manifest(&format!( + r#" +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["{platform}"] +preview = ['pixi-build']"#, + platform = Platform::current(), + )) + .unwrap(); + + // Add a package + pixi.add("boost-check") + .with_git_url(Url::parse("https://github.com/wolfv/pixi-build-examples").unwrap()) + .with_git_rev(GitRev::new().with_tag("v0.1.0".to_string())) + .with_git_subdir("boost-check".to_string()) + .await + .unwrap(); + + // Check the lock file + let lock = pixi.lock_file().await.unwrap(); + insta::with_settings!({filters => vec![ + (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + ]}, { + insta::assert_snapshot!(lock.render_to_string().unwrap()); + }); + + // Check the manifest itself + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +} + +/// Test adding a git dependency using ssh url +#[tokio::test] +async fn add_plain_ssh_url() { + let pixi = PixiControl::from_manifest(&format!( + r#" +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["{platform}"] +preview = ['pixi-build']"#, + platform = Platform::current(), + )) + .unwrap(); + + // Add a package + pixi.add("boost-check") + .with_git_url(Url::parse("git+ssh://git@github.com/wolfv/pixi-build-examples.git").unwrap()) + .with_no_lockfile_update(true) + .await + .unwrap(); + + // Check the manifest itself + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +} diff --git a/tests/integration_rust/common/builders.rs b/tests/integration_rust/common/builders.rs index 7ed0a54ab..2e5f051d3 100644 --- a/tests/integration_rust/common/builders.rs +++ b/tests/integration_rust/common/builders.rs @@ -23,7 +23,7 @@ //! } //! ``` -use pixi::cli::cli_config::{PrefixUpdateConfig, ProjectConfig}; +use pixi::cli::cli_config::{GitRev, PrefixUpdateConfig, ProjectConfig}; use std::{ future::{Future, IntoFuture}, io, @@ -143,6 +143,9 @@ pub trait HasDependencyConfig: Sized { pypi: false, platforms: Default::default(), feature: Default::default(), + git: Default::default(), + rev: Default::default(), + subdir: Default::default(), } } @@ -199,6 +202,26 @@ impl AddBuilder { self.args.dependency_config.feature = FeatureName::Named(feature.to_string()); self } + + pub fn with_git_url(mut self, url: Url) -> Self { + self.args.dependency_config.git = Some(url); + self + } + + pub fn with_git_rev(mut self, rev: GitRev) -> Self { + self.args.dependency_config.rev = Some(rev); + self + } + + pub fn with_git_subdir(mut self, subdir: String) -> Self { + self.args.dependency_config.subdir = Some(subdir); + self + } + + pub fn with_no_lockfile_update(mut self, no_lockfile_update: bool) -> Self { + self.args.prefix_update_config.no_lockfile_update = no_lockfile_update; + self + } } impl HasDependencyConfig for AddBuilder { diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap new file mode 100644 index 000000000..64e822491 --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap @@ -0,0 +1,12 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: pixi.project().unwrap().manifest().source.to_string() +--- +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["osx-arm64"] +preview = ['pixi-build'] + +[dependencies] +boost-check = { git = "https://github.com/wolfv/pixi-build-examples", branch = "main", subdirectory = "boost-check" } diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap new file mode 100644 index 000000000..04ff8d501 --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap @@ -0,0 +1,31 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: lock.render_to_string().unwrap() +--- +version: 6 +environments: + default: + channels: + - url: https://prefix.dev/conda-forge/ + packages: + osx-arm64: + - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&branch=main#[FULL_COMMIT] +packages: +- conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&branch=main#[FULL_COMMIT] + name: boost-check + version: 0.1.0 + build: hbf21a9e_0 + subdir: osx-arm64 + depends: + - libcxx >=19 + channel: null +- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec + md5: ce5252d8db110cdb4ae4173d0a63c7c5 + depends: + - __osx >=11.0 + license: Apache-2.0 WITH LLVM-exception + license_family: Apache + size: 520992 + timestamp: 1734494699681 diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap new file mode 100644 index 000000000..86e9b5b82 --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap @@ -0,0 +1,12 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: pixi.project().unwrap().manifest().source.to_string() +--- +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["osx-arm64"] +preview = ['pixi-build'] + +[dependencies] +boost-check = { git = "https://user:token123@github.com/wolfv/pixi-build-examples.git", branch = "main", subdirectory = "boost-check" } diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap new file mode 100644 index 000000000..65e313c34 --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap @@ -0,0 +1,31 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: lock.render_to_string().unwrap() +--- +version: 6 +environments: + default: + channels: + - url: https://prefix.dev/conda-forge/ + packages: + osx-arm64: + - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + - conda: git+https://github.com/wolfv/pixi-build-examples.git?subdirectory=boost-check&branch=main#[FULL_COMMIT] +packages: +- conda: git+https://github.com/wolfv/pixi-build-examples.git?subdirectory=boost-check&branch=main#[FULL_COMMIT] + name: boost-check + version: 0.1.0 + build: hbf21a9e_0 + subdir: osx-arm64 + depends: + - libcxx >=19 + channel: null +- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec + md5: ce5252d8db110cdb4ae4173d0a63c7c5 + depends: + - __osx >=11.0 + license: Apache-2.0 WITH LLVM-exception + license_family: Apache + size: 520992 + timestamp: 1734494699681 diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap new file mode 100644 index 000000000..ead53e0e0 --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap @@ -0,0 +1,12 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: pixi.project().unwrap().manifest().source.to_string() +--- +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["osx-arm64"] +preview = ['pixi-build'] + +[dependencies] +boost-check = { git = "https://github.com/wolfv/pixi-build-examples", rev = "9de9e1b", subdirectory = "boost-check" } diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap new file mode 100644 index 000000000..93b8e935d --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap @@ -0,0 +1,31 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: lock.render_to_string().unwrap() +--- +version: 6 +environments: + default: + channels: + - url: https://prefix.dev/conda-forge/ + packages: + osx-arm64: + - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&rev=9de9e1b#[FULL_COMMIT] +packages: +- conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&rev=9de9e1b#[FULL_COMMIT] + name: boost-check + version: 0.1.0 + build: hbf21a9e_0 + subdir: osx-arm64 + depends: + - libcxx >=19 + channel: null +- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec + md5: ce5252d8db110cdb4ae4173d0a63c7c5 + depends: + - __osx >=11.0 + license: Apache-2.0 WITH LLVM-exception + license_family: Apache + size: 520992 + timestamp: 1734494699681 diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap new file mode 100644 index 000000000..f27d7ec15 --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap @@ -0,0 +1,12 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: pixi.project().unwrap().manifest().source.to_string() +--- +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["osx-arm64"] +preview = ['pixi-build'] + +[dependencies] +boost-check = { git = "https://github.com/wolfv/pixi-build-examples", tag = "v0.1.0", subdirectory = "boost-check" } diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap new file mode 100644 index 000000000..b40f7703b --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap @@ -0,0 +1,31 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: lock.render_to_string().unwrap() +--- +version: 6 +environments: + default: + channels: + - url: https://prefix.dev/conda-forge/ + packages: + osx-arm64: + - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&tag=v0.1.0#[FULL_COMMIT] +packages: +- conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&tag=v0.1.0#[FULL_COMMIT] + name: boost-check + version: 0.1.0 + build: hbf21a9e_0 + subdir: osx-arm64 + depends: + - libcxx >=19 + channel: null +- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec + md5: ce5252d8db110cdb4ae4173d0a63c7c5 + depends: + - __osx >=11.0 + license: Apache-2.0 WITH LLVM-exception + license_family: Apache + size: 520992 + timestamp: 1734494699681 diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_git.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_git.snap new file mode 100644 index 000000000..bb5edf21d --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_git.snap @@ -0,0 +1,12 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: pixi.project().unwrap().manifest().source.to_string() +--- +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["osx-arm64"] +preview = ['pixi-build'] + +[dependencies] +boost-check = { git = "https://github.com/wolfv/pixi-build-examples" } diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap new file mode 100644 index 000000000..5cbc4135d --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap @@ -0,0 +1,12 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: pixi.project().unwrap().manifest().source.to_string() +--- +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["osx-arm64"] +preview = ['pixi-build'] + +[dependencies] +boost-check = { git = "git+ssh://git@github.com/wolfv/pixi-build-examples.git" } From ece11c6db0cba642570dc796bde4b4b57953fb86 Mon Sep 17 00:00:00 2001 From: nichmor Date: Wed, 8 Jan 2025 13:07:41 +0200 Subject: [PATCH 02/20] misc: remove funcs and add some docstrings --- crates/pixi_git/src/lib.rs | 16 ---------------- crates/pixi_spec/src/lib.rs | 21 +++++---------------- src/cli/add.rs | 4 ++-- src/cli/cli_config.rs | 4 ++++ 4 files changed, 11 insertions(+), 34 deletions(-) diff --git a/crates/pixi_git/src/lib.rs b/crates/pixi_git/src/lib.rs index b5dd20475..612cbbef2 100644 --- a/crates/pixi_git/src/lib.rs +++ b/crates/pixi_git/src/lib.rs @@ -73,22 +73,6 @@ impl GitUrl { pub fn precise(&self) -> Option { self.precise } - - /// Determines if the given URL looks like a Git URL. - pub fn is_git_url(url: &Url) -> bool { - // Check if the scheme indicates it's a Git URL. - if url.scheme().starts_with("git+") { - // Check if the path ends with .git or has a Git-specific format. - return true; - } else if let Some(path) = url.path_segments() { - if path.clone().any(|segment| segment.ends_with(".git")) { - return true; - } - }; - - // If the URL doesn't match Git-specific patterns, return false. - false - } } impl TryFrom for GitUrl { diff --git a/crates/pixi_spec/src/lib.rs b/crates/pixi_spec/src/lib.rs index 4fbb80c02..dd8ae73f6 100644 --- a/crates/pixi_spec/src/lib.rs +++ b/crates/pixi_spec/src/lib.rs @@ -20,7 +20,6 @@ pub use detailed::DetailedSpec; pub use git::{GitSpec, Reference}; use itertools::Either; pub use path::{PathBinarySpec, PathSourceSpec, PathSpec}; -use pixi_git::GitUrl; use rattler_conda_types::{ ChannelConfig, NamedChannelOrUrl, NamelessMatchSpec, ParseChannelError, VersionSpec, }; @@ -103,21 +102,11 @@ impl PixiSpec { channel_config: &ChannelConfig, ) -> Self { if let Some(url) = spec.url { - // check if it is a git url - if GitUrl::is_git_url(&url) { - let git_url = GitUrl::try_from(url.clone()).unwrap(); - Self::Git(GitSpec { - git: git_url.repository().clone(), - rev: Some(git_url.reference().clone().into()), - subdirectory: spec.subdir, - }) - } else { - Self::Url(UrlSpec { - url, - md5: spec.md5, - sha256: spec.sha256, - }) - } + Self::Url(UrlSpec { + url, + md5: spec.md5, + sha256: spec.sha256, + }) } else if spec.build.is_none() && spec.build_number.is_none() && spec.file_name.is_none() diff --git a/src/cli/add.rs b/src/cli/add.rs index 9fb254bfe..9ee561363 100644 --- a/src/cli/add.rs +++ b/src/cli/add.rs @@ -102,8 +102,8 @@ pub async fn execute(args: Args) -> miette::Result<()> { let (match_specs, source_specs, pypi_deps) = match dependency_config.dependency_type() { DependencyType::CondaDependency(spec_type) => { - // now if user passed some git configuration - // we will use it to create pixi specs + // if user passed some git configuration + // we will use it to create pixi source specs let passed_specs: IndexMap = dependency_config .specs()? .into_iter() diff --git a/src/cli/cli_config.rs b/src/cli/cli_config.rs index c057e3dcf..d785bb456 100644 --- a/src/cli/cli_config.rs +++ b/src/cli/cli_config.rs @@ -148,20 +148,24 @@ pub struct GitRev { } impl GitRev { + /// Create a new `GitRev` pub fn new() -> Self { Default::default() } + /// Set the branch pub fn with_branch(mut self, branch: String) -> GitRev { self.branch = Some(branch); self } + /// Set the revision pub fn with_rev(mut self, rev: String) -> GitRev { self.rev = Some(rev); self } + /// Set the tag pub fn with_tag(mut self, tag: String) -> GitRev { self.tag = Some(tag); self From 7cc36352b9651a4b74884e614f19177d42b96baa Mon Sep 17 00:00:00 2001 From: nichmor Date: Wed, 8 Jan 2025 13:13:56 +0200 Subject: [PATCH 03/20] misc: remove unused dep --- Cargo.lock | 1 - crates/pixi_manifest/Cargo.toml | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 26248c589..86c85881c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -3886,7 +3886,6 @@ dependencies = [ "pixi_consts", "pixi_spec", "pixi_toml", - "pixi_utils", "pyproject-toml", "rattler_conda_types", "rattler_lock", diff --git a/crates/pixi_manifest/Cargo.toml b/crates/pixi_manifest/Cargo.toml index e7d399a7b..eecec9b36 100644 --- a/crates/pixi_manifest/Cargo.toml +++ b/crates/pixi_manifest/Cargo.toml @@ -19,7 +19,7 @@ pep508_rs = { workspace = true } pixi_consts = { workspace = true } pixi_spec = { workspace = true } pixi_toml = { workspace = true } -pixi_utils = { workspace = true } +# pixi_utils = { workspace = true } regex = { workspace = true } serde = { workspace = true } serde-value = { workspace = true } From c720898de7249facf3081cb76b0613a0407ee136 Mon Sep 17 00:00:00 2001 From: nichmor Date: Wed, 8 Jan 2025 13:21:04 +0200 Subject: [PATCH 04/20] misc: remove unused dep --- crates/pixi_git/src/url.rs | 4 ---- crates/pixi_spec/src/lib.rs | 1 - 2 files changed, 5 deletions(-) diff --git a/crates/pixi_git/src/url.rs b/crates/pixi_git/src/url.rs index 1cf0d109c..b0aa3dd11 100644 --- a/crates/pixi_git/src/url.rs +++ b/crates/pixi_git/src/url.rs @@ -126,10 +126,6 @@ impl RepositoryUrl { pub fn parse(url: &str) -> Result { Ok(Self::new(&Url::parse(url)?)) } - - pub fn looks_like_git_url(url: &str) -> bool { - url.starts_with("git+") || url.ends_with(".git") - } } /// Remove the credentials from a URL, allowing the generic `git` username (without a password) diff --git a/crates/pixi_spec/src/lib.rs b/crates/pixi_spec/src/lib.rs index dd8ae73f6..75f0e0792 100644 --- a/crates/pixi_spec/src/lib.rs +++ b/crates/pixi_spec/src/lib.rs @@ -310,7 +310,6 @@ impl PixiSpec { /// Converts this instance into a [`toml_edit::Value`]. pub fn to_toml_value(&self) -> toml_edit::Value { - eprintln!("to_toml_value: {:?}", self); ::serde::Serialize::serialize(self, toml_edit::ser::ValueSerializer::new()) .expect("conversion to toml cannot fail") } From 1d75bb3dd3b280b099e3216485c9588447a333ed Mon Sep 17 00:00:00 2001 From: nichmor Date: Wed, 8 Jan 2025 13:23:29 +0200 Subject: [PATCH 05/20] misc: add conflicts_with_all for GitRev --- src/cli/cli_config.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/cli/cli_config.rs b/src/cli/cli_config.rs index d785bb456..700a09c2a 100644 --- a/src/cli/cli_config.rs +++ b/src/cli/cli_config.rs @@ -135,15 +135,15 @@ impl PrefixUpdateConfig { #[derive(Parser, Debug, Default, Clone)] pub struct GitRev { /// The git branch - #[clap(long, requires = "git")] + #[clap(long, requires = "git", conflicts_with_all = ["tag", "rev"])] pub branch: Option, /// The git tag - #[clap(long, requires = "git")] + #[clap(long, requires = "git", conflicts_with_all = ["branch", "rev"])] pub tag: Option, /// The git revision - #[clap(long, requires = "git")] + #[clap(long, requires = "git", conflicts_with_all = ["branch", "tag"])] pub rev: Option, } From a66f5a63cae4cc9e2ff4a5afed4ef65cf41108bf Mon Sep 17 00:00:00 2001 From: nichmor Date: Wed, 8 Jan 2025 13:24:06 +0200 Subject: [PATCH 06/20] misc: remove pixi_utils --- crates/pixi_manifest/Cargo.toml | 1 - 1 file changed, 1 deletion(-) diff --git a/crates/pixi_manifest/Cargo.toml b/crates/pixi_manifest/Cargo.toml index eecec9b36..19aeefe49 100644 --- a/crates/pixi_manifest/Cargo.toml +++ b/crates/pixi_manifest/Cargo.toml @@ -19,7 +19,6 @@ pep508_rs = { workspace = true } pixi_consts = { workspace = true } pixi_spec = { workspace = true } pixi_toml = { workspace = true } -# pixi_utils = { workspace = true } regex = { workspace = true } serde = { workspace = true } serde-value = { workspace = true } From f97bf3faf97b4852ca146178d7e8cbfb5a1c5362 Mon Sep 17 00:00:00 2001 From: nichmor Date: Wed, 8 Jan 2025 15:28:27 +0200 Subject: [PATCH 07/20] misc: update failing tests and snapshots --- crates/pixi_spec/src/git.rs | 3 +++ tests/integration_rust/add_tests.rs | 4 ++++ .../integration_rust__add_tests__add_git_deps.snap | 9 +++++---- ...gration_rust__add_tests__add_git_deps_with_creds.snap | 9 +++++---- ...on_rust__add_tests__add_git_with_specific_commit.snap | 8 ++++---- .../integration_rust__add_tests__add_git_with_tag.snap | 8 ++++---- 6 files changed, 25 insertions(+), 16 deletions(-) diff --git a/crates/pixi_spec/src/git.rs b/crates/pixi_spec/src/git.rs index 877b58d87..82324b448 100644 --- a/crates/pixi_spec/src/git.rs +++ b/crates/pixi_spec/src/git.rs @@ -81,8 +81,11 @@ impl Serialize for Reference { { #[derive(Serialize)] struct RawReference<'a> { + #[serde(skip_serializing_if = "Option::is_none")] tag: Option<&'a str>, + #[serde(skip_serializing_if = "Option::is_none")] branch: Option<&'a str>, + #[serde(skip_serializing_if = "Option::is_none")] rev: Option<&'a str>, } diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index 511f10d03..68f879952 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -674,6 +674,7 @@ preview = ['pixi-build'] let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); @@ -711,6 +712,7 @@ preview = ['pixi-build'] let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); @@ -745,6 +747,7 @@ preview = ['pixi-build']"#, let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); @@ -779,6 +782,7 @@ preview = ['pixi-build']"#, let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap index 04ff8d501..e3cb6c832 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap @@ -1,6 +1,7 @@ --- source: tests/integration_rust/add_tests.rs expression: lock.render_to_string().unwrap() +snapshot_kind: text --- version: 6 environments: @@ -8,19 +9,19 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - osx-arm64: - - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + [CURRENT_PLATFORM]: + - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&branch=main#[FULL_COMMIT] packages: - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&branch=main#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: osx-arm64 + subdir: [CURRENT_PLATFORM] depends: - libcxx >=19 channel: null -- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda +- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec md5: ce5252d8db110cdb4ae4173d0a63c7c5 depends: diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap index 65e313c34..36c6fd595 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap @@ -1,6 +1,7 @@ --- source: tests/integration_rust/add_tests.rs expression: lock.render_to_string().unwrap() +snapshot_kind: text --- version: 6 environments: @@ -8,19 +9,19 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - osx-arm64: - - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + [CURRENT_PLATFORM]: + - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples.git?subdirectory=boost-check&branch=main#[FULL_COMMIT] packages: - conda: git+https://github.com/wolfv/pixi-build-examples.git?subdirectory=boost-check&branch=main#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: osx-arm64 + subdir: [CURRENT_PLATFORM] depends: - libcxx >=19 channel: null -- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda +- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec md5: ce5252d8db110cdb4ae4173d0a63c7c5 depends: diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap index 93b8e935d..1ebf46cc2 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap @@ -8,19 +8,19 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - osx-arm64: - - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + [CURRENT_PLATFORM]: + - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&rev=9de9e1b#[FULL_COMMIT] packages: - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&rev=9de9e1b#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: osx-arm64 + subdir: [CURRENT_PLATFORM] depends: - libcxx >=19 channel: null -- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda +- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec md5: ce5252d8db110cdb4ae4173d0a63c7c5 depends: diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap index b40f7703b..95769e949 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap @@ -8,19 +8,19 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - osx-arm64: - - conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda + [CURRENT_PLATFORM]: + - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&tag=v0.1.0#[FULL_COMMIT] packages: - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&tag=v0.1.0#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: osx-arm64 + subdir: [CURRENT_PLATFORM] depends: - libcxx >=19 channel: null -- conda: https://prefix.dev/conda-forge/osx-arm64/libcxx-19.1.6-ha82da77_1.conda +- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec md5: ce5252d8db110cdb4ae4173d0a63c7c5 depends: From ae8160a3414ba1c68b1ea8a3d684c260c810efd8 Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 9 Jan 2025 16:10:15 +0200 Subject: [PATCH 08/20] misc: add pypi implementation --- docs/reference/cli.md | 38 +++++++----- src/cli/add.rs | 20 +++++-- src/cli/cli_config.rs | 59 +++++++++++++++++-- tests/integration_rust/add_tests.rs | 27 +++++++++ tests/integration_rust/common/builders.rs | 5 ++ ...gration_rust__add_tests__add_pypi_git.snap | 11 ++++ 6 files changed, 137 insertions(+), 23 deletions(-) create mode 100644 tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 5f6240789..89155f31d 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -98,15 +98,20 @@ pixi add --platform osx-64 clang # (7)! pixi add --no-install numpy # (8)! pixi add --no-lockfile-update numpy # (9)! pixi add --feature featurex numpy # (10)! +pixi add --git https://github.com/wolfv/pixi-build-examples boost-check # (11)! +pixi add --git https://github.com/wolfv/pixi-build-examples --branch main --subdir boost-check boost-check # (12)! +pixi add --git https://github.com/wolfv/pixi-build-examples --tag v0.1.0 boost-check # (13)! +pixi add --git https://github.com/wolfv/pixi-build-examples --rev e50d4a1 boost-check # (14)! # Add a pypi dependency -pixi add --pypi requests[security] # (11)! -pixi add --pypi Django==5.1rc1 # (12)! -pixi add --pypi "boltons>=24.0.0" --feature lint # (13)! -pixi add --pypi "boltons @ https://files.pythonhosted.org/packages/46/35/e50d4a115f93e2a3fbf52438435bb2efcf14c11d4fcd6bdcd77a6fc399c9/boltons-24.0.0-py3-none-any.whl" # (14)! -pixi add --pypi "exchangelib @ git+https://github.com/ecederstrand/exchangelib" # (15)! -pixi add --pypi "project @ file:///absolute/path/to/project" # (16)! -pixi add --pypi "project@file:///absolute/path/to/project" --editable # (17)! +pixi add --pypi requests[security] # (15)! +pixi add --pypi Django==5.1rc1 # (16)! +pixi add --pypi "boltons>=24.0.0" --feature lint # (17)! +pixi add --pypi "boltons @ https://files.pythonhosted.org/packages/46/35/e50d4a115f93e2a3fbf52438435bb2efcf14c11d4fcd6bdcd77a6fc399c9/boltons-24.0.0-py3-none-any.whl" # (18)! +pixi add --pypi "exchangelib @ git+https://github.com/ecederstrand/exchangelib" # (19)! +pixi add --pypi "project @ file:///absolute/path/to/project" # (20)! +pixi add --pypi "project@file:///absolute/path/to/project" --editable # (21)! +pixi add --git https://github.com/mahmoud/boltons.git boltons --pypi # (22)! ``` 1. This will add the `numpy` package to the project with the latest available for the solved environment. @@ -119,13 +124,18 @@ pixi add --pypi "project@file:///absolute/path/to/project" --editable # (17)! 8. This will add the `numpy` package to the manifest and lockfile, without installing it in an environment. 9. This will add the `numpy` package to the manifest without updating the lockfile or installing it in the environment. 10. This will add the `numpy` package in the feature `featurex`. -11. This will add the `requests` package as `pypi` dependency with the `security` extra. -12. This will add the `pre-release` version of `Django` to the project as a `pypi` dependency. -13. This will add the `boltons` package in the feature `lint` as `pypi` dependency. -14. This will add the `boltons` package with the given `url` as `pypi` dependency. -15. This will add the `exchangelib` package with the given `git` url as `pypi` dependency. -16. This will add the `project` package with the given `file` url as `pypi` dependency. -17. This will add the `project` package with the given `file` url as an `editable` package as `pypi` dependency. +11. This will add the `boost-check` source package to the dependencies from the git repository. +12. This will add the `boost-check` source package to the dependencies from the git repository using `main` branch and the `boost-check` folder in the repository. +13. This will add the `boost-check` source package to the dependencies from the git repository using `v0.1.0` tag. +14. This will add the `boost-check` source package to the dependencies from the git repository using `e50d4a1` revision. +15. This will add the `requests` package as `pypi` dependency with the `security` extra. +16. This will add the `pre-release` version of `Django` to the project as a `pypi` dependency. +17. This will add the `boltons` package in the feature `lint` as `pypi` dependency. +18. This will add the `boltons` package with the given `url` as `pypi` dependency. +19. This will add the `exchangelib` package with the given `git` url as `pypi` dependency. +20. This will add the `project` package with the given `file` url as `pypi` dependency. +21. This will add the `project` package with the given `file` url as an `editable` package as `pypi` dependency. +22. This will add the `boltons` package with the given `git` url as `pypi` dependency. `branch`, `tag`, and `rev` are not yet supported. !!! tip If you want to use a non default pinning strategy, you can set it using [pixi's configuration](./pixi_configuration.md#pinning-strategy). diff --git a/src/cli/add.rs b/src/cli/add.rs index 9ee561363..52aa4207b 100644 --- a/src/cli/add.rs +++ b/src/cli/add.rs @@ -133,11 +133,21 @@ pub async fn execute(args: Args) -> miette::Result<()> { DependencyType::PypiDependency => { let match_specs = IndexMap::default(); let source_specs = IndexMap::default(); - let pypi_deps = dependency_config - .pypi_deps(&project)? - .into_iter() - .map(|(name, req)| (name, (req, None))) - .collect(); + let pypi_deps = match dependency_config + .vcs_pep508_requirements(&project) + .transpose()? + { + Some(vcs_reqs) => vcs_reqs + .into_iter() + .map(|(name, req)| (name, (req, None))) + .collect(), + None => dependency_config + .pypi_deps(&project)? + .into_iter() + .map(|(name, req)| (name, (req, None))) + .collect(), + }; + (match_specs, source_specs, pypi_deps) } }; diff --git a/src/cli/cli_config.rs b/src/cli/cli_config.rs index 700a09c2a..0f518f70f 100644 --- a/src/cli/cli_config.rs +++ b/src/cli/cli_config.rs @@ -4,11 +4,14 @@ use crate::lock_file::UpdateMode; use crate::DependencyType; use crate::Project; use clap::Parser; +use indexmap::IndexMap; use indexmap::IndexSet; use itertools::Itertools; use miette::IntoDiagnostic; +use pep508_rs::Requirement; use pixi_config::{Config, ConfigCli}; use pixi_consts::consts; +use pixi_manifest::pypi::PyPiPackageName; use pixi_manifest::FeaturesExt; use pixi_manifest::{FeatureName, SpecType}; use pixi_spec::Reference; @@ -135,15 +138,15 @@ impl PrefixUpdateConfig { #[derive(Parser, Debug, Default, Clone)] pub struct GitRev { /// The git branch - #[clap(long, requires = "git", conflicts_with_all = ["tag", "rev"])] + #[clap(long, requires = "git", conflicts_with_all = ["tag", "rev", "pypi"])] pub branch: Option, /// The git tag - #[clap(long, requires = "git", conflicts_with_all = ["branch", "rev"])] + #[clap(long, requires = "git", conflicts_with_all = ["branch", "rev", "pypi"])] pub tag: Option, /// The git revision - #[clap(long, requires = "git", conflicts_with_all = ["branch", "tag"])] + #[clap(long, requires = "git", conflicts_with_all = ["branch", "tag", "pypi"])] pub rev: Option, } @@ -170,6 +173,18 @@ impl GitRev { self.tag = Some(tag); self } + + pub fn as_str(&self) -> Option<&str> { + if let Some(branch) = &self.branch { + Some(branch) + } else if let Some(tag) = &self.tag { + Some(tag) + } else if let Some(rev) = &self.rev { + Some(rev) + } else { + None + } + } } impl From for Reference { @@ -216,7 +231,7 @@ pub struct DependencyConfig { pub feature: FeatureName, /// The git url to use when adding a git dependency - #[clap(long, short, conflicts_with_all = ["pypi"])] + #[clap(long, short)] pub git: Option, #[clap(flatten)] @@ -288,6 +303,42 @@ impl DependencyConfig { } } } + + pub fn vcs_pep508_requirements( + &self, + project: &Project, + ) -> Option>> { + match &self.git { + Some(git) => { + // pep 508 requirements with direct reference + // should be in this format + // name @ url@rev#subdirectory=subdir + // we need to construct it + let pep_reqs: miette::Result> = self + .specs + .iter() + .map(|package_name| { + let mut vcs_req = format!("{} @ {}", package_name, git); + if let Some(rev) = &self.rev { + if let Some(rev_str) = rev.as_str() { + vcs_req.push_str(&format!("@{}", rev_str)); + } + } + if let Some(subdir) = &self.subdir { + vcs_req.push_str(&format!("#subdirectory={}", subdir)); + } + + let dep = Requirement::parse(&vcs_req, project.root()).into_diagnostic()?; + let name = PyPiPackageName::from_normalized(dep.clone().name); + + Ok((name, dep)) + }) + .collect(); + Some(pep_reqs) + } + None => None, + } + } } impl HasSpecs for DependencyConfig { diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index 68f879952..af75e0085 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -815,3 +815,30 @@ preview = ['pixi-build']"#, // Check the manifest itself insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); } + +/// Test adding a git dependency using ssh url +#[tokio::test] +async fn add_pypi_git() { + let pixi = PixiControl::from_manifest(&format!( + r#" +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["{platform}"] + +"#, + platform = Platform::current(), + )) + .unwrap(); + + // Add a package + pixi.add("boltons") + .set_pypi(true) + .with_git_url(Url::parse("https://github.com/mahmoud/boltons.git").unwrap()) + .with_no_lockfile_update(true) + .await + .unwrap(); + + // Check the manifest itself + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +} diff --git a/tests/integration_rust/common/builders.rs b/tests/integration_rust/common/builders.rs index 2e5f051d3..fb69d4b02 100644 --- a/tests/integration_rust/common/builders.rs +++ b/tests/integration_rust/common/builders.rs @@ -198,6 +198,11 @@ impl AddBuilder { self } + pub fn set_pypi(mut self, pypi: bool) -> Self { + self.args.dependency_config.pypi = pypi; + self + } + pub fn with_feature(mut self, feature: impl ToString) -> Self { self.args.dependency_config.feature = FeatureName::Named(feature.to_string()); self diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap new file mode 100644 index 000000000..f4b5d2e27 --- /dev/null +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap @@ -0,0 +1,11 @@ +--- +source: tests/integration_rust/add_tests.rs +expression: pixi.project().unwrap().manifest().source.to_string() +--- +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["osx-arm64"] + +[pypi-dependencies] +boltons = { git = "https://github.com/mahmoud/boltons.git" } From a6b302da09788777f979ae43963a4992235147c8 Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 9 Jan 2025 16:26:50 +0200 Subject: [PATCH 09/20] misc: add cli docs --- docs/reference/cli.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/docs/reference/cli.md b/docs/reference/cli.md index 89155f31d..26b0e10e6 100644 --- a/docs/reference/cli.md +++ b/docs/reference/cli.md @@ -79,6 +79,12 @@ These dependencies will be read by pixi as if they had been added to the pixi `p - `--pypi`: Specifies a PyPI dependency, not a conda package. Parses dependencies as [PEP508](https://peps.python.org/pep-0508/) requirements, supporting extras and versions. See [configuration](pixi_manifest.md) for details. +- `--git`: Specifies a git dependency, the package will be installed from the git repository. + The `--git` flag can be used with the following options: + - `--branch `: The branch to use when installing the package. + - `--tag `: The tag to use when installing the package. + - `--rev `: The revision to use when installing the package. + - `--subdir `: The subdirectory to use when installing the package. - `--no-install`: Don't install the package to the environment, only add the package to the lock-file. - `--no-lockfile-update`: Don't update the lock-file, implies the `--no-install` flag. - `--platform (-p)`: The platform for which the dependency should be added. (Allowed to be used more than once) From 7608031aa00c6962302aae0abb8c02f416554d72 Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 9 Jan 2025 17:00:18 +0200 Subject: [PATCH 10/20] misc: add unit tests for vcs reqs --- src/cli/cli_config.rs | 89 ++++++++++++++++++++++++++++++++++++++----- 1 file changed, 80 insertions(+), 9 deletions(-) diff --git a/src/cli/cli_config.rs b/src/cli/cli_config.rs index 0f518f70f..3ce1d50e6 100644 --- a/src/cli/cli_config.rs +++ b/src/cli/cli_config.rs @@ -318,15 +318,12 @@ impl DependencyConfig { .specs .iter() .map(|package_name| { - let mut vcs_req = format!("{} @ {}", package_name, git); - if let Some(rev) = &self.rev { - if let Some(rev_str) = rev.as_str() { - vcs_req.push_str(&format!("@{}", rev_str)); - } - } - if let Some(subdir) = &self.subdir { - vcs_req.push_str(&format!("#subdirectory={}", subdir)); - } + let vcs_req = build_vcs_requirement( + package_name, + git, + self.rev.as_ref(), + self.subdir.clone(), + ); let dep = Requirement::parse(&vcs_req, project.root()).into_diagnostic()?; let name = PyPiPackageName::from_normalized(dep.clone().name); @@ -346,3 +343,77 @@ impl HasSpecs for DependencyConfig { self.specs.iter().map(AsRef::as_ref).collect() } } + +/// Builds a PEP 508 compliant VCS requirement string +fn build_vcs_requirement( + package_name: &str, + git: &Url, + rev: Option<&GitRev>, + subdir: Option, +) -> String { + let mut vcs_req = format!("{} @ {}", package_name, git); + if let Some(rev_str) = rev.and_then(|rev| rev.as_str().map(|s| s.to_string())) { + vcs_req.push_str(&format!("@{}", rev_str)); + } + if let Some(subdir) = subdir { + vcs_req.push_str(&format!("#subdirectory={}", subdir)); + } + vcs_req +} + +#[cfg(test)] +mod tests { + use url::Url; + + use crate::cli::cli_config::{build_vcs_requirement, GitRev}; + + #[test] + fn test_build_vcs_requirement_with_all_fields() { + let result = build_vcs_requirement( + "mypackage", + &Url::parse("https://github.com/user/repo").unwrap(), + Some(&GitRev::new().with_tag("v1.0.0".to_string())), + Some("subdir".to_string()), + ); + assert_eq!( + result, + "mypackage @ https://github.com/user/repo@v1.0.0#subdirectory=subdir" + ); + } + + #[test] + fn test_build_vcs_requirement_with_no_rev() { + let result = build_vcs_requirement( + "mypackage", + &Url::parse("https://github.com/user/repo").unwrap(), + None, + Some("subdir".to_string()), + ); + assert_eq!( + result, + "mypackage @ https://github.com/user/repo#subdirectory=subdir" + ); + } + + #[test] + fn test_build_vcs_requirement_with_no_subdir() { + let result = build_vcs_requirement( + "mypackage", + &Url::parse("https://github.com/user/repo").unwrap(), + Some(&GitRev::new().with_tag("v1.0.0".to_string())), + None, + ); + assert_eq!(result, "mypackage @ https://github.com/user/repo@v1.0.0"); + } + + #[test] + fn test_build_vcs_requirement_with_only_git() { + let result = build_vcs_requirement( + "mypackage", + &Url::parse("https://github.com/user/repo").unwrap(), + None, + None, + ); + assert_eq!(result, "mypackage @ https://github.com/user/repo"); + } +} From bba2eea4b6b19247fb9348320589c0f75b3b7e18 Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 9 Jan 2025 17:32:08 +0200 Subject: [PATCH 11/20] misc: update snapshot --- tests/integration_rust/add_tests.rs | 7 ++++++- .../integration_rust__add_tests__add_pypi_git.snap | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index 76896dc02..0f55e2dc6 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -840,7 +840,12 @@ platforms = ["{platform}"] .unwrap(); // Check the manifest itself - insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); + insta::with_settings!({filters => vec![ + (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") + ]}, { + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); + }); } #[tokio::test] diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap index f4b5d2e27..f3eaee489 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap @@ -5,7 +5,7 @@ expression: pixi.project().unwrap().manifest().source.to_string() [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["osx-arm64"] +platforms = ["[CURRENT_PLATFORM]"] [pypi-dependencies] boltons = { git = "https://github.com/mahmoud/boltons.git" } From 95750019b08feaf637745127d39cd99a2321d6af Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 9 Jan 2025 18:06:43 +0200 Subject: [PATCH 12/20] misc: make tests more stable by using only one platform --- .../pixi_manifest/src/manifests/manifest.rs | 2 +- tests/integration_rust/add_tests.rs | 43 +++++------ ...ation_rust__add_tests__add_git_deps-2.snap | 2 +- ...gration_rust__add_tests__add_git_deps.snap | 71 +++++++++++++++---- ...t__add_tests__add_git_deps_with_creds.snap | 71 +++++++++++++++---- ...d_tests__add_git_with_specific_commit.snap | 70 ++++++++++++++---- ...ion_rust__add_tests__add_git_with_tag.snap | 70 ++++++++++++++---- 7 files changed, 250 insertions(+), 79 deletions(-) diff --git a/crates/pixi_manifest/src/manifests/manifest.rs b/crates/pixi_manifest/src/manifests/manifest.rs index 1618e4871..457d35ccb 100644 --- a/crates/pixi_manifest/src/manifests/manifest.rs +++ b/crates/pixi_manifest/src/manifests/manifest.rs @@ -2086,7 +2086,7 @@ bar = "*" Some(&VersionSpec::from_str(">=1.2.3", Strict).unwrap()) ); - let (name, spec) = MatchSpec::from_str("qux >=1.2.3", Strict) + let (name, spec) = MatchSpec::from_str("bal >=2.3", Strict) .unwrap() .into_nameless(); let pixi_spec = PixiSpec::from_nameless_matchspec(spec, &channel_config); diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index 0f55e2dc6..de7a39d51 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -651,16 +651,15 @@ async fn add_dependency_pinning_strategy() { /// Test adding a git dependency with a specific branch #[tokio::test] async fn add_git_deps() { - let pixi = PixiControl::from_manifest(&format!( + let pixi = PixiControl::from_manifest( r#" [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["{platform}"] +platforms = ["linux-64"] preview = ['pixi-build'] "#, - platform = Platform::current(), - )) + ) .unwrap(); // Add a package @@ -674,7 +673,6 @@ preview = ['pixi-build'] let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), - (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); @@ -686,16 +684,15 @@ preview = ['pixi-build'] /// Test adding git dependencies with credentials #[tokio::test] async fn add_git_deps_with_creds() { - let pixi = PixiControl::from_manifest(&format!( + let pixi = PixiControl::from_manifest( r#" [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["{platform}"] +platforms = ["linux-64"] preview = ['pixi-build'] "#, - platform = Platform::current(), - )) + ) .unwrap(); // Add a package @@ -712,7 +709,6 @@ preview = ['pixi-build'] let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), - (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); @@ -724,15 +720,14 @@ preview = ['pixi-build'] /// Test adding a git dependency with a specific commit #[tokio::test] async fn add_git_with_specific_commit() { - let pixi = PixiControl::from_manifest(&format!( + let pixi = PixiControl::from_manifest( r#" [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["{platform}"] +platforms = ["linux-64"] preview = ['pixi-build']"#, - platform = Platform::current(), - )) + ) .unwrap(); // Add a package @@ -747,7 +742,6 @@ preview = ['pixi-build']"#, let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), - (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); @@ -759,15 +753,14 @@ preview = ['pixi-build']"#, /// Test adding a git dependency with a specific tag #[tokio::test] async fn add_git_with_tag() { - let pixi = PixiControl::from_manifest(&format!( + let pixi = PixiControl::from_manifest( r#" [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["{platform}"] +platforms = ["linux-64"] preview = ['pixi-build']"#, - platform = Platform::current(), - )) + ) .unwrap(); // Add a package @@ -782,7 +775,6 @@ preview = ['pixi-build']"#, let lock = pixi.lock_file().await.unwrap(); insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), - (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(lock.render_to_string().unwrap()); }); @@ -794,15 +786,14 @@ preview = ['pixi-build']"#, /// Test adding a git dependency using ssh url #[tokio::test] async fn add_plain_ssh_url() { - let pixi = PixiControl::from_manifest(&format!( + let pixi = PixiControl::from_manifest( r#" [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] platforms = ["{platform}"] preview = ['pixi-build']"#, - platform = Platform::current(), - )) + ) .unwrap(); // Add a package @@ -819,7 +810,7 @@ preview = ['pixi-build']"#, /// Test adding a git dependency using ssh url #[tokio::test] async fn add_pypi_git() { - let pixi = PixiControl::from_manifest(&format!( + let pixi = PixiControl::from_manifest( r#" [project] name = "test-channel-change" @@ -827,8 +818,7 @@ channels = ["https://prefix.dev/conda-forge"] platforms = ["{platform}"] "#, - platform = Platform::current(), - )) + ) .unwrap(); // Add a package @@ -842,7 +832,6 @@ platforms = ["{platform}"] // Check the manifest itself insta::with_settings!({filters => vec![ (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), - (&format!("{}", Platform::current()), "[CURRENT_PLATFORM]") ]}, { insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); }); diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap index 64e822491..271c3e0df 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps-2.snap @@ -5,7 +5,7 @@ expression: pixi.project().unwrap().manifest().source.to_string() [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["osx-arm64"] +platforms = ["linux-64"] preview = ['pixi-build'] [dependencies] diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap index e3cb6c832..53afa9d14 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps.snap @@ -1,7 +1,6 @@ --- source: tests/integration_rust/add_tests.rs expression: lock.render_to_string().unwrap() -snapshot_kind: text --- version: 6 environments: @@ -9,24 +8,70 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - [CURRENT_PLATFORM]: - - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda + linux-64: + - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&branch=main#[FULL_COMMIT] packages: +- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 + md5: d7c89558ba9fa0495403155b64376d81 + license: None + size: 2562 + timestamp: 1578324546067 +- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + build_number: 16 + sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 + md5: 73aaf86a425cc6e73fcf236a5a46396d + depends: + - _libgcc_mutex 0.1 conda_forge + - libgomp >=7.5.0 + constrains: + - openmp_impl 9999 + license: BSD-3-Clause + license_family: BSD + size: 23621 + timestamp: 1650670423406 - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&branch=main#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: [CURRENT_PLATFORM] + subdir: linux-64 depends: - - libcxx >=19 + - libstdcxx >=14 + - libgcc >=14 channel: null -- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec - md5: ce5252d8db110cdb4ae4173d0a63c7c5 +- conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + sha256: 53eb8a79365e58849e7b1a068d31f4f9e718dc938d6f2c03e960345739a03569 + md5: 3cb76c3f10d3bc7f1105b2fc9db984df + depends: + - _libgcc_mutex 0.1 conda_forge + - _openmp_mutex >=4.5 + constrains: + - libgomp 14.2.0 h77fa898_1 + - libgcc-ng ==14.2.0=*_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 848745 + timestamp: 1729027721139 +- conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + sha256: 1911c29975ec99b6b906904040c855772ccb265a1c79d5d75c8ceec4ed89cd63 + md5: cc3573974587f12dda90d96e3e55a702 + depends: + - _libgcc_mutex 0.1 conda_forge + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 460992 + timestamp: 1729027639220 +- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda + sha256: 4661af0eb9bdcbb5fb33e5d0023b001ad4be828fccdcc56500059d56f9869462 + md5: 234a5554c53625688d51062645337328 depends: - - __osx >=11.0 - license: Apache-2.0 WITH LLVM-exception - license_family: Apache - size: 520992 - timestamp: 1734494699681 + - libgcc 14.2.0 h77fa898_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 3893695 + timestamp: 1729027746910 diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap index 36c6fd595..cfc046aad 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds.snap @@ -1,7 +1,6 @@ --- source: tests/integration_rust/add_tests.rs expression: lock.render_to_string().unwrap() -snapshot_kind: text --- version: 6 environments: @@ -9,24 +8,70 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - [CURRENT_PLATFORM]: - - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda + linux-64: + - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples.git?subdirectory=boost-check&branch=main#[FULL_COMMIT] packages: +- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 + md5: d7c89558ba9fa0495403155b64376d81 + license: None + size: 2562 + timestamp: 1578324546067 +- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + build_number: 16 + sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 + md5: 73aaf86a425cc6e73fcf236a5a46396d + depends: + - _libgcc_mutex 0.1 conda_forge + - libgomp >=7.5.0 + constrains: + - openmp_impl 9999 + license: BSD-3-Clause + license_family: BSD + size: 23621 + timestamp: 1650670423406 - conda: git+https://github.com/wolfv/pixi-build-examples.git?subdirectory=boost-check&branch=main#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: [CURRENT_PLATFORM] + subdir: linux-64 depends: - - libcxx >=19 + - libstdcxx >=14 + - libgcc >=14 channel: null -- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec - md5: ce5252d8db110cdb4ae4173d0a63c7c5 +- conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + sha256: 53eb8a79365e58849e7b1a068d31f4f9e718dc938d6f2c03e960345739a03569 + md5: 3cb76c3f10d3bc7f1105b2fc9db984df + depends: + - _libgcc_mutex 0.1 conda_forge + - _openmp_mutex >=4.5 + constrains: + - libgomp 14.2.0 h77fa898_1 + - libgcc-ng ==14.2.0=*_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 848745 + timestamp: 1729027721139 +- conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + sha256: 1911c29975ec99b6b906904040c855772ccb265a1c79d5d75c8ceec4ed89cd63 + md5: cc3573974587f12dda90d96e3e55a702 + depends: + - _libgcc_mutex 0.1 conda_forge + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 460992 + timestamp: 1729027639220 +- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda + sha256: 4661af0eb9bdcbb5fb33e5d0023b001ad4be828fccdcc56500059d56f9869462 + md5: 234a5554c53625688d51062645337328 depends: - - __osx >=11.0 - license: Apache-2.0 WITH LLVM-exception - license_family: Apache - size: 520992 - timestamp: 1734494699681 + - libgcc 14.2.0 h77fa898_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 3893695 + timestamp: 1729027746910 diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap index 1ebf46cc2..88a089276 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit.snap @@ -8,24 +8,70 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - [CURRENT_PLATFORM]: - - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda + linux-64: + - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&rev=9de9e1b#[FULL_COMMIT] packages: +- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 + md5: d7c89558ba9fa0495403155b64376d81 + license: None + size: 2562 + timestamp: 1578324546067 +- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + build_number: 16 + sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 + md5: 73aaf86a425cc6e73fcf236a5a46396d + depends: + - _libgcc_mutex 0.1 conda_forge + - libgomp >=7.5.0 + constrains: + - openmp_impl 9999 + license: BSD-3-Clause + license_family: BSD + size: 23621 + timestamp: 1650670423406 - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&rev=9de9e1b#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: [CURRENT_PLATFORM] + subdir: linux-64 depends: - - libcxx >=19 + - libstdcxx >=14 + - libgcc >=14 channel: null -- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec - md5: ce5252d8db110cdb4ae4173d0a63c7c5 +- conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + sha256: 53eb8a79365e58849e7b1a068d31f4f9e718dc938d6f2c03e960345739a03569 + md5: 3cb76c3f10d3bc7f1105b2fc9db984df + depends: + - _libgcc_mutex 0.1 conda_forge + - _openmp_mutex >=4.5 + constrains: + - libgomp 14.2.0 h77fa898_1 + - libgcc-ng ==14.2.0=*_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 848745 + timestamp: 1729027721139 +- conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + sha256: 1911c29975ec99b6b906904040c855772ccb265a1c79d5d75c8ceec4ed89cd63 + md5: cc3573974587f12dda90d96e3e55a702 + depends: + - _libgcc_mutex 0.1 conda_forge + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 460992 + timestamp: 1729027639220 +- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda + sha256: 4661af0eb9bdcbb5fb33e5d0023b001ad4be828fccdcc56500059d56f9869462 + md5: 234a5554c53625688d51062645337328 depends: - - __osx >=11.0 - license: Apache-2.0 WITH LLVM-exception - license_family: Apache - size: 520992 - timestamp: 1734494699681 + - libgcc 14.2.0 h77fa898_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 3893695 + timestamp: 1729027746910 diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap index 95769e949..640431043 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag.snap @@ -8,24 +8,70 @@ environments: channels: - url: https://prefix.dev/conda-forge/ packages: - [CURRENT_PLATFORM]: - - conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda + linux-64: + - conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + - conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + - conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&tag=v0.1.0#[FULL_COMMIT] packages: +- conda: https://prefix.dev/conda-forge/linux-64/_libgcc_mutex-0.1-conda_forge.tar.bz2 + sha256: fe51de6107f9edc7aa4f786a70f4a883943bc9d39b3bb7307c04c41410990726 + md5: d7c89558ba9fa0495403155b64376d81 + license: None + size: 2562 + timestamp: 1578324546067 +- conda: https://prefix.dev/conda-forge/linux-64/_openmp_mutex-4.5-2_gnu.tar.bz2 + build_number: 16 + sha256: fbe2c5e56a653bebb982eda4876a9178aedfc2b545f25d0ce9c4c0b508253d22 + md5: 73aaf86a425cc6e73fcf236a5a46396d + depends: + - _libgcc_mutex 0.1 conda_forge + - libgomp >=7.5.0 + constrains: + - openmp_impl 9999 + license: BSD-3-Clause + license_family: BSD + size: 23621 + timestamp: 1650670423406 - conda: git+https://github.com/wolfv/pixi-build-examples?subdirectory=boost-check&tag=v0.1.0#[FULL_COMMIT] name: boost-check version: 0.1.0 build: hbf21a9e_0 - subdir: [CURRENT_PLATFORM] + subdir: linux-64 depends: - - libcxx >=19 + - libstdcxx >=14 + - libgcc >=14 channel: null -- conda: https://prefix.dev/conda-forge/[CURRENT_PLATFORM]/libcxx-19.1.6-ha82da77_1.conda - sha256: 2b2443404503cd862385fd2f2a2c73f9624686fd1e5a45050b4034cfc06904ec - md5: ce5252d8db110cdb4ae4173d0a63c7c5 +- conda: https://prefix.dev/conda-forge/linux-64/libgcc-14.2.0-h77fa898_1.conda + sha256: 53eb8a79365e58849e7b1a068d31f4f9e718dc938d6f2c03e960345739a03569 + md5: 3cb76c3f10d3bc7f1105b2fc9db984df + depends: + - _libgcc_mutex 0.1 conda_forge + - _openmp_mutex >=4.5 + constrains: + - libgomp 14.2.0 h77fa898_1 + - libgcc-ng ==14.2.0=*_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 848745 + timestamp: 1729027721139 +- conda: https://prefix.dev/conda-forge/linux-64/libgomp-14.2.0-h77fa898_1.conda + sha256: 1911c29975ec99b6b906904040c855772ccb265a1c79d5d75c8ceec4ed89cd63 + md5: cc3573974587f12dda90d96e3e55a702 + depends: + - _libgcc_mutex 0.1 conda_forge + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 460992 + timestamp: 1729027639220 +- conda: https://prefix.dev/conda-forge/linux-64/libstdcxx-14.2.0-hc0a3c3a_1.conda + sha256: 4661af0eb9bdcbb5fb33e5d0023b001ad4be828fccdcc56500059d56f9869462 + md5: 234a5554c53625688d51062645337328 depends: - - __osx >=11.0 - license: Apache-2.0 WITH LLVM-exception - license_family: Apache - size: 520992 - timestamp: 1734494699681 + - libgcc 14.2.0 h77fa898_1 + license: GPL-3.0-only WITH GCC-exception-3.1 + license_family: GPL + size: 3893695 + timestamp: 1729027746910 From 7afa629cdd53242923bb9055ab79ae0164c083cc Mon Sep 17 00:00:00 2001 From: nichmor Date: Thu, 9 Jan 2025 18:23:23 +0200 Subject: [PATCH 13/20] misc: update snapshots --- tests/integration_rust/add_tests.rs | 4 ++-- ...ntegration_rust__add_tests__add_git_deps_with_creds-2.snap | 2 +- ...ation_rust__add_tests__add_git_with_specific_commit-2.snap | 2 +- .../integration_rust__add_tests__add_git_with_tag-2.snap | 2 +- .../integration_rust__add_tests__add_plain_ssh_url.snap | 2 +- .../snapshots/integration_rust__add_tests__add_pypi_git.snap | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index de7a39d51..149e72d51 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -791,7 +791,7 @@ async fn add_plain_ssh_url() { [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["{platform}"] +platforms = ["linux-64"] preview = ['pixi-build']"#, ) .unwrap(); @@ -815,7 +815,7 @@ async fn add_pypi_git() { [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["{platform}"] +platforms = ["linux-64"] "#, ) diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap index 86e9b5b82..85ccb9b4c 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_deps_with_creds-2.snap @@ -5,7 +5,7 @@ expression: pixi.project().unwrap().manifest().source.to_string() [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["osx-arm64"] +platforms = ["linux-64"] preview = ['pixi-build'] [dependencies] diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap index ead53e0e0..7909ce25d 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_specific_commit-2.snap @@ -5,7 +5,7 @@ expression: pixi.project().unwrap().manifest().source.to_string() [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["osx-arm64"] +platforms = ["linux-64"] preview = ['pixi-build'] [dependencies] diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap index f27d7ec15..db0642e5b 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_git_with_tag-2.snap @@ -5,7 +5,7 @@ expression: pixi.project().unwrap().manifest().source.to_string() [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["osx-arm64"] +platforms = ["linux-64"] preview = ['pixi-build'] [dependencies] diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap index 5cbc4135d..1b6285116 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_plain_ssh_url.snap @@ -5,7 +5,7 @@ expression: pixi.project().unwrap().manifest().source.to_string() [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["osx-arm64"] +platforms = ["linux-64"] preview = ['pixi-build'] [dependencies] diff --git a/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap b/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap index f3eaee489..d0e6eff69 100644 --- a/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap +++ b/tests/integration_rust/snapshots/integration_rust__add_tests__add_pypi_git.snap @@ -5,7 +5,7 @@ expression: pixi.project().unwrap().manifest().source.to_string() [project] name = "test-channel-change" channels = ["https://prefix.dev/conda-forge"] -platforms = ["[CURRENT_PLATFORM]"] +platforms = ["linux-64"] [pypi-dependencies] boltons = { git = "https://github.com/mahmoud/boltons.git" } From b355b86ed5b10fbb6e14be93e4429827865efc87 Mon Sep 17 00:00:00 2001 From: nichmor Date: Fri, 10 Jan 2025 11:06:50 +0200 Subject: [PATCH 14/20] misc: configure git user --- .github/workflows/ci.yml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 8b958004b..18cb5d20d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,6 +198,10 @@ jobs: runs-on: 16core_windows_latest_runner steps: - uses: actions/checkout@v4 + - name: Configure Git user + run: | + git config --local user.email "github-actions[bot]@users.noreply.github.com" + git config --local user.name "github-actions[bot]" - name: Create Dev Drive using ReFS run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1 - uses: prefix-dev/setup-pixi@v0.8.1 From e0d46198ac36e90a7d2e091ad40c678e0774f45f Mon Sep 17 00:00:00 2001 From: nichmor Date: Fri, 10 Jan 2025 11:23:51 +0200 Subject: [PATCH 15/20] misc: use global configuration --- .github/workflows/ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 18cb5d20d..1a24ec3fe 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -200,8 +200,8 @@ jobs: - uses: actions/checkout@v4 - name: Configure Git user run: | - git config --local user.email "github-actions[bot]@users.noreply.github.com" - git config --local user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git config --global user.name "github-actions[bot]" - name: Create Dev Drive using ReFS run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1 - uses: prefix-dev/setup-pixi@v0.8.1 From 13b94fadbbcede93c8cf979e25778c3c3a9e887d Mon Sep 17 00:00:00 2001 From: nichmor Date: Fri, 10 Jan 2025 11:35:03 +0200 Subject: [PATCH 16/20] misc: add git user configuraiton for tests --- .github/workflows/ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1a24ec3fe..d8d205d73 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,7 +198,7 @@ jobs: runs-on: 16core_windows_latest_runner steps: - uses: actions/checkout@v4 - - name: Configure Git user + - name: Configure Git user that will be used in the tests run: | git config --global user.email "github-actions[bot]@users.noreply.github.com" git config --global user.name "github-actions[bot]" From c90d7d3a2d255c607eb0af0659e767c20c3621f5 Mon Sep 17 00:00:00 2001 From: nichmor Date: Fri, 10 Jan 2025 11:45:30 +0200 Subject: [PATCH 17/20] misc: comment out cred tests --- tests/integration_rust/add_tests.rs | 70 ++++++++++++++--------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index 149e72d51..87df10c0b 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -681,41 +681,41 @@ preview = ['pixi-build'] insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); } -/// Test adding git dependencies with credentials -#[tokio::test] -async fn add_git_deps_with_creds() { - let pixi = PixiControl::from_manifest( - r#" -[project] -name = "test-channel-change" -channels = ["https://prefix.dev/conda-forge"] -platforms = ["linux-64"] -preview = ['pixi-build'] -"#, - ) - .unwrap(); - - // Add a package - // we want to make sure that the credentials are not exposed in the lock file - pixi.add("boost-check") - .with_git_url( - Url::parse("https://user:token123@github.com/wolfv/pixi-build-examples.git").unwrap(), - ) - .with_git_rev(GitRev::new().with_branch("main".to_string())) - .with_git_subdir("boost-check".to_string()) - .await - .unwrap(); - - let lock = pixi.lock_file().await.unwrap(); - insta::with_settings!({filters => vec![ - (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), - ]}, { - insta::assert_snapshot!(lock.render_to_string().unwrap()); - }); - - // Check the manifest itself - insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); -} +// /// Test adding git dependencies with credentials +// #[tokio::test] +// async fn add_git_deps_with_creds() { +// let pixi = PixiControl::from_manifest( +// r#" +// [project] +// name = "test-channel-change" +// channels = ["https://prefix.dev/conda-forge"] +// platforms = ["linux-64"] +// preview = ['pixi-build'] +// "#, +// ) +// .unwrap(); + +// // Add a package +// // we want to make sure that the credentials are not exposed in the lock file +// pixi.add("boost-check") +// .with_git_url( +// Url::parse("https://user:token123@github.com/wolfv/pixi-build-examples.git").unwrap(), +// ) +// .with_git_rev(GitRev::new().with_branch("main".to_string())) +// .with_git_subdir("boost-check".to_string()) +// .await +// .unwrap(); + +// let lock = pixi.lock_file().await.unwrap(); +// insta::with_settings!({filters => vec![ +// (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), +// ]}, { +// insta::assert_snapshot!(lock.render_to_string().unwrap()); +// }); + +// // Check the manifest itself +// insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +// } /// Test adding a git dependency with a specific commit #[tokio::test] From 3f6077fee59f28895add890472bedc19665ff35f Mon Sep 17 00:00:00 2001 From: nichmor Date: Fri, 10 Jan 2025 11:57:29 +0200 Subject: [PATCH 18/20] misc: do not update lockfileupdate on lock --- tests/integration_rust/add_tests.rs | 71 +++++++++++++++-------------- 1 file changed, 36 insertions(+), 35 deletions(-) diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index 87df10c0b..4f688feda 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -681,41 +681,42 @@ preview = ['pixi-build'] insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); } -// /// Test adding git dependencies with credentials -// #[tokio::test] -// async fn add_git_deps_with_creds() { -// let pixi = PixiControl::from_manifest( -// r#" -// [project] -// name = "test-channel-change" -// channels = ["https://prefix.dev/conda-forge"] -// platforms = ["linux-64"] -// preview = ['pixi-build'] -// "#, -// ) -// .unwrap(); - -// // Add a package -// // we want to make sure that the credentials are not exposed in the lock file -// pixi.add("boost-check") -// .with_git_url( -// Url::parse("https://user:token123@github.com/wolfv/pixi-build-examples.git").unwrap(), -// ) -// .with_git_rev(GitRev::new().with_branch("main".to_string())) -// .with_git_subdir("boost-check".to_string()) -// .await -// .unwrap(); - -// let lock = pixi.lock_file().await.unwrap(); -// insta::with_settings!({filters => vec![ -// (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), -// ]}, { -// insta::assert_snapshot!(lock.render_to_string().unwrap()); -// }); - -// // Check the manifest itself -// insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); -// } +/// Test adding git dependencies with credentials +#[tokio::test] +async fn add_git_deps_with_creds() { + let pixi = PixiControl::from_manifest( + r#" +[project] +name = "test-channel-change" +channels = ["https://prefix.dev/conda-forge"] +platforms = ["linux-64"] +preview = ['pixi-build'] +"#, + ) + .unwrap(); + + // Add a package + // we want to make sure that the credentials are not exposed in the lock file + pixi.add("boost-check") + .with_git_url( + Url::parse("https://user:token123@github.com/wolfv/pixi-build-examples.git").unwrap(), + ) + .with_git_rev(GitRev::new().with_branch("main".to_string())) + .with_git_subdir("boost-check".to_string()) + .with_no_lockfile_update(true) + .await + .unwrap(); + + // let lock = pixi.lock_file().await.unwrap(); + // insta::with_settings!({filters => vec![ + // (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + // ]}, { + // insta::assert_snapshot!(lock.render_to_string().unwrap()); + // }); + + // Check the manifest itself + insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); +} /// Test adding a git dependency with a specific commit #[tokio::test] From 1d88d5da55b247dd099ebe4949d0438ca977c1f6 Mon Sep 17 00:00:00 2001 From: nichmor Date: Fri, 10 Jan 2025 12:12:56 +0200 Subject: [PATCH 19/20] misc: enable snapshot back --- tests/integration_rust/add_tests.rs | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/tests/integration_rust/add_tests.rs b/tests/integration_rust/add_tests.rs index 4f688feda..d5ae2ab45 100644 --- a/tests/integration_rust/add_tests.rs +++ b/tests/integration_rust/add_tests.rs @@ -682,6 +682,9 @@ preview = ['pixi-build'] } /// Test adding git dependencies with credentials +/// This tests is skipped on windows because it spawns a credential helper +/// during the CI run +#[cfg(not(windows))] #[tokio::test] async fn add_git_deps_with_creds() { let pixi = PixiControl::from_manifest( @@ -703,16 +706,15 @@ preview = ['pixi-build'] ) .with_git_rev(GitRev::new().with_branch("main".to_string())) .with_git_subdir("boost-check".to_string()) - .with_no_lockfile_update(true) .await .unwrap(); - // let lock = pixi.lock_file().await.unwrap(); - // insta::with_settings!({filters => vec![ - // (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), - // ]}, { - // insta::assert_snapshot!(lock.render_to_string().unwrap()); - // }); + let lock = pixi.lock_file().await.unwrap(); + insta::with_settings!({filters => vec![ + (r"#([a-f0-9]+)", "#[FULL_COMMIT]"), + ]}, { + insta::assert_snapshot!(lock.render_to_string().unwrap()); + }); // Check the manifest itself insta::assert_snapshot!(pixi.project().unwrap().manifest().source.to_string()); From 373a1e91197058c9e0e896245f0f0032e752fec0 Mon Sep 17 00:00:00 2001 From: nichmor Date: Fri, 10 Jan 2025 12:13:56 +0200 Subject: [PATCH 20/20] misc: remove git configuration --- .github/workflows/ci.yml | 4 ---- 1 file changed, 4 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d8d205d73..8b958004b 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -198,10 +198,6 @@ jobs: runs-on: 16core_windows_latest_runner steps: - uses: actions/checkout@v4 - - name: Configure Git user that will be used in the tests - run: | - git config --global user.email "github-actions[bot]@users.noreply.github.com" - git config --global user.name "github-actions[bot]" - name: Create Dev Drive using ReFS run: ${{ github.workspace }}/.github/workflows/setup-dev-drive.ps1 - uses: prefix-dev/setup-pixi@v0.8.1