Skip to content
Latchkey

Nightly Cron workflow (facebook/Ax)

The Nightly Cron workflow from facebook/Ax, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: facebook/Ax.github/workflows/cron.ymlLicense MITView source

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

workflow (.yml)
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: true

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: 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: 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

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:

This workflow runs 4 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow