Skip to content

Commit

Permalink
ci: Use cargo-nextest from within a pixi task (prefix-dev#2305)
Browse files Browse the repository at this point in the history
Also remove `test_environment_json` since it doesn't work when run from
within pixi
  • Loading branch information
Hofer-Julian authored Oct 25, 2024
1 parent 5bb65ce commit f33bee8
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 42 deletions.
32 changes: 6 additions & 26 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -128,35 +128,15 @@ jobs:

steps:
- uses: actions/checkout@v4
- uses: taiki-e/setup-cross-toolchain-action@v1
- uses: prefix-dev/setup-[email protected]
with:
target: ${{ matrix.target }}

cache: true
- uses: Swatinem/rust-cache@v2

- name: Show version information (Rust, cargo, GCC)
shell: bash
run: |
gcc --version || true
rustup -V
rustup toolchain list
cargo -V
rustc -V
- name: "Install cargo nextest"
uses: taiki-e/install-action@v2
with:
tool: cargo-nextest

- uses: rui314/setup-mold@v1

- name: "Cargo nextest"
run: >-
cargo nextest run
--workspace
--retries 2
--no-default-features --features rustls-tls --features slow_integration_tests
--status-level skip --failure-output immediate-final --no-fail-fast --final-status-level slow
workspaces: ". -> target-pixi"
key: ${{ hashFiles('pixi.lock') }}
- name: Test pixi
run: pixi run test-workspace

build:
name: Build Binary | ${{ matrix.name }}
Expand Down
6 changes: 6 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,12 @@ repos:
language: system
types_or: [python, pyi]
pass_filenames: false
- id: check-openssl
name: check-openssl
entry: pixi run check-openssl
language: system
types: [file, toml]
pass_filenames: false
# typos
- id: typos
name: typos
Expand Down
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ By contributing to Pixi, you agree that your contributions will be licensed unde
pixi run build
pixi run lint
pixi run test
pixi run test-all
pixi run test-workspace
pixi run install # only works on unix systems as on windows you can't overwrite the binary while it's running
```

Expand Down
2 changes: 1 addition & 1 deletion crates/pixi_utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ repository.workspace = true
version = "0.1.0"

[features]
default = ["native-tls"]
default = ["rustls-tls"]
native-tls = [
"reqwest/native-tls",
"reqwest/native-tls-alpn",
Expand Down
72 changes: 72 additions & 0 deletions pixi.lock

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

8 changes: 6 additions & 2 deletions pixi.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ release = "python scripts/release.py"
run-all-examples = { cmd = "python ./tests/run_all_examples.py --pixi-exec $CARGO_TARGET_DIR/release/pixi", depends-on = [
"build",
] }
test = "cargo test"
test-all = "cargo test --all-features"
test = "cargo nextest run"
test-workspace = """cargo nextest run --workspace --retries 2 --features slow_integration_tests
--status-level skip --failure-output immediate-final --no-fail-fast --final-status-level slow"""


[feature.pytest.dependencies]
filelock = ">=3.16.0,<4"
Expand Down Expand Up @@ -54,6 +56,7 @@ update-integration-test-data = { cmd = "python update-channels.py", cwd = "tests

[feature.dev.dependencies]
# Needed for the citation
cargo-nextest = ">=0.9.78,<0.10"
cffconvert = ">=2.0.0,<2.1"
tbump = ">=6.9.0,<6.10"

Expand All @@ -65,6 +68,7 @@ taplo = ">=0.9.1,<0.10"
typos = ">=1.23.1,<2"

[feature.lint.tasks]
check-openssl = "python scripts/check-openssl.py"
lint = "pre-commit run --all-files --hook-stage=manual"
pre-commit-install = "pre-commit install --install-hooks -t=pre-commit -t=pre-push"
pre-commit-install-minimal = "pre-commit install -t=pre-commit"
Expand Down
39 changes: 39 additions & 0 deletions scripts/check-openssl.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
from enum import StrEnum
import subprocess
import sys


class Colors(StrEnum):
GREEN = "\033[92m"
RED = "\033[91m"
RESET = "\033[0m"


def colored_print(message: str, color: Colors) -> None:
print(f"{color}{message}{Colors.RESET}")


def check_openssl_dependency() -> None:
# Run the cargo tree command
result = subprocess.run(
["cargo", "tree", "-i", "openssl", "--workspace"],
capture_output=True,
text=True,
)

if result.returncode == 0:
colored_print("Error: openssl is part of the dependencies tree", Colors.RED)
print(result.stdout)
sys.exit(1)

# Check if the error message matches the expected message
if "package ID specification `openssl` did not match any packages" in result.stderr:
colored_print("Success: openssl is not part of the dependencies tree.", Colors.GREEN)
else:
colored_print("Error: Unexpected error message.", Colors.RED)
print(result.stderr)
sys.exit(1)


if __name__ == "__main__":
check_openssl_dependency()
12 changes: 0 additions & 12 deletions src/cli/shell_hook.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,16 +185,4 @@ mod tests {
assert!(script.contains(&format!("$env.{path_var_name} = ")));
assert!(script.contains("$env.CONDA_PREFIX = "));
}

#[tokio::test]
async fn test_environment_json() {
let default_shell = rattler_shell::shell::ShellEnum::default();
let path_var_name = default_shell.path_var(&Platform::current());
let project = Project::discover().unwrap();
let environment = project.default_environment();
let json_env = generate_environment_json(&environment).await.unwrap();
assert!(json_env.contains("\"PIXI_ENVIRONMENT_NAME\":\"default\""));
assert!(json_env.contains("\"CONDA_PREFIX\":"));
assert!(json_env.contains(&format!("\"{path_var_name}\":")));
}
}

0 comments on commit f33bee8

Please sign in to comment.