Tests workflow (cdt15/lingam)
The Tests workflow from cdt15/lingam, explained and optimized by Latchkey.
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 Tests workflow from the cdt15/lingam 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
name: Tests
on:
push:
pull_request:
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install flake8 pytest pytest-cov
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 lingam --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 lingam --count --exit-zero --ignore=E203,E501,E741,C901 --max-line-length=127 --statistics
- name: Test with pytest
run: |
pytest -v --cov=lingam --cov-report=term-missing
build-and-install:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12"]
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Build sdist & wheel via pyproject.toml
run: |
python -m venv venv_b
source venv_b/bin/activate
python -m pip install --upgrade pip setuptools wheel build
python -m build
ls -la dist/
echo "List sdist contents:"
tar -tf dist/*.tar.gz | head -n 50
- name: Test install from wheel
run: |
python -m venv venv_w
source venv_w/bin/activate
pip install --no-cache-dir dist/*.whl
python -c "import lingam; print(lingam.__version__)"
pip check
- name: Test install from sdist
run: |
python -m venv venv_s
source venv_s/bin/activate
pip install --no-cache-dir dist/*.tar.gz
python -c "import lingam; print(lingam.__version__)"
pip check
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
name: Tests on: push: pull_request: concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: build: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: Set up Python ${{ matrix.python-version }} uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: 'pip' - name: Install dependencies run: | python -m pip install --upgrade pip pip install flake8 pytest pytest-cov if [ -f requirements.txt ]; then pip install -r requirements.txt; fi - name: Lint with flake8 run: | # stop the build if there are Python syntax errors or undefined names flake8 lingam --count --select=E9,F63,F7,F82 --show-source --statistics # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide flake8 lingam --count --exit-zero --ignore=E203,E501,E741,C901 --max-line-length=127 --statistics - name: Test with pytest run: | pytest -v --cov=lingam --cov-report=term-missing build-and-install: timeout-minutes: 30 runs-on: latchkey-small strategy: matrix: python-version: ["3.10", "3.11", "3.12"] steps: - uses: actions/checkout@v4 - name: Set up Python uses: actions/setup-python@v5 with: python-version: ${{ matrix.python-version }} cache: 'pip' - name: Build sdist & wheel via pyproject.toml run: | python -m venv venv_b source venv_b/bin/activate python -m pip install --upgrade pip setuptools wheel build python -m build ls -la dist/ echo "List sdist contents:" tar -tf dist/*.tar.gz | head -n 50 - name: Test install from wheel run: | python -m venv venv_w source venv_w/bin/activate pip install --no-cache-dir dist/*.whl python -c "import lingam; print(lingam.__version__)" pip check - name: Test install from sdist run: | python -m venv venv_s source venv_s/bin/activate pip install --no-cache-dir dist/*.tar.gz python -c "import lingam; print(lingam.__version__)" pip check
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.
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:
- Dependency installs
This workflow runs 2 jobs (6 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.