Skip to content
Latchkey

CI workflow (abey79/vpype)

The CI workflow from abey79/vpype, explained and optimized by Latchkey.

D

CI health: D - needs work

Run this on Latchkey for self-healing, caching, and up to 58% lower cost.

Grade your own workflow free or run it on Latchkey →
Source: abey79/vpype.github/workflows/python-lint-tests.ymlLicense MITView source

What it does

This is the CI workflow from the abey79/vpype 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: CI

on:
  push:
    branches:
      - master
      - release/*
  pull_request:
    branches:
      - master
      - release/*

jobs:

  # ----------------------------------------
  lint-tests:
    strategy:
      fail-fast: true
      matrix:
        python-version: ['3.11', '3.11', '3.13']
        os: [ubuntu-latest, macos-latest, windows-latest]
    defaults:
      run:
        shell: bash
    runs-on: ${{ matrix.os }}

    steps:
    - uses: actions/checkout@v4

    - name: Install Just
      uses: extractions/setup-just@v2

    - name: Install Python
      uses: actions/setup-python@v5
      with:
          python-version: ${{ matrix.python-version }}

    - name: Install poetry
      run: pipx install --python ${{ matrix.python-version }} poetry!=1.4.1

    # TODO: cache poetry venv

    - name: Install project
      run: |
        python --version
        poetry config virtualenvs.in-project true
        poetry env use ${{ matrix.python-version }}
        poetry install -E all --with docs,dev

    - name: Lint and static analysis
      if:  matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'  # no need to run that 9x
      run: |
        poetry run just lint

    # needed for tests to work on ubuntu (libEGL.so.1)
    - name: Install EGL mesa
      if: matrix.os == 'ubuntu-latest'
      run: |
        sudo apt-get update -y -qq
        sudo apt-get install -y -qq libegl1-mesa-dev

    # PYTEST STRATEGY
    # macOS is the only runner who has working ModernGL behaviour
    # macOS + 3.11 is used for code coverage
    - name: Pytest (code coverage)
      run: |
        poetry run pytest --cov=./ --cov-report=xml
      if: matrix.os == 'macos-latest' && matrix.python-version == '3.12'
    - name: Pytest
      run: |
        poetry run pytest
      if: matrix.os == 'macos-latest' && matrix.python-version != '3.12'
    - name: Pytest (no image similarity check)
      run: |
        poetry run pytest --skip-image-similarity
      if: matrix.os != 'macos-latest'
    - name: Upload comparison test results
      if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: test_report_${{ runner.os }}_${{ matrix.python-version }}
        path: |
          test_report_img_sim/**/*
          test_report_reference_svg/**/*
        if-no-files-found: ignore
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v3
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        file: ./coverage.xml
      if: matrix.os == 'macos-latest' && matrix.python-version == '3.12'

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: CI
 
on:
  push:
    branches:
      - master
      - release/*
  pull_request:
    branches:
      - master
      - release/*
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
 
  # ----------------------------------------
  lint-tests:
    strategy:
      fail-fast: true
      matrix:
        python-version: ['3.11', '3.11', '3.13']
        os: [ubuntu-latest, macos-latest, windows-latest]
    defaults:
      run:
        shell: bash
    runs-on: ${{ matrix.os }}
 
    steps:
    - uses: actions/checkout@v4
 
    - name: Install Just
      uses: extractions/setup-just@v2
 
    - name: Install Python
      uses: actions/setup-python@v5
      with:
        cache: 'pip'
          python-version: ${{ matrix.python-version }}
 
    - name: Install poetry
      run: pipx install --python ${{ matrix.python-version }} poetry!=1.4.1
 
    # TODO: cache poetry venv
 
    - name: Install project
      run: |
        python --version
        poetry config virtualenvs.in-project true
        poetry env use ${{ matrix.python-version }}
        poetry install -E all --with docs,dev
 
    - name: Lint and static analysis
      if:  matrix.os == 'ubuntu-latest' && matrix.python-version == '3.12'  # no need to run that 9x
      run: |
        poetry run just lint
 
    # needed for tests to work on ubuntu (libEGL.so.1)
    - name: Install EGL mesa
      if: matrix.os == 'ubuntu-latest'
      run: |
        sudo apt-get update -y -qq
        sudo apt-get install -y -qq libegl1-mesa-dev
 
    # PYTEST STRATEGY
    # macOS is the only runner who has working ModernGL behaviour
    # macOS + 3.11 is used for code coverage
    - name: Pytest (code coverage)
      run: |
        poetry run pytest --cov=./ --cov-report=xml
      if: matrix.os == 'macos-latest' && matrix.python-version == '3.12'
    - name: Pytest
      run: |
        poetry run pytest
      if: matrix.os == 'macos-latest' && matrix.python-version != '3.12'
    - name: Pytest (no image similarity check)
      run: |
        poetry run pytest --skip-image-similarity
      if: matrix.os != 'macos-latest'
    - name: Upload comparison test results
      if: failure()
      uses: actions/upload-artifact@v4
      with:
        name: test_report_${{ runner.os }}_${{ matrix.python-version }}
        path: |
          test_report_img_sim/**/*
          test_report_reference_svg/**/*
        if-no-files-found: ignore
    - name: Upload coverage to Codecov
      uses: codecov/codecov-action@v3
      with:
        token: ${{ secrets.CODECOV_TOKEN }}
        file: ./coverage.xml
      if: matrix.os == 'macos-latest' && matrix.python-version == '3.12'
 

What changed

2 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 1 job (9 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