Skip to content
Latchkey

ci workflow (hardbyte/qabot)

The ci workflow from hardbyte/qabot, 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: hardbyte/qabot.github/workflows/ci.ymlLicense Apache-2.0View source

What it does

This is the ci workflow from the hardbyte/qabot 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)
on:
  push:
    branches: [main]
  pull_request:
  release:
    types: [ published ]

jobs:
  test:
    name: Unit tests / ${{ matrix.python }} / ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest ]
        python: [ "3.11", "3.12" ]
      fail-fast: true
    env:
      OS: ${{ matrix.os }}
      PYTHON: ${{ matrix.python }}

    steps:
      - uses: actions/checkout@v4

      - name: Install uv
        id: setup-uv
        uses: astral-sh/setup-uv@v2
        with:
          version: "0.4.10"
          enable-cache: true

      - name: Install Python
        id: setup-python
        run: uv python install ${{ matrix.python }}

      # Sync dependencies without dev dependencies
      - name: Sync dependencies
        run: uv sync --frozen --no-dev

      # Install the project
      - name: Install library
        run: uv pip install --no-deps .

      - name: Artifact creation
        run: uv build

      - name: Save artifacts
        uses: actions/upload-artifact@v4
        with:
          name: "${{ matrix.os }}-${{ matrix.python }}"
          path: ./dist


  upload_pypi:
    name: Release to PyPi
    needs: [test]
    permissions:
      id-token: write
    runs-on: ubuntu-latest

    # upload to PyPI only on release
    if: github.event.release && github.event.action == 'published'
    steps:
      - name: Retrieve release distributions
        uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true

      - name: Publish release distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1

  build_and_push_docker:
    name: Build and Push Docker Image
    runs-on: ubuntu-latest
    permissions:
      contents: read
      packages: write
      id-token: write # needed for signing the images with GitHub OIDC Token
    env:
      IMAGE_NAME: qabot
      IMAGE_REGISTRY: ghcr.io
      IMAGE_REPOSITORY: hardbyte
    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2

      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: ${{env.IMAGE_REGISTRY}}/${{env.IMAGE_REPOSITORY}}/${{env.IMAGE_NAME}}
          tags: |
            type=sha
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}

      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ${{ env.IMAGE_REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}

      - name: Build and push Docker image
        id: docker_build
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          platforms: linux/amd64,linux/arm64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}

The same workflow, on Latchkey

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

on:
  push:
    branches: [main]
  pull_request:
  release:
    types: [ published ]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    name: Unit tests / ${{ matrix.python }} / ${{ matrix.os }}
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [ ubuntu-latest ]
        python: [ "3.11", "3.12" ]
      fail-fast: true
    env:
      OS: ${{ matrix.os }}
      PYTHON: ${{ matrix.python }}
 
    steps:
      - uses: actions/checkout@v4
 
      - name: Install uv
        id: setup-uv
        uses: astral-sh/setup-uv@v2
        with:
          version: "0.4.10"
          enable-cache: true
 
      - name: Install Python
        id: setup-python
        run: uv python install ${{ matrix.python }}
 
      # Sync dependencies without dev dependencies
      - name: Sync dependencies
        run: uv sync --frozen --no-dev
 
      # Install the project
      - name: Install library
        run: uv pip install --no-deps .
 
      - name: Artifact creation
        run: uv build
 
      - name: Save artifacts
        uses: actions/upload-artifact@v4
        with:
          name: "${{ matrix.os }}-${{ matrix.python }}"
          path: ./dist
 
 
  upload_pypi:
    timeout-minutes: 30
    name: Release to PyPi
    needs: [test]
    permissions:
      id-token: write
    runs-on: latchkey-small
 
    # upload to PyPI only on release
    if: github.event.release && github.event.action == 'published'
    steps:
      - name: Retrieve release distributions
        uses: actions/download-artifact@v4
        with:
          path: dist
          merge-multiple: true
 
      - name: Publish release distributions to PyPI
        uses: pypa/gh-action-pypi-publish@release/v1
 
  build_and_push_docker:
    timeout-minutes: 30
    name: Build and Push Docker Image
    runs-on: latchkey-small
    permissions:
      contents: read
      packages: write
      id-token: write # needed for signing the images with GitHub OIDC Token
    env:
      IMAGE_NAME: qabot
      IMAGE_REGISTRY: ghcr.io
      IMAGE_REPOSITORY: hardbyte
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
 
      - name: Set up Docker Buildx
        uses: docker/setup-buildx-action@v2
 
      - name: Docker meta
        id: meta
        uses: docker/metadata-action@v4
        with:
          images: ${{env.IMAGE_REGISTRY}}/${{env.IMAGE_REPOSITORY}}/${{env.IMAGE_NAME}}
          tags: |
            type=sha
            type=ref,event=branch
            type=ref,event=pr
            type=semver,pattern={{version}}
            type=semver,pattern={{major}}.{{minor}}
 
      - name: Login to GitHub Container Registry
        uses: docker/login-action@v2
        with:
          registry: ${{ env.IMAGE_REGISTRY }}
          username: ${{ github.repository_owner }}
          password: ${{ secrets.GITHUB_TOKEN }}
 
      - name: Build and push Docker image
        id: docker_build
        uses: docker/build-push-action@v4
        with:
          context: .
          push: true
          platforms: linux/amd64,linux/arm64
          tags: ${{ steps.meta.outputs.tags }}
          labels: ${{ steps.meta.outputs.labels }}
 

What changed

6 third-party actions are referenced by a movable tag. Pin them 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 3 jobs (4 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