diff --git a/.github/workflows/test_downstream.yml b/.github/workflows/test_downstream.yml index e74e4e2be..a0bf564f9 100644 --- a/.github/workflows/test_downstream.yml +++ b/.github/workflows/test_downstream.yml @@ -203,3 +203,71 @@ jobs: run: ${{ env.TARGET_RELEASE }}/pixi${{ matrix.arch.extension }} run typecheck-integration - name: Run integration tests run: ${{ env.TARGET_RELEASE }}/pixi${{ matrix.arch.extension }} run test-integration-ci + + test-export: + name: ${{ matrix.arch.name }} - Export Tests + runs-on: ${{ matrix.arch.os }} + strategy: + fail-fast: false + matrix: + arch: + # Linux + - { + target: x86_64-unknown-linux-musl, + os: ubuntu-20.04, + name: "Linux", + } + # MacOS + - { target: x86_64-apple-darwin, os: macos-13, name: "MacOS-x86" } + - { target: aarch64-apple-darwin, os: macos-14, name: "MacOS-arm" } # macOS-14 is the ARM chipset + # Windows + - { + target: x86_64-pc-windows-msvc, + os: windows-latest, + extension: .exe, + name: "Windows", + } + steps: + - name: checkout repo + uses: actions/checkout@v4 + - name: setup micromamba + uses: mamba-org/setup-micromamba@v1.8.1 + - name: Download binary from build + uses: actions/download-artifact@v4 + with: + name: pixi-${{ matrix.arch.target }}${{ matrix.arch.extension }} + path: pixi_bin + - name: Debug + run: | + pwd + - name: Setup unix binary, add to github path + if: matrix.arch.name != 'Windows' + run: | + mv pixi_bin/pixi-${{ matrix.arch.target }} pixi_bin/pixi + chmod a+x pixi_bin/pixi + echo "$(pwd)/pixi_bin" >> $GITHUB_PATH + - name: Create Directory and Move Executable + if: matrix.arch.name == 'Windows' && matrix.arch.target == 'x86_64-pc-windows-msvc' + run: | + New-Item -ItemType Directory -Force -Path "D:\.pixi" + Move-Item -Path "pixi_bin/pixi-${{ matrix.arch.target }}${{ matrix.arch.extension }}" -Destination "D:\.pixi\pixi.exe" + shell: pwsh + - name: Add to PATH + if: matrix.arch.name == 'Windows' && matrix.arch.target == 'x86_64-pc-windows-msvc' + run: echo "D:\.pixi" | Out-File -Append -Encoding utf8 -FilePath $env:GITHUB_PATH + shell: pwsh + - name: Verify and Use Executable + if: matrix.arch.name == 'Windows' && matrix.arch.target == 'x86_64-pc-windows-msvc' + run: | + echo "Current PATH: $env:PATH" + pixi --version + shell: pwsh + - name: Help + run: pixi --help + - name: Info + run: pixi info + - name: Install pixi + run: pixi install -v + - name: Test export + shell: bash + run: bash tests/test_export.sh diff --git a/src/cli/project/export/conda_environment.rs b/src/cli/project/export/conda_environment.rs index 56a6d8f0c..4223f49e9 100644 --- a/src/cli/project/export/conda_environment.rs +++ b/src/cli/project/export/conda_environment.rs @@ -17,17 +17,16 @@ use crate::project::Environment; use crate::Project; #[derive(Debug, Parser)] -#[clap(arg_required_else_help = false)] pub struct Args { /// Explicit path to export the environment to pub output_path: Option, - /// The platform to render the environment file for. - /// Defaults to the current platform. + /// The platform to render the environment file for. + /// Defaults to the current platform. #[arg(short, long)] pub platform: Option, - /// The environment to render the environment file for. + /// The environment to render the environment file for. /// Defaults to the default environment. #[arg(short, long)] pub environment: Option, diff --git a/tests/test_export.sh b/tests/test_export.sh new file mode 100644 index 000000000..e466716ef --- /dev/null +++ b/tests/test_export.sh @@ -0,0 +1,45 @@ +# Run from the root of the project using `bash tests/test_export.sh` +set -e +echo "Running test_export.sh" + +echo "Exporting the export test environment" +pixi project export conda-environment --manifest-path src/cli/project/export/test-data/testenv/pixi.toml | tee test-env.yml +echo "Creating the export test environment with micromamba" +micromamba create -y -f test-env.yml -n export-test +micromamba env list +micromamba env remove -y -n export-test + +echo "Exporting an environment.yml with pip extras" +pixi project export conda-environment --manifest-path examples/pypi/pixi.toml | tee test-env-pip-extras.yml +echo "Creating the pip extra test environment with micromamba" +micromamba create -y -f test-env-pip-extras.yml -n export-test-pip-extras +micromamba env list +micromamba env remove -y -n export-test-pip-extras + +echo "Export an environment.yml with editable source dependencies" +pixi project export conda-environment --manifest-path examples/pypi-source-deps/pixi.toml | tee test-env-source-deps.yml +echo "Creating the editable source dependencies test environment with micromamba" +micromamba create -y -f test-env-source-deps.yml -n export-test-source-deps +micromamba env list +micromamba env remove -y -n export-test-source-deps + +echo "Export an environment.yml with custom pip registry" +pixi project export conda-environment --manifest-path examples/pypi-custom-registry/pixi.toml | tee test-env-custom-registry.yml +echo "Creating the custom pip registry test environment with micromamba" +micromamba create -y -f test-env-custom-registry.yml -n export-test-custom-registry +micromamba env list +micromamba env remove -y -n export-test-custom-registry + +echo "Export an environment.yml with pip find links" +pixi project export conda-environment --manifest-path examples/pypi-find-links/pixi.toml | tee test-env-find-links.yml +echo "Creating the pip find links test environment with micromamba" +micromamba create -y -f test-env-find-links.yml -n export-test-find-links +micromamba env list +micromamba env remove -y -n export-test-find-links + +echo "Export an environment.yml from a pyproject.toml that has caused panics" +pixi project export conda-environment --manifest-path examples/docker/pyproject.toml | tee test-env-pyproject-panic.yml +echo "Creating the pyproject.toml panic test environment with micromamba" +micromamba create -y -f test-env-pyproject-panic.yml -n export-test-pyproject-panic +micromamba env list +micromamba env remove -y -n export-test-pyproject-panic