Skip to content

Tests

Tests #2512

Workflow file for this run

# If you change this name also do it in tests_skipper.yml and ci_metrics.yml
name: Tests
on:
# Activate this workflow manually
workflow_dispatch:
# Run tests nightly against Haystack's main branch
schedule:
- cron: "0 0 * * *"
push:
branches:
- main
pull_request:
types:
- opened
- reopened
- synchronize
paths:
- "haystack_experimental/**/*.py"
- "test/**/*.py"
- "pyproject.toml"
- ".github/workflows/tests.yml"
env:
PYTHON_VERSION: "3.9"
HATCH_VERSION: "1.14.2"
PYTHONUNBUFFERED: "1"
FORCE_COLOR: "1"
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
jobs:
linting:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Get changed files
id: files
uses: tj-actions/changed-files@v47
with:
files_yaml: |
python:
- '**/*.py'
- '!test/**'
pyproject:
- 'pyproject.toml'
- uses: actions/setup-python@v6
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Ruff - check format and linting
run: hatch run fmt-check
- name: Pylint
# Running pylint on pyproject.toml causes errors, so we only run it on python files.
if: steps.files.outputs.python_any_changed == 'true'
run: |
hatch run test:lint ${{ steps.files.outputs.python_all_changed_files }}
- name: Typing
if: steps.files.outputs.python_any_changed == 'true' || steps.files.outputs.pyproject_any_changed == 'true'
run: |
mkdir .mypy_cache
hatch run test:types
unit-tests:
name: Unit / ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run
run: hatch run test:unit
- name: Coveralls
# We upload only coverage for ubuntu as handling both os
# complicates the workflow too much for little to no gain
if: matrix.os == 'ubuntu-latest'
uses: coverallsapp/github-action@v2
with:
path-to-lcov: coverage.xml
- name: Nightly - run unit tests with Haystack main branch
if: github.event_name == 'schedule'
id: nightly-haystack-main
run: |
hatch run pip install git+https://github.com/deepset-ai/haystack.git
hatch run test:unit
integration-tests:
name: Integration / ${{ matrix.os }}
needs: linting
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v5
- uses: actions/setup-python@v6
with:
python-version: "${{ env.PYTHON_VERSION }}"
- name: Install Hatch
run: pip install hatch==${{ env.HATCH_VERSION }}
- name: Run
run: hatch run test:integration-retry