Test and Lint workflow (typesense/typesense-python)
The Test and Lint workflow from typesense/typesense-python, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Test and Lint workflow from the typesense/typesense-python repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Test and Lint
on:
push:
branches: [ master ]
pull_request:
branches: [ master ]
jobs:
quality:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"]
steps:
- name: Start Typesense
run: |
docker run -d \
-p 8108:8108 \
--name typesense \
-v /tmp/typesense-data:/data \
-v /tmp/typesense-analytics-data:/analytics-data \
typesense/typesense:30.0.alpha1 \
--api-key=xyz \
--data-dir=/data \
--enable-search-analytics=true \
--analytics-dir=/analytics-data \
--analytics-flush-interval=60 \
--analytics-minute-rate-limit=50 \
--enable-cors
- name: Wait for Typesense
run: |
timeout 20 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8108/health)" != "200" ]]; do sleep 1; done' || false
- uses: actions/checkout@v4
- name: Install uv and set the python version
uses: astral-sh/setup-uv@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install the project
run: uv sync --locked --all-extras --dev
- name: Check sync generation
run: uv run python utils/run-unasync.py --check
- name: Lint with Ruff
run: |
uv run ruff check src/typesense
uv run ruff format src/typesense
- name: Check types with mypy
run: |
uv run mypy src/typesense
- name: Run tests and coverage (excluding OpenAI)
run: |
uv run coverage run -m pytest -m "not open_ai"
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Test and Lint on: push: branches: [ master ] pull_request: branches: [ master ] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: quality: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: python-version: ["3.9", "3.10", "3.11", "3.12", "3.13"] steps: - name: Start Typesense run: | docker run -d \ -p 8108:8108 \ --name typesense \ -v /tmp/typesense-data:/data \ -v /tmp/typesense-analytics-data:/analytics-data \ typesense/typesense:30.0.alpha1 \ --api-key=xyz \ --data-dir=/data \ --enable-search-analytics=true \ --analytics-dir=/analytics-data \ --analytics-flush-interval=60 \ --analytics-minute-rate-limit=50 \ --enable-cors - name: Wait for Typesense run: | timeout 20 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:8108/health)" != "200" ]]; do sleep 1; done' || false - uses: actions/checkout@v4 - name: Install uv and set the python version uses: astral-sh/setup-uv@v5 with: python-version: ${{ matrix.python-version }} - name: Install the project run: uv sync --locked --all-extras --dev - name: Check sync generation run: uv run python utils/run-unasync.py --check - name: Lint with Ruff run: | uv run ruff check src/typesense uv run ruff format src/typesense - name: Check types with mypy run: | uv run mypy src/typesense - name: Run tests and coverage (excluding OpenAI) run: | uv run coverage run -m pytest -m "not open_ai"
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.
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.
This workflow runs 1 job (5 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.