Skip to content
Latchkey

testing workflow (r05323028/eyes)

The testing workflow from r05323028/eyes, 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: r05323028/eyes.github/workflows/testing.ymlLicense MITView source

What it does

This is the testing workflow from the r05323028/eyes 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: testing

on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main

jobs:
  test:
    name: Testing
    runs-on: ubuntu-latest

    services:
      mysql:
        image: mysql:8
        env:
          MYSQL_DATABASE: eyes
          MYSQL_USER: eyes
          MYSQL_PASSWORD: example
          MYSQL_ROOT_PASSWORD: example
          MYSQL_HOST: 127.0.0.1
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      redis:
        image: redis:latest
        ports:
          - 6379:6379

    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup Python
        uses: actions/setup-python@v1
        with:
          python-version: 3.7
      - name: Install Poetry
        run: |
          pip install poetry
      - name: Install Dependencies
        run: |
          poetry install
      - name: Initialize Database
        run: |
          poetry run dotenv -f .env.testing run eyes db init
      - name: Download spacy model
        run: |
          poetry run spacy download zh_core_web_sm
      - name: Run Celery Worker
        run: |
          poetry run dotenv -f .env.testing run celery -A eyes.celery worker --detach
      - name: Run Testing
        run: |
          poetry run dotenv -f .env.testing run pytest -s -m 'not slow and not dcard'
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v2

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: testing
 
on:
  pull_request:
    branches:
      - main
  push:
    branches:
      - main
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    name: Testing
    runs-on: latchkey-small
 
    services:
      mysql:
        image: mysql:8
        env:
          MYSQL_DATABASE: eyes
          MYSQL_USER: eyes
          MYSQL_PASSWORD: example
          MYSQL_ROOT_PASSWORD: example
          MYSQL_HOST: 127.0.0.1
        ports:
          - 3306:3306
        options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3
      redis:
        image: redis:latest
        ports:
          - 6379:6379
 
    steps:
      - name: Checkout code
        uses: actions/checkout@v2
      - name: Setup Python
        uses: actions/setup-python@v1
        with:
          cache: 'pip'
          python-version: 3.7
      - name: Install Poetry
        run: |
          pip install poetry
      - name: Install Dependencies
        run: |
          poetry install
      - name: Initialize Database
        run: |
          poetry run dotenv -f .env.testing run eyes db init
      - name: Download spacy model
        run: |
          poetry run spacy download zh_core_web_sm
      - name: Run Celery Worker
        run: |
          poetry run dotenv -f .env.testing run celery -A eyes.celery worker --detach
      - name: Run Testing
        run: |
          poetry run dotenv -f .env.testing run pytest -s -m 'not slow and not dcard'
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v2
 

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 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow