name: "Opik Optimizer - Unit Tests" run-name: "Opik Optimizer Unit Tests ${{ github.ref_name }} by @${{ github.actor }}" on: workflow_dispatch: pull_request: paths: - 'sdks/opik_optimizer/**' push: branches: - 'main' paths: - 'sdks/opik_optimizer/**' concurrency: group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} cancel-in-progress: true env: OPIK_ENABLE_LITELLM_MODELS_MONITORING: False OPIK_SENTRY_ENABLE: False HF_HUB_OFFLINE: true HF_DATASETS_OFFLINE: true HF_HUB_ENABLE_PROGRESS_BARS: "0" HF_HUB_DISABLE_TELEMETRY: "1" permissions: contents: read jobs: run-unit-tests: name: Opik Optimizer Unit Tests Python ${{matrix.python_version}} runs-on: ubuntu-latest timeout-minutes: 15 defaults: run: working-directory: sdks/opik_optimizer/ strategy: fail-fast: false matrix: python_version: ${{ fromJSON(vars.PYTHON_VERSIONS || '["3.10","3.11","3.12","3.13","3.14"]') }} steps: - name: Check out code uses: actions/checkout@v6 - name: Setup Python ${{matrix.python_version}} uses: actions/setup-python@v5 with: python-version: ${{matrix.python_version}} cache: 'pip' cache-dependency-path: | sdks/opik_optimizer/pyproject.toml sdks/opik_optimizer/setup.py sdks/opik_optimizer/tests/test_requirements.txt - name: Cache HuggingFace datasets uses: actions/cache@v4 with: path: ~/.cache/huggingface key: hf-datasets-${{ hashFiles('**/datasets/*.py') }} restore-keys: | hf-datasets- - name: Cache LiteLLM cache uses: actions/cache@v4 with: path: ~/.litellm_cache key: litellm-cache-${{ hashFiles('**/requirements.txt', '**/pyproject.toml', '**/setup.py') }} restore-keys: | litellm-cache- - name: Install opik_optimizer run: pip install . - name: Install test requirements run: | cd ./tests pip install --no-cache-dir --disable-pip-version-check -r test_requirements.txt - name: Run unit tests run: pytest -n auto --dist loadfile tests/unit -vv --junitxml=${{ github.workspace }}/test_results_${{matrix.python_version}}.xml