Test workflow (lorien/grab)
The Test workflow from lorien/grab, explained and optimized by Latchkey.
C
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Test workflow from the lorien/grab 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: Test
on: ["push", "pull_request"]
jobs:
without-db:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [windows-latest]
python: ['3.13']
network_service: ['multicurl', 'threaded']
grab_transport: ['pycurl', 'urllib3']
exclude:
- network_service: 'multicurl'
grab_transport: 'urllib3'
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test
with:
python: ${{ matrix.python }}
database_enabled: false
os: ${{ matrix.os }}
network_service: ${{ matrix.network_service }}
grab_transport: ${{ matrix.grab_transport }}
with-db:
runs-on: ubuntu-latest
strategy:
matrix:
python: ['2.7', '3.9', '3.13']
network_service: ['multicurl', 'threaded']
grab_transport: ['pycurl', 'urllib3']
exclude:
- network_service: 'multicurl'
grab_transport: 'urllib3'
services:
redis:
image: redis:7.2
ports:
- 6379:6379
options: >-
--health-cmd "redis-cli ping"
--health-interval 5s
--health-timeout 2s
--health-retries 5
mysql:
image: mysql:8.0
env:
# same config must be in test_settings.py
MYSQL_ALLOW_EMPTY_PASSWORD: yes
MYSQL_USER: github
MYSQL_PASSWORD: github
MYSQL_DATABASE: grab_test
ports:
- 3306:3306
options: >-
--health-cmd="mysqladmin ping -uroot -prootpassword"
--health-interval=5s
--health-timeout=2s
--health-retries=10
postgres:
image: postgres:16
env:
# same config must be in test_settings.py
POSTGRES_USER: github
POSTGRES_PASSWORD: github
POSTGRES_DB: grab_test
ports:
- 5432:5432
options: >-
--health-cmd "pg_isready -U testuser"
--health-interval 5s
--health-timeout 2s
--health-retries 10
mongodb:
image: mongo:7.0
ports:
- 27017:27017
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/test
with:
python: ${{ matrix.python }}
database_enabled: true
os: 'ubuntu-latest'
network_service: ${{ matrix.network_service }}
grab_transport: ${{ matrix.grab_transport }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Test on: ["push", "pull_request"] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: without-db: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: matrix: os: [windows-latest] python: ['3.13'] network_service: ['multicurl', 'threaded'] grab_transport: ['pycurl', 'urllib3'] exclude: - network_service: 'multicurl' grab_transport: 'urllib3' steps: - uses: actions/checkout@v4 - uses: ./.github/actions/test with: python: ${{ matrix.python }} database_enabled: false os: ${{ matrix.os }} network_service: ${{ matrix.network_service }} grab_transport: ${{ matrix.grab_transport }} with-db: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: python: ['2.7', '3.9', '3.13'] network_service: ['multicurl', 'threaded'] grab_transport: ['pycurl', 'urllib3'] exclude: - network_service: 'multicurl' grab_transport: 'urllib3' services: redis: image: redis:7.2 ports: - 6379:6379 options: >- --health-cmd "redis-cli ping" --health-interval 5s --health-timeout 2s --health-retries 5 mysql: image: mysql:8.0 env: # same config must be in test_settings.py MYSQL_ALLOW_EMPTY_PASSWORD: yes MYSQL_USER: github MYSQL_PASSWORD: github MYSQL_DATABASE: grab_test ports: - 3306:3306 options: >- --health-cmd="mysqladmin ping -uroot -prootpassword" --health-interval=5s --health-timeout=2s --health-retries=10 postgres: image: postgres:16 env: # same config must be in test_settings.py POSTGRES_USER: github POSTGRES_PASSWORD: github POSTGRES_DB: grab_test ports: - 5432:5432 options: >- --health-cmd "pg_isready -U testuser" --health-interval 5s --health-timeout 2s --health-retries 10 mongodb: image: mongo:7.0 ports: - 27017:27017 steps: - uses: actions/checkout@v4 - uses: ./.github/actions/test with: python: ${{ matrix.python }} database_enabled: true os: 'ubuntu-latest' network_service: ${{ matrix.network_service }} grab_transport: ${{ matrix.grab_transport }}
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cancel superseded runs when a branch or PR gets a newer push.
- Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 2 jobs (16 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.