Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: docs manifest tests #1879

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions crates/pixi_manifest/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ rattler_virtual_packages = { workspace = true }

# TODO: Remove these dependencies
console = { workspace = true }
glob = "0.3.1"
miette = { workspace = true }

[dev-dependencies]
Expand Down
19 changes: 19 additions & 0 deletions crates/pixi_manifest/src/manifest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -660,6 +660,7 @@ mod tests {

use super::*;
use crate::{channel::PrioritizedChannel, manifest::Manifest};
use glob::glob;

const PROJECT_BOILERPLATE: &str = r#"
[project]
Expand Down Expand Up @@ -2142,4 +2143,22 @@ bar = "*"
Caused by: Found invalid characters for git revision 'main', branches and tags are not supported yet
"###);
}

#[test]
fn test_docs_pixi_manifests() {
let location = "../../docs/source_files/pixi_tomls/*.toml";

// Check that the glob is not empty
assert!(glob(location).unwrap().count() > 0);

for entry in glob(location).unwrap() {
Hofer-Julian marked this conversation as resolved.
Show resolved Hide resolved
match entry {
Ok(path) => {
let contents = std::fs::read_to_string(path).unwrap();
let _manifest = Manifest::from_str(Path::new("pixi.toml"), contents).unwrap();
Hofer-Julian marked this conversation as resolved.
Show resolved Hide resolved
}
Err(e) => println!("{:?}", e),
}
}
}
}
29 changes: 13 additions & 16 deletions docs/reference/project_configuration.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,18 +20,15 @@ For more technical documentation check pixi on [crates.io](https://docs.rs/pixi/
The minimally required information in the `project` table is:

```toml
[project]
name = "project-name"
channels = ["conda-forge"]
platforms = ["linux-64"]
--8<-- "docs/source_files/pixi_tomls/simple_pixi.toml:project"
```

### `name`

The name of the project.

```toml
name = "project-name"
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_name"
```

### `channels`
Expand All @@ -40,19 +37,19 @@ This is a list that defines the channels used to fetch the packages from.
If you want to use channels hosted on `anaconda.org` you only need to use the name of the channel directly.

```toml
channels = ["conda-forge", "robostack", "bioconda", "nvidia", "pytorch"]
--8<-- "docs/source_files/pixi_tomls/lots_of_channels.toml:project_channels_long"
```

Channels situated on the file system are also supported with **absolute** file paths:

```toml
channels = ["conda-forge", "file:///home/user/staged-recipes/build_artifacts"]
--8<-- "docs/source_files/pixi_tomls/lots_of_channels.toml:project_channels_path"
```

To access private or public channels on [prefix.dev](https://prefix.dev/channels) or [Quetz](https://github.com/mamba-org/quetz) use the url including the hostname:

```toml
channels = ["conda-forge", "https://repo.prefix.dev/channel-name"]
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_channels"
```

### `platforms`
Expand All @@ -61,7 +58,7 @@ Defines the list of platforms that the project supports.
Pixi solves the dependencies for all these platforms and puts them in the lock file (`pixi.lock`).

```toml
platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_platforms"
```

The available platforms are listed here: [link](https://docs.rs/rattler_conda_types/latest/rattler_conda_types/enum.Platform.html)
Expand All @@ -79,31 +76,31 @@ This should be a valid version based on the conda Version Spec.
See the [version documentation](https://docs.rs/rattler_conda_types/latest/rattler_conda_types/struct.Version.html), for an explanation of what is allowed in a Version Spec.

```toml
version = "1.2.3"
-8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_version"
```

### `authors` (optional)

This is a list of authors of the project.

```toml
authors = ["John Doe <[email protected]>", "Marie Curie <[email protected]>"]
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_authors"
```

### `description` (optional)

This should contain a short description of the project.

```toml
description = "A simple description"
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_description"
```

### `license` (optional)

The license as a valid [SPDX](https://spdx.org/licenses/) string (e.g. MIT AND Apache-2.0)

```toml
license = "MIT"
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_license"
```

### `license-file` (optional)
Expand All @@ -127,23 +124,23 @@ readme = "README.md"
URL of the project homepage.

```toml
homepage = "https://pixi.sh"
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_homepage"
```

### `repository` (optional)

URL of the project source repository.

```toml
repository = "https://github.com/prefix-dev/pixi"
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_repository"
```

### `documentation` (optional)

URL of the project documentation.

```toml
documentation = "https://pixi.sh"
--8<-- "docs/source_files/pixi_tomls/main_pixi.toml:project_documentation"
```

### `conda-pypi-map` (optional)
Expand Down
12 changes: 12 additions & 0 deletions docs/source_files/pixi_tomls/lots_of_channels.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
[project]
name = "lots_of_channels"
platforms = []
# --8<-- [start:project_channels_long]
channels = ["conda-forge", "robostack", "bioconda", "nvidia", "pytorch"]
# --8<-- [end:project_channels_long]


[feature.path_channels]
# --8<-- [start:project_channels_path]
channels = ["conda-forge", "file:///home/user/staged-recipes/build_artifacts"]
# --8<-- [end:project_channels_path]
41 changes: 41 additions & 0 deletions docs/source_files/pixi_tomls/main_pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
[project]
# --8<-- [start:project_name]
name = "project-name"
# --8<-- [end:project_name]
# --8<-- [start:project_channels]
channels = ["conda-forge", "https://repo.prefix.dev/channel-name"]
# --8<-- [end:project_channels]
# --8<-- [start:project_platforms]
platforms = ["win-64", "linux-64", "osx-64", "osx-arm64"]
# --8<-- [end:project_platforms]
# --8<-- [start:project_version]
version = "1.2.3"
# --8<-- [end:project_version]
# --8<-- [start:project_authors]
authors = ["John Doe <[email protected]>", "Marie Curie <[email protected]>"]
# --8<-- [end:project_authors]
# --8<-- [start:project_description]
description = "A simple description"
# --8<-- [end:project_description]
# --8<-- [start:project_license]
license = "MIT"
# --8<-- [end:project_license]

# Untestable because it's a path to a must have file.
# --8<-- [start:project_license_file]
# license-file = "LICENSE.md"
# --8<-- [end:project_license_file]
# --8<-- [start:project_readme]
# readme = "README.md"
# --8<-- [end:project_readme]


# --8<-- [start:project_homepage]
homepage = "https://pixi.sh"
# --8<-- [end:project_homepage]
# --8<-- [start:project_repository]
repository = "https://github.com/prefix-dev/pixi"
# --8<-- [end:project_repository]
# --8<-- [start:project_documentation]
documentation = "https://pixi.sh"
# --8<-- [end:project_documentation]
7 changes: 7 additions & 0 deletions docs/source_files/pixi_tomls/simple_pixi.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@

# --8<-- [start:project]
[project]
channels = ["conda-forge"]
name = "project-name"
platforms = ["linux-64"]
# --8<-- [end:project]
Loading
Loading