Tests workflow (PythonOT/POT)
The Tests workflow from PythonOT/POT, explained and optimized by Latchkey.
CI health: D - needs work
Point runs-on at Latchkey and get caching, run de-duplication, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Tests workflow from the PythonOT/POT repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Tests
on:
workflow_dispatch:
pull_request:
branches:
- 'master'
push:
branches:
- 'master'
create:
branches:
- 'master'
tags:
- '**'
env:
PY_VERSION: "3.13"
jobs:
Lint:
runs-on: ubuntu-latest
strategy:
fail-fast: false
defaults:
run:
shell: bash -l {0}
steps:
- name: Checking Out Repository
uses: actions/checkout@v7
with:
submodules: true
# Install Python & Packages
- uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
- run: which python
- name: Lint with pre-commit
run: |
pip install pre-commit
pre-commit install --install-hooks
pre-commit run --all-files
build_from_source:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
- name: Build from source
run: |
python -m pip install --upgrade pip setuptools wheel
python -m pip install cython numpy
python setup.py sdist bdist_wheel
pip install dist/*.tar.gz
doctests:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
steps:
- name: Free Disk Space (Ubuntu)
uses: insightsengineering/disk-space-reclaimer@v1
with:
android: true
dotnet: true
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r .github/requirements_doctests.txt
pip install pytest pytest-cov
- name: Install POT
run: |
pip install -e .
- name: Run tests
run: |
python -m pytest -v ot/ test/conftest.py --doctest-modules --color=yes --cov=./ --cov-report=xml
linux-minimal:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install pytest pytest-cov
- name: Install POT
run: |
pip install -e .
- name: Run tests
run: |
python -m pytest --durations=20 -v test/ ot/ --color=yes --cov=./ --cov-report=xml
linux:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
strategy:
max-parallel: 4
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14"]
steps:
# - name: Free Disk Space (Ubuntu)
# uses: insightsengineering/disk-space-reclaimer@v1
# with:
# android: true
# dotnet: true
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install POT
run: |
pip install -e .
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r .github/requirements_no_backend.txt
pip install pytest pytest-cov
- name: test POT import
run: |
python -c "import ot; print(ot.__version__)"
- name: Run tests
run: |
python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v4
linux-torch:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python ${{ env.PY_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
cache: 'pip'
- name: Install POT
run: |
pip install -e .
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install torch torch_geometric geomloss pykeops scikit-learn
pip install pytest pytest-cov
- name: Run tests
run: |
python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v4
linux-jax:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python ${{ env.PY_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
cache: 'pip'
- name: Install POT
run: |
pip install -e .
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install jax jaxlib
pip install pytest pytest-cov
- name: Run tests
run: |
python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v4
linux-tf:
runs-on: ubuntu-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python ${{ env.PY_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
cache: 'pip'
- name: Install POT
run: |
pip install -e .
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install tensorflow
pip install pytest pytest-cov
- name: Run tests
run: |
python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml
- name: Upload coverage reports to Codecov with GitHub Action
uses: codecov/codecov-action@v4
# linux-minimal-deps-ft:
# runs-on: ubuntu-latest
# if: "!contains(github.event.head_commit.message, 'no ci')"
# steps:
# - uses: actions/checkout@v4
# with:
# submodules: true
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: "3.14t"
# cache: 'pip'
# - name: Install dependencies
# run: |
# python -m pip install --upgrade pip setuptools
# pip install pytest pytest-cov
# - name: Install POT
# run: |
# pip install -e .
# - name: Run tests
# run: |
# python -m pytest --durations=20 -v test/ ot/ --color=yes --cov=./ --cov-report=xml
macos:
runs-on: macos-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python ${{ env.PY_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
cache: 'pip'
- name: Install POT
run: |
pip install -e .
- name: Install dependencies
run: |
python -m pip install --upgrade pip setuptools
pip install -r .github/requirements_no_backend.txt
pip install pytest
- name: Run tests
run: |
python -m pytest --durations=20 -v test/ ot/ --color=yes
windows:
runs-on: windows-latest
if: "!contains(github.event.head_commit.message, 'no ci')"
steps:
- uses: actions/checkout@v7
with:
submodules: true
- name: Set up Python ${{ env.PY_VERSION }}
uses: actions/setup-python@v6
with:
python-version: ${{ env.PY_VERSION }}
cache: 'pip'
- name: RC.exe
run: |
function Invoke-VSDevEnvironment {
$vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe"
$installationPath = & $vswhere -prerelease -legacy -latest -property installationPath
$Command = Join-Path $installationPath "Common7\Tools\vsdevcmd.bat"
& "${env:COMSPEC}" /s /c "`"$Command`" -no_logo && set" | Foreach-Object {
if ($_ -match '^([^=]+)=(.*)') {
[System.Environment]::SetEnvironmentVariable($matches[1], $matches[2])
}
}
}
Invoke-VSDevEnvironment
Get-Command rc.exe | Format-Table -AutoSize
- name: Update pip
run: |
python -m pip install --upgrade pip setuptools
python -m pip install cython
- name: Install POT
run: |
python -m pip install -e .
- name: Install dependencies
run: |
python -m pip install -r .github/requirements_test_windows.txt
python -m pip3 install torch torchvision torchaudio
python -m pip install pytest
- name: Run tests
run: |
python -m pytest --durations=20 -v test/ ot/ --color=yes
The same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Tests on: workflow_dispatch: pull_request: branches: - 'master' push: branches: - 'master' create: branches: - 'master' tags: - '**' env: PY_VERSION: "3.13" concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: Lint: runs-on: latchkey-small strategy: fail-fast: false defaults: run: shell: bash -l {0} steps: - name: Checking Out Repository uses: actions/checkout@v7 with: submodules: true # Install Python & Packages - uses: actions/setup-python@v6 with: cache: 'pip' python-version: ${{ env.PY_VERSION }} - run: which python - name: Lint with pre-commit run: | pip install pre-commit pre-commit install --install-hooks pre-commit run --all-files build_from_source: runs-on: latchkey-small steps: - uses: actions/checkout@v7 with: submodules: true - name: Set up Python uses: actions/setup-python@v6 with: cache: 'pip' python-version: ${{ env.PY_VERSION }} - name: Build from source run: | python -m pip install --upgrade pip setuptools wheel python -m pip install cython numpy python setup.py sdist bdist_wheel pip install dist/*.tar.gz doctests: runs-on: latchkey-small if: "!contains(github.event.head_commit.message, 'no ci')" steps: - name: Free Disk Space (Ubuntu) uses: insightsengineering/disk-space-reclaimer@v1 with: android: true dotnet: true - uses: actions/checkout@v7 with: submodules: true - name: Set up Python uses: actions/setup-python@v6 with: python-version: ${{ env.PY_VERSION }} cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install -r .github/requirements_doctests.txt pip install pytest pytest-cov - name: Install POT run: | pip install -e . - name: Run tests run: | python -m pytest -v ot/ test/conftest.py --doctest-modules --color=yes --cov=./ --cov-report=xml linux-minimal: runs-on: latchkey-small if: "!contains(github.event.head_commit.message, 'no ci')" steps: - uses: actions/checkout@v7 with: submodules: true - name: Set up Python uses: actions/setup-python@v6 with: python-version: ${{ env.PY_VERSION }} cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install pytest pytest-cov - name: Install POT run: | pip install -e . - name: Run tests run: | python -m pytest --durations=20 -v test/ ot/ --color=yes --cov=./ --cov-report=xml linux: runs-on: latchkey-small if: "!contains(github.event.head_commit.message, 'no ci')" strategy: max-parallel: 4 matrix: python-version: ["3.11", "3.12", "3.13", "3.14"] steps: # - name: Free Disk Space (Ubuntu) # uses: insightsengineering/disk-space-reclaimer@v1 # with: # android: true # dotnet: true - uses: actions/checkout@v7 with: submodules: true - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v6 with: python-version: ${{ matrix.python-version }} cache: 'pip' - name: Install POT run: | pip install -e . - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install -r .github/requirements_no_backend.txt pip install pytest pytest-cov - name: test POT import run: | python -c "import ot; print(ot.__version__)" - name: Run tests run: | python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v4 linux-torch: runs-on: latchkey-small if: "!contains(github.event.head_commit.message, 'no ci')" steps: - uses: actions/checkout@v7 with: submodules: true - name: Set up Python ${{ env.PY_VERSION }} uses: actions/setup-python@v6 with: python-version: ${{ env.PY_VERSION }} cache: 'pip' - name: Install POT run: | pip install -e . - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install torch torch_geometric geomloss pykeops scikit-learn pip install pytest pytest-cov - name: Run tests run: | python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v4 linux-jax: runs-on: latchkey-small if: "!contains(github.event.head_commit.message, 'no ci')" steps: - uses: actions/checkout@v7 with: submodules: true - name: Set up Python ${{ env.PY_VERSION }} uses: actions/setup-python@v6 with: python-version: ${{ env.PY_VERSION }} cache: 'pip' - name: Install POT run: | pip install -e . - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install jax jaxlib pip install pytest pytest-cov - name: Run tests run: | python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v4 linux-tf: runs-on: latchkey-small if: "!contains(github.event.head_commit.message, 'no ci')" steps: - uses: actions/checkout@v7 with: submodules: true - name: Set up Python ${{ env.PY_VERSION }} uses: actions/setup-python@v6 with: python-version: ${{ env.PY_VERSION }} cache: 'pip' - name: Install POT run: | pip install -e . - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install tensorflow pip install pytest pytest-cov - name: Run tests run: | python -m pytest --durations=20 -v test/ --color=yes --cov=./ --cov-report=xml - name: Upload coverage reports to Codecov with GitHub Action uses: codecov/codecov-action@v4 # linux-minimal-deps-ft: # runs-on: latchkey-small # if: "!contains(github.event.head_commit.message, 'no ci')" # steps: # - uses: actions/checkout@v4 # with: # submodules: true # - name: Set up Python # uses: actions/setup-python@v5 with: cache: 'pip' # with: # python-version: "3.14t" # cache: 'pip' # - name: Install dependencies # run: | # python -m pip install --upgrade pip setuptools # pip install pytest pytest-cov # - name: Install POT # run: | # pip install -e . # - name: Run tests # run: | # python -m pytest --durations=20 -v test/ ot/ --color=yes --cov=./ --cov-report=xml macos: runs-on: macos-latest if: "!contains(github.event.head_commit.message, 'no ci')" steps: - uses: actions/checkout@v7 with: submodules: true - name: Set up Python ${{ env.PY_VERSION }} uses: actions/setup-python@v6 with: python-version: ${{ env.PY_VERSION }} cache: 'pip' - name: Install POT run: | pip install -e . - name: Install dependencies run: | python -m pip install --upgrade pip setuptools pip install -r .github/requirements_no_backend.txt pip install pytest - name: Run tests run: | python -m pytest --durations=20 -v test/ ot/ --color=yes windows: runs-on: windows-latest if: "!contains(github.event.head_commit.message, 'no ci')" steps: - uses: actions/checkout@v7 with: submodules: true - name: Set up Python ${{ env.PY_VERSION }} uses: actions/setup-python@v6 with: python-version: ${{ env.PY_VERSION }} cache: 'pip' - name: RC.exe run: | function Invoke-VSDevEnvironment { $vswhere = "${env:ProgramFiles(x86)}\Microsoft Visual Studio\Installer\vswhere.exe" $installationPath = & $vswhere -prerelease -legacy -latest -property installationPath $Command = Join-Path $installationPath "Common7\Tools\vsdevcmd.bat" & "${env:COMSPEC}" /s /c "`"$Command`" -no_logo && set" | Foreach-Object { if ($_ -match '^([^=]+)=(.*)') { [System.Environment]::SetEnvironmentVariable($matches[1], $matches[2]) } } } Invoke-VSDevEnvironment Get-Command rc.exe | Format-Table -AutoSize - name: Update pip run: | python -m pip install --upgrade pip setuptools python -m pip install cython - name: Install POT run: | python -m pip install -e . - name: Install dependencies run: | python -m pip install -r .github/requirements_test_windows.txt python -m pip3 install torch torchvision torchaudio python -m pip install pytest - name: Run tests run: | python -m pytest --durations=20 -v test/ ot/ --color=yes
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
This workflow runs 10 jobs (13 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.