Nightly Cron workflow (facebook/Ax)
The Nightly Cron workflow from facebook/Ax, explained and optimized by Latchkey.
- F
- CI health grade
- 40/100
- Health score
- 4
- Jobs per trigger
- 4
- Fixes in the optimized version
In short
- CI health: F (at risk)
- The optimized version below points runs-on at Latchkey managed runners and adds run de-duplication, caching, and job timeouts.
What it does
This is the Nightly Cron workflow from the facebook/Ax 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: Nightly Cron
on:
schedule:
# midnight EST
- cron: '0 5 * * *'
# allow this to be scheduled manually in addition to cron
workflow_dispatch:
push:
branches: [ main ]
paths:
- "tutorials/**"
jobs:
tests-and-coverage-minimal:
name: Tests with latest BoTorch & minimal dependencies
uses: ./.github/workflows/reusable_test.yml
with:
pinned_botorch: false
minimal_dependencies: true
secrets: inherit
tests-and-coverage-full:
name: Tests with latest BoTorch & full dependencies
uses: ./.github/workflows/reusable_test.yml
with:
pinned_botorch: false
minimal_dependencies: false
secrets: inherit
publish-latest-website:
name: Publish latest website
uses: ./.github/workflows/publish_website.yml
permissions:
pages: write
id-token: write
contents: write
with:
run_tutorials: true
pinned_botorch: false
deploy-test-pypi:
runs-on: ubuntu-latest
permissions:
id-token: write # This is required for PyPI OIDC authentication.
env:
# `uv pip ...` requires venv by default. This skips that requirement.
UV_SYSTEM_PYTHON: 1
steps:
- uses: actions/checkout@v6
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.14"
- name: Install dependencies
run: |
# use latest BoTorch
uv pip install git+https://github.com/cornellius-gp/linear_operator.git
uv pip install git+https://github.com/cornellius-gp/gpytorch.git
uv pip install git+https://github.com/pytorch/botorch.git
uv pip install -e ".[dev,mysql,notebook]"
uv pip install --upgrade build setuptools setuptools_scm wheel
- name: Extract reduced version and save to env var
# strip the commit hash from the version to enable upload to pypi
# env var will persist for subsequent steps
run: |
no_local_version=$(python -m setuptools_scm | cut -d "+" -f 1)
echo "SETUPTOOLS_SCM_PRETEND_VERSION=${no_local_version}" >> $GITHUB_ENV
- name: Build wheel
run: |
python -m build --sdist --wheel
- name: Deploy to Test PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1.13
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: trueThe 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: Nightly Cron
on:
schedule:
# midnight EST
- cron: '0 5 * * *'
# allow this to be scheduled manually in addition to cron
workflow_dispatch:
push:
branches: [ main ]
paths:
- "tutorials/**"
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
jobs:
tests-and-coverage-minimal:
timeout-minutes: 30
name: Tests with latest BoTorch & minimal dependencies
uses: ./.github/workflows/reusable_test.yml
with:
pinned_botorch: false
minimal_dependencies: true
secrets: inherit
tests-and-coverage-full:
timeout-minutes: 30
name: Tests with latest BoTorch & full dependencies
uses: ./.github/workflows/reusable_test.yml
with:
pinned_botorch: false
minimal_dependencies: false
secrets: inherit
publish-latest-website:
timeout-minutes: 30
name: Publish latest website
uses: ./.github/workflows/publish_website.yml
permissions:
pages: write
id-token: write
contents: write
with:
run_tutorials: true
pinned_botorch: false
deploy-test-pypi:
timeout-minutes: 30
runs-on: ubuntu-latest
runs-on: latchkey-small
permissions:
id-token: write # This is required for PyPI OIDC authentication.
env:
# `uv pip ...` requires venv by default. This skips that requirement.
UV_SYSTEM_PYTHON: 1
steps:
- uses: actions/checkout@v6
- name: Fetch all history for all tags and branches
run: git fetch --prune --unshallow
- name: Install uv
uses: astral-sh/setup-uv@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
cache: 'pip'
python-version: "3.14"
- name: Install dependencies
run: |
# use latest BoTorch
uv pip install git+https://github.com/cornellius-gp/linear_operator.git
uv pip install git+https://github.com/cornellius-gp/gpytorch.git
uv pip install git+https://github.com/pytorch/botorch.git
uv pip install -e ".[dev,mysql,notebook]"
uv pip install --upgrade build setuptools setuptools_scm wheel
- name: Extract reduced version and save to env var
# strip the commit hash from the version to enable upload to pypi
# env var will persist for subsequent steps
run: |
no_local_version=$(python -m setuptools_scm | cut -d "+" -f 1)
echo "SETUPTOOLS_SCM_PRETEND_VERSION=${no_local_version}" >> $GITHUB_ENV
- name: Build wheel
run: |
python -m build --sdist --wheel
- name: Deploy to Test PyPI
uses: pypa/gh-action-pypi-publish@ed0c53931b1dc9bd32cbe73a98c7f6766f8a527e # release/v1.13
with:
repository-url: https://test.pypi.org/legacy/
skip-existing: true
verbose: true
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. Each Linux x64 job moves to the Latchkey size matching its vCPU count,latchkey-smallfor a standard 2 vCPU runner; macOS, Windows and arm64 jobs stay as written. - 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.
- 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 4 jobs per trigger. 1 of the 4 runs on a standard GitHub-hosted Linux x64 runner, which in a private repository bills $0.006 a minute against $0.0025 on latchkey-small, 58% lower; in a public repository like this one it is free. Estimate the monthly difference with your own run counts.
Actions used in this workflow
- actions/checkout
- astral-sh/setup-uv
- actions/setup-python
- pypa/gh-action-pypi-publish