Skip to content
Latchkey

build workflow (marshmallow-code/marshmallow)

The build workflow from marshmallow-code/marshmallow, explained and optimized by Latchkey.

C

CI health: C - fair

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

Grade your own workflow free or run it on Latchkey →
Source: marshmallow-code/marshmallow.github/workflows/build-release.ymlLicense MITView source

What it does

This is the build workflow from the marshmallow-code/marshmallow 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: build
on:
  push:
    branches: ["dev", "*.x-line"]
    tags: ["*"]
  pull_request:

permissions:
  contents: read

jobs:
  tests:
    name: ${{ matrix.name }}
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        include:
          - { name: "3.10", tox: py310 }
          - { name: "3.14", tox: py314 }
          - { name: "mypy", tox: mypy }
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
        with:
          persist-credentials: false
      - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with: # zizmor: ignore[cache-poisoning] cache key is lockfile-derived
          enable-cache: true
      - run: uv run tox -e ${{ matrix.tox }}
  build:
    name: Build package
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
        with:
          persist-credentials: false
      - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with: # zizmor: ignore[cache-poisoning] cache key is lockfile-derived
          enable-cache: true
      - run: uv build
      - run: uvx twine check --strict dist/*
      - name: Store the distribution packages
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        with:
          name: python-package-distributions
          path: dist/
  # this duplicates pre-commit.ci, so only run it on tags
  # it guarantees that linting is passing prior to a release
  lint-pre-release:
    if: startsWith(github.ref, 'refs/tags')
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
        with:
          persist-credentials: false
      - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with: # zizmor: ignore[cache-poisoning] cache key is lockfile-derived
          enable-cache: true
      - run: uv run tox -e lint
  publish-to-pypi:
    name: PyPI release
    if: startsWith(github.ref, 'refs/tags/')
    needs: [build, tests, lint-pre-release]
    runs-on: ubuntu-latest
    environment:
      name: pypi
      url: https://pypi.org/p/marshmallow
    permissions:
      id-token: write
    steps:
      - name: Download all the dists
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
        with:
          name: python-package-distributions
          path: dist/
      - name: Publish distribution to PyPI
        uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: build
on:
  push:
    branches: ["dev", "*.x-line"]
    tags: ["*"]
  pull_request:
 
permissions:
  contents: read
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  tests:
    timeout-minutes: 30
    name: ${{ matrix.name }}
    runs-on: latchkey-small
    strategy:
      fail-fast: false
      matrix:
        include:
          - { name: "3.10", tox: py310 }
          - { name: "3.14", tox: py314 }
          - { name: "mypy", tox: mypy }
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
        with:
          persist-credentials: false
      - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with: # zizmor: ignore[cache-poisoning] cache key is lockfile-derived
          enable-cache: true
      - run: uv run tox -e ${{ matrix.tox }}
  build:
    timeout-minutes: 30
    name: Build package
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
        with:
          persist-credentials: false
      - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with: # zizmor: ignore[cache-poisoning] cache key is lockfile-derived
          enable-cache: true
      - run: uv build
      - run: uvx twine check --strict dist/*
      - name: Store the distribution packages
        uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7
        with:
          name: python-package-distributions
          path: dist/
  # this duplicates pre-commit.ci, so only run it on tags
  # it guarantees that linting is passing prior to a release
  lint-pre-release:
    timeout-minutes: 30
    if: startsWith(github.ref, 'refs/tags')
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
        with:
          persist-credentials: false
      - uses: astral-sh/setup-uv@fac544c07dec837d0ccb6301d7b5580bf5edae39 # v8.2.0
        with: # zizmor: ignore[cache-poisoning] cache key is lockfile-derived
          enable-cache: true
      - run: uv run tox -e lint
  publish-to-pypi:
    timeout-minutes: 30
    name: PyPI release
    if: startsWith(github.ref, 'refs/tags/')
    needs: [build, tests, lint-pre-release]
    runs-on: latchkey-small
    environment:
      name: pypi
      url: https://pypi.org/p/marshmallow
    permissions:
      id-token: write
    steps:
      - name: Download all the dists
        uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8
        with:
          name: python-package-distributions
          path: dist/
      - name: Publish distribution to PyPI
        uses: pypa/gh-action-pypi-publish@cef221092ed1bacb1cc03d23a2d87d1d172e277b # release/v1
 

What changed

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