Skip to content
Latchkey

Python Connectors CI workflow (binance/binance-connector-python)

The Python Connectors CI workflow from binance/binance-connector-python, explained and optimized by Latchkey.

C

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.

Grade your own workflow free or run it on Latchkey →
Source: binance/binance-connector-python.github/workflows/ci.yamlLicense MITView source

What it does

This is the Python Connectors CI workflow from the binance/binance-connector-python 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: Python Connectors CI

on:
  push:
    branches: 
      - master
  workflow_dispatch:

jobs:
  detect-clients:
    runs-on: ubuntu-latest
    outputs:
      clients: ${{ steps.detect.outputs.clients }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3

      - name: Detect all clients
        id: detect
        run: |
          ALL_CLIENTS=$(ls -d clients/*/ | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]')
          echo "Detected clients: $ALL_CLIENTS"
          echo "clients=$ALL_CLIENTS" >> $GITHUB_ENV
          echo "::set-output name=clients::$ALL_CLIENTS"

  build:
    needs: detect-clients
    runs-on: ubuntu-latest
    strategy:
      matrix:
        client: ${{ fromJson(needs.detect-clients.outputs.clients) }}
        python-version: ["3.12"]
        poetry-version: ["1.8.4"]

    steps:
      - name: Checkout code
        uses: actions/checkout@v4

      - name: Install dependencies
        run: |
          pip3 install --upgrade pip && \
          pip3 install ruff black && \
          curl -sSL https://install.python-poetry.org | python3 -
          echo "$HOME/.local/bin" >> $GITHUB_PATH

      - name: Build ${{ matrix.client }} client
        run: |
          if [ "${{ matrix.client }}" == "common" ]; then
            cd common
          else
            cd clients/${{ matrix.client }}
          fi

          # Install dependencies
          poetry install

          # Format
          poetry run black .

          # Lint
          poetry run ruff check --fix .

          # Test
          poetry run pytest tests

          # Build
          poetry build

The same workflow, on Latchkey

Removes redundant runs and caps runaway jobs. Added and changed lines are highlighted.

name: Python Connectors CI
 
on:
  push:
    branches: 
      - master
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  detect-clients:
    timeout-minutes: 30
    runs-on: latchkey-small
    outputs:
      clients: ${{ steps.detect.outputs.clients }}
    steps:
      - name: Checkout repository
        uses: actions/checkout@v3
 
      - name: Detect all clients
        id: detect
        run: |
          ALL_CLIENTS=$(ls -d clients/*/ | xargs -n 1 basename | jq -R -s -c 'split("\n")[:-1]')
          echo "Detected clients: $ALL_CLIENTS"
          echo "clients=$ALL_CLIENTS" >> $GITHUB_ENV
          echo "::set-output name=clients::$ALL_CLIENTS"
 
  build:
    timeout-minutes: 30
    needs: detect-clients
    runs-on: latchkey-small
    strategy:
      matrix:
        client: ${{ fromJson(needs.detect-clients.outputs.clients) }}
        python-version: ["3.12"]
        poetry-version: ["1.8.4"]
 
    steps:
      - name: Checkout code
        uses: actions/checkout@v4
 
      - name: Install dependencies
        run: |
          pip3 install --upgrade pip && \
          pip3 install ruff black && \
          curl -sSL https://install.python-poetry.org | python3 -
          echo "$HOME/.local/bin" >> $GITHUB_PATH
 
      - name: Build ${{ matrix.client }} client
        run: |
          if [ "${{ matrix.client }}" == "common" ]; then
            cd common
          else
            cd clients/${{ matrix.client }}
          fi
 
          # Install dependencies
          poetry install
 
          # Format
          poetry run black .
 
          # Lint
          poetry run ruff check --fix .
 
          # Test
          poetry run pytest tests
 
          # Build
          poetry build
 

What changed

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 2 jobs per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.

Actions used in this workflow