Skip to content
Latchkey

Unittests & Auto-publish workflow (jax-ml/bayeux)

The Unittests & Auto-publish workflow from jax-ml/bayeux, explained and optimized by Latchkey.

D

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.

Grade your own workflow free or run it on Latchkey →
Source: jax-ml/bayeux.github/workflows/pytest_and_autopublish.ymlLicense Apache-2.0View source

What it does

This is the Unittests & Auto-publish workflow from the jax-ml/bayeux 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

workflow (.yml)
name: Unittests & Auto-publish

# Allow to trigger the workflow manually (e.g. when deps changes)
on: [push, workflow_dispatch]

jobs:
  pytest-job:
    runs-on: ubuntu-latest
    timeout-minutes: 30

    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: true

    steps:
    - uses: actions/checkout@v3

    # Install deps
    - uses: actions/setup-python@v4
      with:
        python-version: "3.10"
        # Uncomment to cache of pip dependencies (if tests too slow)
        # cache: pip
        # cache-dependency-path: '**/pyproject.toml'

    - run: pip --version
    - run: pip install -e .[dev]
    - run: pip freeze

    # Run tests (in parallel)
    - name: Run core tests
      run: pytest -vv -n auto

  # Auto-publish when version is increased
  publish-job:
    # Only try to publish if:
    # * Repo is self (prevents running from forks)
    # * Branch is `main`
    if: |
      github.repository == 'jax-ml/bayeux'
      && github.ref == 'refs/heads/main'
    needs: pytest-job  # Only publish after tests are successful
    runs-on: ubuntu-latest
    permissions:
      contents: write
    timeout-minutes: 30

    steps:
    # Publish the package (if local `__version__` > pip version)
    - uses: etils-actions/pypi-auto-publish@v1
      with:
        pypi-token: ${{ secrets.PYPI_API_TOKEN }}
        gh-token: ${{ secrets.GITHUB_TOKEN }}
        parse-changelog: 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: Unittests & Auto-publish
 
# Allow to trigger the workflow manually (e.g. when deps changes)
on: [push, workflow_dispatch]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pytest-job:
    runs-on: latchkey-small
    timeout-minutes: 30
 
    concurrency:
      group: ${{ github.workflow }}-${{ github.ref }}
      cancel-in-progress: true
 
    steps:
    - uses: actions/checkout@v3
 
    # Install deps
    - uses: actions/setup-python@v4
      with:
        cache: 'pip'
        python-version: "3.10"
        # Uncomment to cache of pip dependencies (if tests too slow)
        # cache: pip
        # cache-dependency-path: '**/pyproject.toml'
 
    - run: pip --version
    - run: pip install -e .[dev]
    - run: pip freeze
 
    # Run tests (in parallel)
    - name: Run core tests
      run: pytest -vv -n auto
 
  # Auto-publish when version is increased
  publish-job:
    # Only try to publish if:
    # * Repo is self (prevents running from forks)
    # * Branch is `main`
    if: |
      github.repository == 'jax-ml/bayeux'
      && github.ref == 'refs/heads/main'
    needs: pytest-job  # Only publish after tests are successful
    runs-on: latchkey-small
    permissions:
      contents: write
    timeout-minutes: 30
 
    steps:
    # Publish the package (if local `__version__` > pip version)
    - uses: etils-actions/pypi-auto-publish@v1
      with:
        pypi-token: ${{ secrets.PYPI_API_TOKEN }}
        gh-token: ${{ secrets.GITHUB_TOKEN }}
        parse-changelog: 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 2 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