CI workflow (xai-org/xai-sdk-python)
The CI workflow from xai-org/xai-sdk-python, explained and optimized by Latchkey.
D
CI health: D - needs work
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 CI workflow from the xai-org/xai-sdk-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
workflow (.yml)
name: CI
on:
pull_request:
branches:
- main
workflow_dispatch:
permissions:
contents: read
jobs:
ci-checks:
runs-on: xai-sdk-python-runner
strategy:
matrix:
python-version: ["3.10", "3.11", "3.12", "3.13"]
fail-fast: false
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1
- name: Setup Python ${{ matrix.python-version }}
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@c7f87aa956e4c323abf06d5dec078e358f6b4d04 # v6.0.0
with:
version: "0.7.3"
- name: Install dependencies
run: uv sync --locked
- name: Check formatting
run: uv run ruff format --check
- name: Check linting
run: uv run ruff check --output-format=github
- name: Check type safety
run: uv run pyright
- name: Run tests
run: uv run pytest -n auto -v
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: CI on: pull_request: branches: - main workflow_dispatch: permissions: contents: read concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: ci-checks: timeout-minutes: 30 runs-on: xai-sdk-python-runner strategy: matrix: python-version: ["3.10", "3.11", "3.12", "3.13"] fail-fast: false steps: - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4.3.1 - name: Setup Python ${{ matrix.python-version }} uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0 with: cache: 'pip' python-version: ${{ matrix.python-version }} - name: Install uv uses: astral-sh/setup-uv@c7f87aa956e4c323abf06d5dec078e358f6b4d04 # v6.0.0 with: version: "0.7.3" - name: Install dependencies run: uv sync --locked - name: Check formatting run: uv run ruff format --check - name: Check linting run: uv run ruff check --output-format=github - name: Check type safety run: uv run pyright - name: Run tests run: uv run pytest -n auto -v
What changed
- Cancel superseded runs when a branch or PR gets a newer push.
- Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
This workflow runs 1 job (4 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.