ci: llama.cpp - simplify test setup #1125
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
| # This workflow comes from https://github.com/ofek/hatch-mypyc | |
| # https://github.com/ofek/hatch-mypyc/blob/5a198c0ba8660494d02716cfc9d79ce4adfb1442/.github/workflows/test.yml | |
| name: Test / llama_cpp | |
| on: | |
| schedule: | |
| - cron: "0 0 * * *" | |
| pull_request: | |
| paths: | |
| - "integrations/llama_cpp/**" | |
| - "!integrations/llama_cpp/*.md" | |
| - ".github/workflows/llama_cpp.yml" | |
| push: | |
| branches: | |
| - main | |
| paths: | |
| - "integrations/llama_cpp/**" | |
| - "!integrations/llama_cpp/*.md" | |
| - ".github/workflows/llama_cpp.yml" | |
| defaults: | |
| run: | |
| working-directory: integrations/llama_cpp | |
| concurrency: | |
| group: llama_cpp-${{ github.head_ref || github.sha }} | |
| cancel-in-progress: true | |
| env: | |
| PYTHONUNBUFFERED: "1" | |
| FORCE_COLOR: "1" | |
| jobs: | |
| compute-test-matrix: | |
| runs-on: ubuntu-slim | |
| defaults: | |
| run: | |
| working-directory: . | |
| outputs: | |
| matrix: ${{ steps.set.outputs.matrix }} | |
| steps: | |
| - id: set | |
| run: | | |
| if [ "${{ github.event_name }}" = "push" ]; then | |
| echo 'matrix=[{"os":"ubuntu-latest","python-version":"3.10"}]' >> "$GITHUB_OUTPUT" | |
| else | |
| MATRIX='[' | |
| MATRIX+='{"os":"ubuntu-latest","python-version":"3.10"},' | |
| MATRIX+='{"os":"ubuntu-latest","python-version":"3.14"},' | |
| MATRIX+='{"os":"windows-latest","python-version":"3.10"},' | |
| MATRIX+='{"os":"windows-latest","python-version":"3.14"},' | |
| # On macOS, pre-built wheels for 3.14 are not available and installing from source | |
| # might fail due to missing dependencies (CMake fails with "OpenMP not found"). | |
| # We test with 3.12 instead because pre-built wheels are available for this version. | |
| MATRIX+='{"os":"macos-latest","python-version":"3.10"},' | |
| MATRIX+='{"os":"macos-latest","python-version":"3.12"}' | |
| MATRIX+=']' | |
| echo "matrix=$MATRIX" >> "$GITHUB_OUTPUT" | |
| fi | |
| run: | |
| name: Python ${{ matrix.python-version }} on ${{ startsWith(matrix.os, 'macos-') && 'macOS' || startsWith(matrix.os, 'windows-') && 'Windows' || 'Linux' }} | |
| needs: compute-test-matrix | |
| permissions: | |
| contents: write | |
| pull-requests: write | |
| runs-on: ${{ matrix.os }} | |
| strategy: | |
| fail-fast: false | |
| matrix: | |
| include: ${{ fromJSON(needs.compute-test-matrix.outputs.matrix) }} | |
| steps: | |
| - name: Support longpaths | |
| if: matrix.os == 'windows-latest' | |
| working-directory: . | |
| run: git config --system core.longpaths true | |
| - uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2 | |
| - name: Set up Python ${{ matrix.python-version }} | |
| uses: actions/setup-python@a309ff8b426b58ec0e2a45f0f869d46889d02405 # v6.2.0 | |
| with: | |
| python-version: ${{ matrix.python-version }} | |
| - name: Install Hatch | |
| run: pip install hatch | |
| - name: Lint | |
| if: matrix.python-version == '3.10' && runner.os == 'Linux' | |
| run: hatch run fmt-check && hatch run test:types | |
| - name: Run unit tests | |
| run: hatch run test:unit-cov-retry | |
| # On PR: generates coverage comment artifact. On push to main: stores coverage baseline on data branch. | |
| - name: Store unit tests coverage | |
| if: matrix.python-version == '3.10' && runner.os == 'Linux' && github.event_name != 'schedule' | |
| uses: py-cov-action/python-coverage-comment-action@7188638f871f721a365d644f505d1ff3df20d683 # v3.40 | |
| with: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| COVERAGE_PATH: integrations/llama_cpp | |
| SUBPROJECT_ID: llama_cpp | |
| COMMENT_ARTIFACT_NAME: coverage-comment-llama_cpp | |
| MINIMUM_GREEN: 90 | |
| MINIMUM_ORANGE: 60 | |
| - name: Run integration tests | |
| run: hatch run test:integration-cov-append-retry | |
| - name: Store combined coverage | |
| if: github.event_name == 'push' | |
| uses: py-cov-action/python-coverage-comment-action@7188638f871f721a365d644f505d1ff3df20d683 # v3.40 | |
| with: | |
| GITHUB_TOKEN: ${{ github.token }} | |
| COVERAGE_PATH: integrations/llama_cpp | |
| SUBPROJECT_ID: llama_cpp-combined | |
| COMMENT_ARTIFACT_NAME: coverage-comment-llama_cpp-combined | |
| MINIMUM_GREEN: 90 | |
| MINIMUM_ORANGE: 60 | |
| - name: Run unit tests with lowest direct dependencies | |
| if: github.event_name != 'push' | |
| run: | | |
| hatch run uv pip compile pyproject.toml --resolution lowest-direct --output-file requirements_lowest_direct.txt | |
| hatch -e test env run -- uv pip install -r requirements_lowest_direct.txt | |
| hatch run test:unit | |
| - name: Nightly - run unit tests with Haystack main branch | |
| if: github.event_name == 'schedule' | |
| run: | | |
| hatch env prune | |
| hatch -e test env run -- uv pip install git+https://github.com/deepset-ai/haystack.git@main | |
| hatch run test:unit | |
| notify-slack-on-failure: | |
| needs: run | |
| if: failure() && github.event_name == 'schedule' | |
| runs-on: ubuntu-slim | |
| steps: | |
| - uses: deepset-ai/notify-slack-action@3cda73b77a148f16f703274198e7771340cf862b # v1 | |
| with: | |
| slack-webhook-url: ${{ secrets.SLACK_WEBHOOK_URL_NOTIFICATIONS }} |