Skip to content
Latchkey

Tests workflow (yashlamba/handwrite)

The Tests workflow from yashlamba/handwrite, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, 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: yashlamba/handwrite.github/workflows/testing.ymlLicense MITView source

What it does

This is the Tests workflow from the yashlamba/handwrite 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, pull_request]

jobs:

  lint:
      runs-on: ubuntu-latest

      steps:
        - name: Checkout full upstream repo
          uses: actions/checkout@v2
        - name: Set up Python 3.8
          uses: actions/setup-python@v2
          with:
            python-version: 3.8
        - name: Check formatting with Black
          uses: psf/black@stable

  test:
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest]
        python-version: [3.7, 3.8]

    steps:
      - name: Checkout full upstream repo
        uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install fontforge (Linux)
        if: matrix.os == 'ubuntu-latest'
        run: |
          wget -O fontforge https://github.com/fontforge/fontforge/releases/download/20201107/FontForge-2020-11-07-21ad4a1-x86_64.AppImage
          chmod +x fontforge
          sudo mv fontforge /usr/bin/
      - name: Install fontforge (Windows)
        if: matrix.os == 'windows-latest'
        run: |
          Invoke-WebRequest -Uri https://github.com/fontforge/fontforge/releases/download/20201107/FontForge-2020-11-07-Windows.exe -OutFile fontforge.exe
          .\fontforge.exe /SP- /VERYSILENT /SUPPRESSMSGBOXES /NOCANCEL | Out-Null
          echo "C:\Program Files (x86)\FontForgeBuilds\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
      - name: Install Potrace
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt install -y potrace
      - name: Install Handwrite
        run: |
          pip install -e .
      - name: Test
        run: |
          python setup.py test

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: Tests
 
on: [push, pull_request]
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
 
  lint:
    timeout-minutes: 30
      runs-on: latchkey-small
 
      steps:
        - name: Checkout full upstream repo
          uses: actions/checkout@v2
        - name: Set up Python 3.8
          uses: actions/setup-python@v2
          with:
            cache: 'pip'
            python-version: 3.8
        - name: Check formatting with Black
          uses: psf/black@stable
 
  test:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    strategy:
      matrix:
        os: [windows-latest, ubuntu-latest]
        python-version: [3.7, 3.8]
 
    steps:
      - name: Checkout full upstream repo
        uses: actions/checkout@v2
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v2
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
      - name: Install fontforge (Linux)
        if: matrix.os == 'ubuntu-latest'
        run: |
          wget -O fontforge https://github.com/fontforge/fontforge/releases/download/20201107/FontForge-2020-11-07-21ad4a1-x86_64.AppImage
          chmod +x fontforge
          sudo mv fontforge /usr/bin/
      - name: Install fontforge (Windows)
        if: matrix.os == 'windows-latest'
        run: |
          Invoke-WebRequest -Uri https://github.com/fontforge/fontforge/releases/download/20201107/FontForge-2020-11-07-Windows.exe -OutFile fontforge.exe
          .\fontforge.exe /SP- /VERYSILENT /SUPPRESSMSGBOXES /NOCANCEL | Out-Null
          echo "C:\Program Files (x86)\FontForgeBuilds\bin" | Out-File -FilePath $env:GITHUB_PATH -Encoding utf8 -Append
      - name: Install Potrace
        if: matrix.os == 'ubuntu-latest'
        run: |
          sudo apt install -y potrace
      - name: Install Handwrite
        run: |
          pip install -e .
      - name: Test
        run: |
          python setup.py test
 

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.

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