Skip to content
Latchkey

Test workflow (laixintao/iredis)

The Test workflow from laixintao/iredis, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, 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: laixintao/iredis.github/workflows/test.yamlLicense BSD-3-ClauseView source

What it does

This is the Test workflow from the laixintao/iredis repository, a real project running GitHub Actions. It is shown here with attribution under its BSD-3-Clause license.

Below, Latchkey shows a faster, safer version produced by its optimization engine.

The workflow

workflow (.yml)
name: Test

on:
  pull_request:
  push:
    branches:
      - master

jobs:
  test:
    name: Pytest
    strategy:
      fail-fast: false
      matrix:
        os: ["ubuntu-24.04"]
        python: ["3.10", "3.11.1", "3.12"]
        redis: [5, 6, 7, 7.2]
    runs-on: ${{ matrix.os }}

    services:
      redis:
        image: redis:${{ matrix.redis }}
        ports:
          - 6379:6379
        options: --entrypoint redis-server

    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python }}
          architecture: "x64"
      - name: Cache deps
        uses: actions/cache@v4
        with:
          path: |
            ~/.cache/pypoetry
            ~/.cache/pip
          key: deps-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('poetry.lock') }}

      - name: Install Poetry
        run: pip install poetry

      - name: Install dependencies
        run: |
          poetry config virtualenvs.in-project true
          poetry install --no-interaction --no-root
          poetry run python -c "import sys; print(sys.version)"
  lint:
    name: flake8 & black
    runs-on: ubuntu-latest

    steps:
      - uses: actions/checkout@v4

      - uses: actions/setup-python@v5
        with:
          python-version: 3.12

      - name: Cache pip
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: lint-${{ runner.os }}-3.12

      - name: Install tools
        run: pip install flake8==7.1.1 black==24.10.0

      - name: Flake8
        run: flake8 .

      - name: Black
        run: black --check .

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: Test
 
on:
  pull_request:
  push:
    branches:
      - master
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    name: Pytest
    strategy:
      fail-fast: false
      matrix:
        os: ["ubuntu-24.04"]
        python: ["3.10", "3.11.1", "3.12"]
        redis: [5, 6, 7, 7.2]
    runs-on: ${{ matrix.os }}
 
    services:
      redis:
        image: redis:${{ matrix.redis }}
        ports:
          - 6379:6379
        options: --entrypoint redis-server
 
    steps:
      - uses: actions/checkout@v2
      - uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: ${{ matrix.python }}
          architecture: "x64"
      - name: Cache deps
        uses: actions/cache@v4
        with:
          path: |
            ~/.cache/pypoetry
            ~/.cache/pip
          key: deps-${{ runner.os }}-${{ matrix.python }}-${{ hashFiles('poetry.lock') }}
 
      - name: Install Poetry
        run: pip install poetry
 
      - name: Install dependencies
        run: |
          poetry config virtualenvs.in-project true
          poetry install --no-interaction --no-root
          poetry run python -c "import sys; print(sys.version)"
  lint:
    timeout-minutes: 30
    name: flake8 & black
    runs-on: latchkey-small
 
    steps:
      - uses: actions/checkout@v4
 
      - uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: 3.12
 
      - name: Cache pip
        uses: actions/cache@v4
        with:
          path: ~/.cache/pip
          key: lint-${{ runner.os }}-3.12
 
      - name: Install tools
        run: pip install flake8==7.1.1 black==24.10.0
 
      - name: Flake8
        run: flake8 .
 
      - name: Black
        run: black --check .
 

What changed

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 (13 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