Python workflow (roniemartinez/latex2mathml)
The Python workflow from roniemartinez/latex2mathml, explained and optimized by Latchkey.
CI health: B - good
Run this on Latchkey for self-healing, caching, and up to 58% lower cost.
Grade your own workflow free or run it on Latchkey →What it does
This is the Python workflow from the roniemartinez/latex2mathml 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
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python
on:
push:
branches:
- master
pull_request:
branches:
- master
workflow_dispatch:
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest, macos-latest, windows-latest ]
python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14' ]
steps:
- uses: actions/checkout@v7.0.0
- name: Install uv
uses: astral-sh/setup-uv@v8.3.2
with:
enable-cache: true
- name: Set up Python ${{ matrix.python-version }}
run: uv python install ${{ matrix.python-version }}
- uses: actions/cache@v6.1.0
with:
path: .mypy_cache
key: ${{ runner.os }}-${{ matrix.python-version }}-mypy-${{ hashFiles('**/uv.lock') }}
restore-keys: |
${{ runner.os }}-${{ matrix.python-version }}-mypy-
- name: Install dependencies
run: uv sync
- name: Lint
run: make lint
- name: Test
run: make test
- name: Code Coverage
uses: codecov/codecov-action@v7.0.0
if: ${{ success() }}
The same workflow, on Latchkey
Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions # For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions name: Python on: push: branches: - master pull_request: branches: - master workflow_dispatch: concurrency: group: ${{ github.ref }} cancel-in-progress: true jobs: test: timeout-minutes: 30 runs-on: ${{ matrix.os }} strategy: matrix: os: [ ubuntu-latest, macos-latest, windows-latest ] python-version: [ '3.10', '3.11', '3.12', '3.13', '3.14' ] steps: - uses: actions/checkout@v7.0.0 - name: Install uv uses: astral-sh/setup-uv@v8.3.2 with: enable-cache: true - name: Set up Python ${{ matrix.python-version }} run: uv python install ${{ matrix.python-version }} - uses: actions/cache@v6.1.0 with: path: .mypy_cache key: ${{ runner.os }}-${{ matrix.python-version }}-mypy-${{ hashFiles('**/uv.lock') }} restore-keys: | ${{ runner.os }}-${{ matrix.python-version }}-mypy- - name: Install dependencies run: uv sync - name: Lint run: make lint - name: Test run: make test - name: Code Coverage uses: codecov/codecov-action@v7.0.0 if: ${{ success() }}
What changed
- Add a job timeout so a hung step cannot burn hours of runner time.
2 third-party actions are referenced by a movable tag. Pin them to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
This workflow runs 1 job (15 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.