From f33bee8e9ed5f0cd51efc4b39f88af44c5a0e5a4 Mon Sep 17 00:00:00 2001 From: Hofer-Julian <30049909+Hofer-Julian@users.noreply.github.com> Date: Fri, 25 Oct 2024 11:24:27 +0200 Subject: [PATCH] ci: Use cargo-nextest from within a pixi task (#2305) Also remove `test_environment_json` since it doesn't work when run from within pixi --- .github/workflows/rust.yml | 32 +++------------- .pre-commit-config.yaml | 6 +++ CONTRIBUTING.md | 2 +- crates/pixi_utils/Cargo.toml | 2 +- pixi.lock | 72 ++++++++++++++++++++++++++++++++++++ pixi.toml | 8 +++- scripts/check-openssl.py | 39 +++++++++++++++++++ src/cli/shell_hook.rs | 12 ------ 8 files changed, 131 insertions(+), 42 deletions(-) create mode 100644 scripts/check-openssl.py diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 89f1ed952..6b5c24131 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -128,35 +128,15 @@ jobs: steps: - uses: actions/checkout@v4 - - uses: taiki-e/setup-cross-toolchain-action@v1 + - uses: prefix-dev/setup-pixi@v0.8.1 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 }} diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 2420cfe3b..050b2f58b 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 028c7c001..8c671fd6a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -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 ``` diff --git a/crates/pixi_utils/Cargo.toml b/crates/pixi_utils/Cargo.toml index ea3feb0f9..8144cffb1 100644 --- a/crates/pixi_utils/Cargo.toml +++ b/crates/pixi_utils/Cargo.toml @@ -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", diff --git a/pixi.lock b/pixi.lock index 552a9f3b5..761958890 100644 --- a/pixi.lock +++ b/pixi.lock @@ -18,6 +18,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/linux-64/c-ares-1.33.1-heb4867d_0.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/c-compiler-1.7.0-hd590300_1.conda - conda: https://conda.anaconda.org/conda-forge/linux-64/ca-certificates-2024.8.30-hbcca054_0.conda + - conda: https://conda.anaconda.org/conda-forge/linux-64/cargo-nextest-0.9.78-h6c30b3d_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/certifi-2024.7.4-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/cffconvert-2.0.0-pyhd8ed1ab_0.tar.bz2 - conda: https://conda.anaconda.org/conda-forge/linux-64/cffi-1.17.0-py312h06ac9bb_1.conda @@ -147,6 +148,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-64/bzip2-1.0.8-hfdf4475_7.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/c-ares-1.33.1-h44e7173_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-64/ca-certificates-2024.8.30-h8857fd0_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-64/cargo-nextest-0.9.78-h32f0265_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/certifi-2024.7.4-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/cffconvert-2.0.0-pyhd8ed1ab_0.tar.bz2 - conda: https://conda.anaconda.org/conda-forge/osx-64/cffi-1.17.0-py312hf857d28_1.conda @@ -239,6 +241,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/osx-arm64/bzip2-1.0.8-h99b78c6_7.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/c-ares-1.33.1-hd74edd7_0.conda - conda: https://conda.anaconda.org/conda-forge/osx-arm64/ca-certificates-2024.8.30-hf0a4a13_0.conda + - conda: https://conda.anaconda.org/conda-forge/osx-arm64/cargo-nextest-0.9.78-h27c7404_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/certifi-2024.7.4-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/cffconvert-2.0.0-pyhd8ed1ab_0.tar.bz2 - conda: https://conda.anaconda.org/conda-forge/osx-arm64/cffi-1.17.0-py312h0fad829_1.conda @@ -331,6 +334,7 @@ environments: - conda: https://conda.anaconda.org/conda-forge/win-64/brotli-python-1.1.0-py312h53d5487_1.conda - conda: https://conda.anaconda.org/conda-forge/win-64/bzip2-1.0.8-h2466b09_7.conda - conda: https://conda.anaconda.org/conda-forge/win-64/ca-certificates-2024.8.30-h56e8100_0.conda + - conda: https://conda.anaconda.org/conda-forge/win-64/cargo-nextest-0.9.78-ha073cba_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/certifi-2024.7.4-pyhd8ed1ab_0.conda - conda: https://conda.anaconda.org/conda-forge/noarch/cffconvert-2.0.0-pyhd8ed1ab_0.tar.bz2 - conda: https://conda.anaconda.org/conda-forge/win-64/cffi-1.17.0-py312h4389bb4_1.conda @@ -1972,6 +1976,74 @@ packages: license_family: LGPL size: 43857 timestamp: 1691391975709 +- kind: conda + name: cargo-nextest + version: 0.9.78 + build: h27c7404_0 + subdir: osx-arm64 + url: https://conda.anaconda.org/conda-forge/osx-arm64/cargo-nextest-0.9.78-h27c7404_0.conda + sha256: 0401356c5ea47e9351b56e3824863f3415e2401b9d59940620713c1ece2a4339 + md5: f49aafff221daaf9bfc7ca8a09485ff1 + depends: + - __osx >=11.0 + constrains: + - __osx >=11.0 + license: MIT + license_family: MIT + size: 4384820 + timestamp: 1728918162464 +- kind: conda + name: cargo-nextest + version: 0.9.78 + build: h32f0265_0 + subdir: osx-64 + url: https://conda.anaconda.org/conda-forge/osx-64/cargo-nextest-0.9.78-h32f0265_0.conda + sha256: 0df943c68d72828527c4a8a0cf00b54a4f1c58006195812610e6149b3c40fa9b + md5: ce7b80bd21e3e9aa35e844f6957360f3 + depends: + - __osx >=10.13 + constrains: + - __osx >=10.13 + license: MIT + license_family: MIT + size: 4717530 + timestamp: 1728918242982 +- kind: conda + name: cargo-nextest + version: 0.9.78 + build: h6c30b3d_0 + subdir: linux-64 + url: https://conda.anaconda.org/conda-forge/linux-64/cargo-nextest-0.9.78-h6c30b3d_0.conda + sha256: 9e232557caeb8bf4e34c5d0175b23ed1a129df78c6aad01bb4792e532b5f5201 + md5: 013179d01cba10a39c1badaace213143 + depends: + - libgcc >=13 + - __glibc >=2.17,<3.0.a0 + constrains: + - __glibc >=2.17 + license: MIT + license_family: MIT + size: 4765005 + timestamp: 1728918162264 +- kind: conda + name: cargo-nextest + version: 0.9.78 + build: ha073cba_0 + subdir: win-64 + url: https://conda.anaconda.org/conda-forge/win-64/cargo-nextest-0.9.78-ha073cba_0.conda + sha256: a1759b1734162ec7bf225742fefee8d4b9db39215e0d34be9302a037299aa4ae + md5: 0d404f06dbc7968fbf247d7cc9390744 + depends: + - vc >=14.2,<15 + - vc14_runtime >=14.29.30139 + - ucrt >=10.0.20348.0 + - vc >=14.2,<15 + - vc14_runtime >=14.29.30139 + - ucrt >=10.0.20348.0 + license: MIT + license_family: MIT + size: 4538985 + timestamp: 1728918279376 - kind: conda name: certifi version: 2024.7.4 diff --git a/pixi.toml b/pixi.toml index 4b2296576..6fcf40810 100644 --- a/pixi.toml +++ b/pixi.toml @@ -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" @@ -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" @@ -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" diff --git a/scripts/check-openssl.py b/scripts/check-openssl.py new file mode 100644 index 000000000..e89fe3855 --- /dev/null +++ b/scripts/check-openssl.py @@ -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() diff --git a/src/cli/shell_hook.rs b/src/cli/shell_hook.rs index 96ae35699..5da49c455 100644 --- a/src/cli/shell_hook.rs +++ b/src/cli/shell_hook.rs @@ -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}\":"))); - } }