Skip to content
Latchkey

Tests workflow (newAM/monitorcontrol)

The Tests workflow from newAM/monitorcontrol, explained and optimized by Latchkey.

C

CI health: C - fair

Point runs-on at Latchkey and get 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: newAM/monitorcontrol.github/workflows/ci.ymlLicense MITView source

What it does

This is the Tests workflow from the newAM/monitorcontrol 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: Tests

on:
  push:
    branches:
      - main
    tags:
      - "*"
  pull_request:

jobs:
  style:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv run ruff check
      - run: uv run ruff format --check

  docs:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv run sphinx-build -W -b html docs public
      - uses: actions/upload-pages-artifact@v5
        with:
          path: public

  deploy_docs:
    runs-on: ubuntu-latest
    needs: docs
    if: ${{ github.ref == 'refs/heads/main' }}
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v5

  pytest:
    runs-on: ubuntu-latest
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - run: uv sync --all-extras --dev
      - run: uv run pytest -vvv --cov=monitorcontrol
      - name: Upload coverage data to coveralls.io
        run: uv run coveralls --service=github
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_FLAG_NAME: py${{ matrix.python-version }}
          COVERALLS_PARALLEL: true

  coveralls:
    name: Indicate completion to coveralls.io
    needs: pytest
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv run coveralls --finish --service=github
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

  release:
    name: PyPi Release
    runs-on: ubuntu-latest
    permissions:
      # IMPORTANT: this permission is mandatory for trusted publishing
      id-token: write
    if: startsWith(github.ref, 'refs/tags/')
    needs:
      - pytest
      - docs
      - style
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv build
      - run: uv publish --trusted-publishing always

The same workflow, on Latchkey

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

name: Tests
 
on:
  push:
    branches:
      - main
    tags:
      - "*"
  pull_request:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  style:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv run ruff check
      - run: uv run ruff format --check
 
  docs:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv run sphinx-build -W -b html docs public
      - uses: actions/upload-pages-artifact@v5
        with:
          path: public
 
  deploy_docs:
    timeout-minutes: 30
    runs-on: latchkey-small
    needs: docs
    if: ${{ github.ref == 'refs/heads/main' }}
    permissions:
      pages: write
      id-token: write
    environment:
      name: github-pages
      url: ${{ steps.deployment.outputs.page_url }}
    steps:
      - name: Deploy to GitHub Pages
        id: deployment
        uses: actions/deploy-pages@v5
 
  pytest:
    timeout-minutes: 30
    runs-on: latchkey-small
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: ${{ matrix.python-version }}
      - run: uv sync --all-extras --dev
      - run: uv run pytest -vvv --cov=monitorcontrol
      - name: Upload coverage data to coveralls.io
        run: uv run coveralls --service=github
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
          COVERALLS_FLAG_NAME: py${{ matrix.python-version }}
          COVERALLS_PARALLEL: true
 
  coveralls:
    timeout-minutes: 30
    name: Indicate completion to coveralls.io
    needs: pytest
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv run coveralls --finish --service=github
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 
  release:
    timeout-minutes: 30
    name: PyPi Release
    runs-on: latchkey-small
    permissions:
      # IMPORTANT: this permission is mandatory for trusted publishing
      id-token: write
    if: startsWith(github.ref, 'refs/tags/')
    needs:
      - pytest
      - docs
      - style
    steps:
      - uses: actions/checkout@v7
      - uses: astral-sh/setup-uv@v7
        with:
          python-version: "3.12"
      - run: uv sync --all-extras --dev
      - run: uv build
      - run: uv publish --trusted-publishing always
 

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.

This workflow runs 6 jobs (10 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow