Nightly workflow (anyoptimization/pymoo)
The Nightly 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 Nightly 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: Nightly
# The expensive gate (full OS × Python matrix, examples, full docs build),
# run once a day - but ONLY if something was committed in the last 24h, so a
# quiet day costs nothing. Manual dispatch always runs. (IMPROVEMENTS.md P-1.)
on:
schedule:
- cron: '0 4 * * *' # 04:00 UTC daily
workflow_dispatch:
concurrency:
group: nightly
cancel-in-progress: false
jobs:
changed:
name: any commit in the last 24h?
runs-on: ubuntu-latest
outputs:
run: ${{ steps.check.outputs.run }}
steps:
- uses: actions/checkout@v4
- id: check
run: |
latest=$(git log -1 --format=%ct)
now=$(date +%s)
age=$(( now - latest ))
if [ "${{ github.event_name }}" = "workflow_dispatch" ] || [ "$age" -lt 86400 ]; then
echo "Last commit ${age}s ago → running nightly."
echo "run=true" >> "$GITHUB_OUTPUT"
else
echo "Last commit ${age}s ago (>24h) → skipping nightly."
echo "run=false" >> "$GITHUB_OUTPUT"
fi
unit-matrix:
name: unit ${{ matrix.os }} · py${{ matrix.python }}
needs: changed
if: needs.changed.outputs.run == 'true'
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python }}
cache: pip
- 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
pip install "pyclawd>=0.1.1" pytest-xdist
- name: Compiled extensions present
# fail if the Cython extensions didn't compile (P-5b) - no silent slow fallback.
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: Full unit suite (incl. long convergence tests)
run: pytest -n auto -m "not examples and not docs and not golden"
- name: Golden behavior-regression
# res.F baselines are bit-reproducible only on the platform they were
# recorded on (linux-x86_64); population EAs amplify platform libm
# differences into a different front. Run the golden tier on Linux only;
# the test module itself skips on other platforms (tests/test_golden.py).
if: runner.os == 'Linux'
run: pytest -m golden
docs-examples:
name: docs + examples (ubuntu)
needs: changed
if: needs.changed.outputs.run == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: pip
- uses: astral-sh/setup-uv@v7
- name: System deps
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
pip install "pyclawd>=0.1.1" pytest-xdist pytest-xvfb
- 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: Full docs build (guardrailed; all notebooks execute + HTML renders)
# `pyclawd docs build` runs the output guardrail - fails if an executed
# page rendered blank (the empty-docs failure mode).
run: pyclawd docs build
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Nightly # The expensive gate (full OS × Python matrix, examples, full docs build), # run once a day - but ONLY if something was committed in the last 24h, so a # quiet day costs nothing. Manual dispatch always runs. (IMPROVEMENTS.md P-1.) on: schedule: - cron: '0 4 * * *' # 04:00 UTC daily workflow_dispatch: concurrency: group: nightly cancel-in-progress: false jobs: changed: timeout-minutes: 30 name: any commit in the last 24h? runs-on: latchkey-small outputs: run: ${{ steps.check.outputs.run }} steps: - uses: actions/checkout@v4 - id: check run: | latest=$(git log -1 --format=%ct) now=$(date +%s) age=$(( now - latest )) if [ "${{ github.event_name }}" = "workflow_dispatch" ] || [ "$age" -lt 86400 ]; then echo "Last commit ${age}s ago → running nightly." echo "run=true" >> "$GITHUB_OUTPUT" else echo "Last commit ${age}s ago (>24h) → skipping nightly." echo "run=false" >> "$GITHUB_OUTPUT" fi unit-matrix: timeout-minutes: 30 name: unit ${{ matrix.os }} · py${{ matrix.python }} needs: changed if: needs.changed.outputs.run == 'true' strategy: fail-fast: false matrix: os: [ubuntu-latest, macos-latest, windows-latest] python: ['3.10', '3.11', '3.12', '3.13', '3.14'] runs-on: ${{ matrix.os }} steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: ${{ matrix.python }} cache: pip - 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 pip install "pyclawd>=0.1.1" pytest-xdist - name: Compiled extensions present # fail if the Cython extensions didn't compile (P-5b) - no silent slow fallback. 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: Full unit suite (incl. long convergence tests) run: pytest -n auto -m "not examples and not docs and not golden" - name: Golden behavior-regression # res.F baselines are bit-reproducible only on the platform they were # recorded on (linux-x86_64); population EAs amplify platform libm # differences into a different front. Run the golden tier on Linux only; # the test module itself skips on other platforms (tests/test_golden.py). if: runner.os == 'Linux' run: pytest -m golden docs-examples: timeout-minutes: 30 name: docs + examples (ubuntu) needs: changed if: needs.changed.outputs.run == 'true' runs-on: latchkey-small steps: - uses: actions/checkout@v4 - uses: actions/setup-python@v5 with: python-version: '3.12' cache: pip - uses: astral-sh/setup-uv@v7 - name: System deps 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 pip install "pyclawd>=0.1.1" pytest-xdist pytest-xvfb - 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: Full docs build (guardrailed; all notebooks execute + HTML renders) # `pyclawd docs build` runs the output guardrail - fails if an executed # page rendered blank (the empty-docs failure mode). run: pyclawd docs build
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 3 jobs (17 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.