update pixi tests #14
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Test python-setup/pixi | |
| on: | |
| push: | |
| jobs: | |
| test-pixi-basic: | |
| name: Test pixi action - defaults | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create test pyproject.toml | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "test-project" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| numpy = ">=1.26" | |
| [tool.pixi.feature.test.dependencies] | |
| pytest = ">=7.0" | |
| [tool.pixi.environments] | |
| default = ["test"] | |
| EOF | |
| - name: Test pixi setup with defaults | |
| uses: ./actions/python-setup/pixi | |
| id: setup | |
| - name: Verify installation | |
| run: | | |
| echo "Testing pixi command..." | |
| pixi --version | |
| echo "Testing Python..." | |
| python --version | |
| echo "Testing installed packages..." | |
| python -c "import numpy; print(f'NumPy version: {numpy.__version__}')" | |
| python -c "import pytest; print(f'Pytest version: {pytest.__version__}')" | |
| test-pixi-default-environment: | |
| name: Test pixi action - Default environment only | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create test pyproject.toml with default environment | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "test-default-only" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| requests = ">=2.31" | |
| [tool.pixi.environments] | |
| default = [] | |
| EOF | |
| - name: Test pixi action with defaults (should use default environment) | |
| uses: ./actions/python-setup/pixi | |
| # No inputs provided - should use defaults | |
| - name: Verify default environment installation | |
| run: | | |
| python --version | |
| python -c "import requests; print('[OK] Default environment installed')" | |
| pixi info | |
| test-pixi-multiple-environments: | |
| name: Test pixi action - Multiple environments | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create test pyproject.toml with multiple environments | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "multi-env-project" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| [tool.pixi.feature.py311.dependencies] | |
| python = "3.11.*" | |
| pandas = ">=2.0" | |
| [tool.pixi.feature.py312.dependencies] | |
| python = "3.12.*" | |
| scikit-learn = ">=1.3" | |
| [tool.pixi.environments] | |
| py311 = ["py311"] | |
| py312 = ["py312"] | |
| EOF | |
| - name: Test pixi setup with multiple environments | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| environments: "py311 py312" | |
| activate-environment: "py311" | |
| - name: Verify active environment | |
| run: | | |
| echo "Current Python version:" | |
| python --version | |
| echo "Testing py311 specific package..." | |
| python -c "import pandas; print(f'Pandas version: {pandas.__version__}')" | |
| - name: List environments | |
| run: | | |
| pixi info | |
| pixi list -e py311 | |
| pixi list -e py312 | |
| test-pixi-environment-activation: | |
| name: Test pixi action - Environment activation | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create test pyproject.toml | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "env-activation-test" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| [tool.pixi.feature.prod.dependencies] | |
| flask = ">=3.0" | |
| [tool.pixi.feature.dev.dependencies] | |
| pytest = ">=7.0" | |
| black = ">=23.0" | |
| [tool.pixi.environments] | |
| prod = ["prod"] | |
| dev = ["dev"] | |
| EOF | |
| - name: Test pixi setup with dev environment activation | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| environments: "prod dev" | |
| activate-environment: "dev" | |
| - name: Verify dev environment is active | |
| run: | | |
| echo "Testing dev packages..." | |
| python -c "import pytest; print('Pytest available in dev')" | |
| python -c "import black; print('Black available in dev')" | |
| echo "Testing that prod packages are not in dev environment..." | |
| python -c "import flask" 2>/dev/null && echo "ERROR: Flask should not be in dev!" && exit 1 || echo "Good: Flask not in dev environment" | |
| test-pixi-lock-verification: | |
| name: Test pixi action - Lock file verification | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create test pyproject.toml | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "lock-test" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| numpy = ">=1.26" | |
| EOF | |
| - name: Generate initial lock file | |
| run: | | |
| curl -fsSL https://pixi.sh/install.sh | bash | |
| export PATH="$HOME/.pixi/bin:$PATH" | |
| pixi install | |
| - name: Test with valid lock file | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| verify-lock: "true" | |
| - name: Modify pyproject.toml to make lock outdated | |
| run: | | |
| cat >> pyproject.toml << 'EOF' | |
| [tool.pixi.dependencies.pandas] | |
| version = ">=2.0" | |
| EOF | |
| - name: Test with outdated lock file (should fail) | |
| id: outdated-lock-test | |
| continue-on-error: true | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| verify-lock: "true" | |
| - name: Verify lock verification failed | |
| if: steps.outdated-lock-test.outcome != 'failure' | |
| run: | | |
| echo "ERROR: Lock verification should have failed with outdated lock file" | |
| exit 1 | |
| - name: Test with verify-lock disabled | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| verify-lock: "false" | |
| test-pixi-caching: | |
| name: Test pixi action - Caching | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create test pyproject.toml | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "cache-test" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| numpy = ">=1.26" | |
| scipy = ">=1.11" | |
| matplotlib = ">=3.8" | |
| EOF | |
| - name: Generate lock file | |
| run: | | |
| curl -fsSL https://pixi.sh/install.sh | bash | |
| export PATH="$HOME/.pixi/bin:$PATH" | |
| pixi install | |
| - name: First run - populate cache | |
| uses: ./actions/python-setup/pixi | |
| id: first-run | |
| - name: Clear pixi installation to test cache | |
| run: | | |
| rm -rf ~/.pixi/envs/ | |
| rm -rf .pixi/ | |
| - name: Second run - use cache | |
| uses: ./actions/python-setup/pixi | |
| id: second-run | |
| - name: Verify packages are still available | |
| run: | | |
| python -c "import numpy, scipy, matplotlib; print('All packages available from cache')" | |
| test-pixi-matrix: | |
| name: Test pixi action - Matrix | |
| strategy: | |
| matrix: | |
| os: [ubuntu-latest, windows-latest, macos-latest] | |
| environment: ["default", "py311", "py312"] | |
| runs-on: ${{ matrix.os }} | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create test pyproject.toml | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "cross-platform-test" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| [tool.pixi.feature.py311.dependencies] | |
| python = "3.11.*" | |
| requests = ">=2.31" | |
| [tool.pixi.feature.py312.dependencies] | |
| python = "3.12.*" | |
| httpx = ">=0.25" | |
| [tool.pixi.environments] | |
| default = [] | |
| py311 = ["py311"] | |
| py312 = ["py312"] | |
| EOF | |
| - name: Test pixi setup | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| environments: ${{ matrix.environment }} | |
| activate-environment: ${{ matrix.environment }} | |
| - name: Verify Python installation | |
| run: | | |
| python --version | |
| pixi list -e ${{ matrix.environment }} | |
| test-pixi-error-scenarios: | |
| name: Test pixi action - Error scenarios | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Test without pyproject.toml | |
| id: no-toml-test | |
| continue-on-error: true | |
| uses: ./actions/python-setup/pixi | |
| - name: Verify action failed without pyproject.toml | |
| if: steps.no-toml-test.outcome != 'failure' | |
| run: | | |
| echo "ERROR: Action should fail without pyproject.toml" | |
| exit 1 | |
| - name: Create invalid pyproject.toml | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "invalid-test" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| [tool.pixi.dependencies] | |
| python = ">=99.0" # Impossible version | |
| EOF | |
| - name: Test with invalid dependencies | |
| id: invalid-deps-test | |
| continue-on-error: true | |
| uses: ./actions/python-setup/pixi | |
| - name: Verify action failed with invalid dependencies | |
| if: steps.invalid-deps-test.outcome != 'failure' | |
| run: | | |
| echo "ERROR: Action should fail with invalid dependencies" | |
| exit 1 | |
| - name: Create pyproject.toml with non-existent environment | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "env-test" | |
| version = "0.1.0" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.dependencies] | |
| python = ">=3.11" | |
| [tool.pixi.environments] | |
| default = [] | |
| EOF | |
| - name: Test activating non-existent environment | |
| id: nonexistent-env-test | |
| continue-on-error: true | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| activate-environment: "nonexistent" | |
| - name: Verify action failed with non-existent environment | |
| if: steps.nonexistent-env-test.outcome != 'failure' | |
| run: | | |
| echo "ERROR: Action should fail when activating non-existent environment" | |
| exit 1 | |
| test-pixi-complex-project: | |
| name: Test pixi action - Complex project setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Create complex pyproject.toml | |
| run: | | |
| cat > pyproject.toml << 'EOF' | |
| [project] | |
| name = "complex-project" | |
| version = "0.1.0" | |
| description = "A complex project with multiple features" | |
| dependencies = [] | |
| [tool.pixi.workspace] | |
| channels = ["conda-forge", "pytorch"] | |
| platforms = ["linux-64", "osx-64", "osx-arm64", "win-64"] | |
| [tool.pixi.tasks] | |
| test = "pytest tests/" | |
| lint = "ruff check ." | |
| format = "black ." | |
| [tool.pixi.dependencies] | |
| python = ">=3.11,<3.13" | |
| [tool.pixi.feature.core.dependencies] | |
| numpy = ">=1.26" | |
| pandas = ">=2.0" | |
| scipy = ">=1.11" | |
| [tool.pixi.feature.ml.dependencies] | |
| scikit-learn = ">=1.3" | |
| xgboost = ">=2.0" | |
| pytorch = ">=2.0" | |
| [tool.pixi.feature.viz.dependencies] | |
| matplotlib = ">=3.8" | |
| seaborn = ">=0.13" | |
| plotly = ">=5.18" | |
| [tool.pixi.feature.dev.dependencies] | |
| pytest = ">=7.0" | |
| pytest-cov = ">=4.0" | |
| black = ">=23.0" | |
| ruff = ">=0.1" | |
| mypy = ">=1.0" | |
| [tool.pixi.environments] | |
| default = ["core", "dev"] | |
| ml = ["core", "ml", "viz", "dev"] | |
| prod = ["core", "ml"] | |
| EOF | |
| - name: Test complex project setup | |
| uses: ./actions/python-setup/pixi | |
| with: | |
| environments: "default ml prod" | |
| activate-environment: "ml" | |
| - name: Verify ML environment | |
| run: | | |
| echo "Testing ML environment packages..." | |
| python -c "import numpy, pandas, scipy; print('Core packages OK')" | |
| python -c "import sklearn, xgboost, torch; print('ML packages OK')" | |
| python -c "import matplotlib, seaborn, plotly; print('Viz packages OK')" | |
| python -c "import pytest, black; print('Dev packages OK')" | |
| echo "Environment info:" | |
| pixi info | |
| pixi list -e ml |