Skip to content
Latchkey

CI workflow (coze-dev/coze-py)

The CI workflow from coze-dev/coze-py, explained and optimized by Latchkey.

F

CI health: F - at risk

Point runs-on at Latchkey and get caching, run de-duplication, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.

Grade your own workflow free or run it on Latchkey →
Source: coze-dev/coze-py.github/workflows/ci.ymlLicense MITView source

What it does

This is the CI workflow from the coze-dev/coze-py 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: CI
on:
  push:
    branches:
      - main
  pull_request:
  merge_group:

permissions: write-all

jobs:
  test:
    runs-on: ${{ matrix.os }}
    name: test (Python ${{ matrix.python-version }} on ${{ matrix.os-label }})
    strategy:
      fail-fast: false
      matrix:
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
        os: [ "ubuntu-latest" ]
        os-label: [ "Ubuntu" ]
        include:
          - { python-version: "3.8", os: "windows-latest", os-label: "Windows" }
          - { python-version: "3.8", os: "macos-latest", os-label: "macOS" }
          - { python-version: "3.7", os: "ubuntu-22.04", os-label: "Ubuntu" }
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          python-version: "${{ matrix.python-version }}"
      - name: Install Dependencies
        run: |
          pip install poetry 
          poetry install
      - name: Build
        run: |
          poetry build
      - name: Check
        run: |
          poetry run ruff check cozepy
          poetry run ruff format --check
          poetry run mypy .
      - name: Run tests
        run: poetry run pytest --cov --cov-report=xml
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}

  test_success:
    # this aggregates success state of all jobs listed in `needs`
    # this is the only required check to pass CI
    name: "Test success"
    if: always()
    runs-on: ubuntu-latest
    needs: [ test ]
    steps:
      - name: "Success"
        if: needs.test.result == 'success'
        run: true
        shell: bash
      - name: "Failure"
        if: needs.test.result != 'success'
        run: false
        shell: bash

  draft:
    runs-on: ubuntu-latest
    needs: test_success
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: release-drafter/release-drafter@v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

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:
  push:
    branches:
      - main
  pull_request:
  merge_group:
 
permissions: write-all
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  test:
    timeout-minutes: 30
    runs-on: ${{ matrix.os }}
    name: test (Python ${{ matrix.python-version }} on ${{ matrix.os-label }})
    strategy:
      fail-fast: false
      matrix:
        python-version: [ "3.8", "3.9", "3.10", "3.11", "3.12" ]
        os: [ "ubuntu-latest" ]
        os-label: [ "Ubuntu" ]
        include:
          - { python-version: "3.8", os: "windows-latest", os-label: "Windows" }
          - { python-version: "3.8", os: "macos-latest", os-label: "macOS" }
          - { python-version: "3.7", os: "ubuntu-22.04", os-label: "Ubuntu" }
    steps:
      - uses: actions/checkout@v3
      - name: Set up Python
        uses: actions/setup-python@v4
        with:
          cache: 'pip'
          python-version: "${{ matrix.python-version }}"
      - name: Install Dependencies
        run: |
          pip install poetry 
          poetry install
      - name: Build
        run: |
          poetry build
      - name: Check
        run: |
          poetry run ruff check cozepy
          poetry run ruff format --check
          poetry run mypy .
      - name: Run tests
        run: poetry run pytest --cov --cov-report=xml
      - name: Upload coverage to Codecov
        uses: codecov/codecov-action@v3
        with:
          token: ${{ secrets.CODECOV_TOKEN }}
 
  test_success:
    timeout-minutes: 30
    # this aggregates success state of all jobs listed in `needs`
    # this is the only required check to pass CI
    name: "Test success"
    if: always()
    runs-on: latchkey-small
    needs: [ test ]
    steps:
      - name: "Success"
        if: needs.test.result == 'success'
        run: true
        shell: bash
      - name: "Failure"
        if: needs.test.result != 'success'
        run: false
        shell: bash
 
  draft:
    timeout-minutes: 30
    runs-on: latchkey-small
    needs: test_success
    if: github.ref == 'refs/heads/main'
    steps:
      - uses: release-drafter/release-drafter@v5
        env:
          GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
 

What changed

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.

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:

This workflow runs 3 jobs (7 with the matrix expanded) per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow