CI workflow (anyoptimization/pymoo)
The CI workflow from anyoptimization/pymoo, explained and optimized by Latchkey.
CI health: B - good
Point runs-on at Latchkey and get job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the CI workflow from the anyoptimization/pymoo repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: CI
# No per-commit CI by design. The maintainer commits frequently (often straight
# to main), so fast feedback lives LOCALLY (`pyclawd test fast` before pushing),
# not as a run per push. Server-side coverage is:
# - this full gate: on PRs and manual dispatch (the consolidation point)
# - nightly.yml: the heavy matrix + docs + golden, once a day IF committed
# - build.yml: the release gate, on a version tag
on:
pull_request:
workflow_dispatch:
# If a PR gets several pushes in a row, only the latest gate run survives.
concurrency:
group: ci-${{ github.ref }}
cancel-in-progress: true
jobs:
gate:
name: full gate (3.12, ubuntu)
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # docs --changed compares against origin/main
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- uses: astral-sh/setup-uv@v7
- name: System deps (docs + headless examples)
run: sudo apt-get update && sudo apt-get install -y pandoc xvfb
- name: Install pymoo (compiled) + deps
run: |
pip install --upgrade pip "setuptools>=77" "Cython>=0.29" "numpy>=2.0.0"
pip install -e .
python setup.py build_ext --inplace
pip install -r tests/requirements.txt
# pyclawd provides the golden pytest plugin (compares baselines) AND
# the docs build with its output guardrail. It runs under the CI Python
# (sys.executable - conda_env in config is advisory only). >=0.1.1 is
# the release carrying `pyclawd docs validate`.
pip install "pyclawd>=0.1.1" pytest-xdist pytest-xvfb ruff mypy
- name: Compiled extensions present
# fail if the Cython extensions didn't compile - otherwise the suite would
# silently run the slow pure-Python fallback (P-5b).
run: python -c "import sys; from pymoo.functions import is_compiled; ok=is_compiled(); print('compiled:', ok); sys.exit(0 if ok else 1)"
- name: Lint + format + typecheck
run: |
ruff check pymoo
ruff format --check pymoo
mypy pymoo # enforcing (P-4): name-defined on, attr-defined/arg-type staged
- name: Full unit suite (incl. long convergence tests)
run: pytest -n auto -m "not examples and not docs and not golden"
- name: Golden behavior-regression (pyclawd plugin compares baselines)
run: pytest -m golden
- name: Examples (headless via xvfb)
run: pytest -n auto -m examples
- name: Restore docs execution cache
uses: actions/cache@v4
with:
path: docs/.jupyter_cache
key: jupyter-cache-${{ hashFiles('docs/source/**/*.md', 'pymoo/**/*.py') }}
restore-keys: jupyter-cache-
- name: Docs build (guardrailed; only pages changed vs main)
# `pyclawd docs build` runs the output guardrail - fails if an executed
# page rendered blank (the empty-docs failure mode).
run: pyclawd docs build --changed
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: CI # No per-commit CI by design. The maintainer commits frequently (often straight # to main), so fast feedback lives LOCALLY (`pyclawd test fast` before pushing), # not as a run per push. Server-side coverage is: # - this full gate: on PRs and manual dispatch (the consolidation point) # - nightly.yml: the heavy matrix + docs + golden, once a day IF committed # - build.yml: the release gate, on a version tag on: pull_request: workflow_dispatch: # If a PR gets several pushes in a row, only the latest gate run survives. concurrency: group: ci-${{ github.ref }} cancel-in-progress: true jobs: gate: timeout-minutes: 30 name: full gate (3.12, ubuntu) runs-on: latchkey-small steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # docs --changed compares against origin/main - uses: actions/setup-python@v5 with: python-version: '3.12' cache: pip - uses: astral-sh/setup-uv@v7 - name: System deps (docs + headless examples) run: sudo apt-get update && sudo apt-get install -y pandoc xvfb - name: Install pymoo (compiled) + deps run: | pip install --upgrade pip "setuptools>=77" "Cython>=0.29" "numpy>=2.0.0" pip install -e . python setup.py build_ext --inplace pip install -r tests/requirements.txt # pyclawd provides the golden pytest plugin (compares baselines) AND # the docs build with its output guardrail. It runs under the CI Python # (sys.executable - conda_env in config is advisory only). >=0.1.1 is # the release carrying `pyclawd docs validate`. pip install "pyclawd>=0.1.1" pytest-xdist pytest-xvfb ruff mypy - name: Compiled extensions present # fail if the Cython extensions didn't compile - otherwise the suite would # silently run the slow pure-Python fallback (P-5b). run: python -c "import sys; from pymoo.functions import is_compiled; ok=is_compiled(); print('compiled:', ok); sys.exit(0 if ok else 1)" - name: Lint + format + typecheck run: | ruff check pymoo ruff format --check pymoo mypy pymoo # enforcing (P-4): name-defined on, attr-defined/arg-type staged - name: Full unit suite (incl. long convergence tests) run: pytest -n auto -m "not examples and not docs and not golden" - name: Golden behavior-regression (pyclawd plugin compares baselines) run: pytest -m golden - name: Examples (headless via xvfb) run: pytest -n auto -m examples - name: Restore docs execution cache uses: actions/cache@v4 with: path: docs/.jupyter_cache key: jupyter-cache-${{ hashFiles('docs/source/**/*.md', 'pymoo/**/*.py') }} restore-keys: jupyter-cache- - name: Docs build (guardrailed; only pages changed vs main) # `pyclawd docs build` runs the output guardrail - fails if an executed # page rendered blank (the empty-docs failure mode). run: pyclawd docs build --changed
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. - Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it 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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.