Add python tests via Tox #8
Workflow file for this run
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: Python checks | |
| on: | |
| push: | |
| branches: [main] | |
| paths: | |
| - compass/** | |
| - .github/workflows/lint-python.yml | |
| - pyproject.toml | |
| - pixi.lock | |
| pull_request: | |
| paths: | |
| - compass/** | |
| - .github/workflows/lint-python.yml | |
| - pyproject.toml | |
| - pixi.lock | |
| workflow_dispatch: | |
| jobs: | |
| lint: | |
| name: Lint Python Code Base with Ruff | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - uses: astral-sh/ruff-action@v3 | |
| with: | |
| version: "latest" | |
| args: "check" | |
| src: "./compass" | |
| - uses: astral-sh/ruff-action@v3 | |
| with: | |
| version: "latest" | |
| args: "format --check" | |
| src: "./compass" | |
| unit-tests: | |
| needs: lint | |
| name: Python Unit Tests (Pixi) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 8 | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: prefix-dev/[email protected] | |
| with: | |
| pixi-version: v0.50.2 | |
| locked: true | |
| cache: true | |
| cache-write: ${{ github.ref == 'refs/heads/main' }} | |
| environments: pdev | |
| - run: | | |
| pixi run -e pdev --frozen tests-u | |
| integration-tests: | |
| needs: lint | |
| name: Python Integration Tests (Pixi) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 8 | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| steps: | |
| - name: Checkout Repo | |
| uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| - uses: prefix-dev/[email protected] | |
| with: | |
| pixi-version: v0.50.2 | |
| locked: true | |
| cache: true | |
| cache-write: ${{ github.ref == 'refs/heads/main' }} | |
| environments: pdev | |
| - run: | | |
| pixi run -e pdev --frozen tests-i | |
| tox-tests: | |
| needs: lint | |
| name: Python tests (Tox) | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| max-parallel: 8 | |
| matrix: | |
| os: [ubuntu-latest, macos-latest, windows-latest] | |
| python-version: ['3.13', '3.12'] | |
| steps: | |
| - uses: actions/checkout@v5 | |
| with: | |
| fetch-depth: 0 | |
| # - name: Set up Python ${{ matrix.python-version }} | |
| # uses: actions/setup-python@v6 | |
| # with: | |
| # python-version: ${{ matrix.python-version }} | |
| # cache: 'pip' | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: conda-incubator/setup-miniconda@v3 | |
| with: | |
| auto-update-conda: true | |
| channels: conda-forge,defaults | |
| python-version: ${{ matrix.python-version }} | |
| miniconda-version: "latest" | |
| - name: Install Poppler Reqs | |
| shell: bash | |
| run: | | |
| if [ "$RUNNER_OS" == "Linux" ]; then | |
| sudo apt-get update | |
| sudo apt-get install -y libpoppler-cpp-dev poppler-utils | |
| elif [ "$RUNNER_OS" == "macOS" ]; then | |
| brew install poppler | |
| elif [ "$RUNNER_OS" == "Windows" ]; then | |
| choco install poppler -y | |
| fi | |
| - name: Install Dependencies | |
| run: | | |
| conda install -c conda-forge poppler | |
| python -m pip install --upgrade pip | |
| python -m pip install tox tox-gh-actions>=2.0 | |
| python -m pip install pdftotext | |
| - name: Load tox cache | |
| uses: actions/cache/restore@v4 | |
| with: | |
| path: .tox/ | |
| key: ${{ runner.os }}-${{ matrix.python-version }}-tox-v1-${{ hashFiles('**/pyproject.toml') }} | |
| restore-keys: | | |
| ${{ runner.os }}-${{ matrix.python-version }}-tox-v1- | |
| - name: Test with tox | |
| run: tox -e ${{ matrix.python-version == '3.12' && 'msv' || 'latest' }} | |
| env: | |
| PYTHONDEVMODE: 1 | |
| - name: Save tox cache only on main | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/cache/save@v4 | |
| with: | |
| path: .tox/ | |
| key: ${{ runner.os }}-${{ matrix.python-version }}-tox-v1-${{ hashFiles('**/pyproject.toml') }} |