Skip to content
Latchkey

ctypeslib-linux workflow (trolldbois/ctypeslib)

The ctypeslib-linux workflow from trolldbois/ctypeslib, 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: trolldbois/ctypeslib.github/workflows/ctypeslib-linux.ymlLicense MITView source

What it does

This is the ctypeslib-linux workflow from the trolldbois/ctypeslib 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)

# good example https://github.com/thenewguy/django-randomfields/blob/master/.github/workflows/sdist.yml
name: ctypeslib-linux

on: [push, pull_request]


jobs:
  check-package-build:
    name: Build & inspect our package.
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
        with:
          # get all history and tags for setuptools_scm to find the right version
          fetch-depth: 0
      - name: Install build dependencies
        run: |
          pip install setuptools setuptools_scm wheel build
      - name: Build package wheel
        run: python -m build -w
      - name: Upload built artifacts.
        uses: actions/upload-artifact@v4
        # By default, the artifacts and log files generated by workflows are retained for 90 days before they are automatically deleted.
        with:
          name: Packages
          path: ./dist/*
#      - uses: hynek/build-and-inspect-python-package@v1
#        id: build-package
      # packages are uploaded to Packages

  test:
    needs: check-package-build
    runs-on: ubuntu-latest
    strategy:
      matrix:
#         os: [ubuntu-latest]
#         python-version: [3.13]
#         clang-version: ['19']
         os: [ubuntu-latest, macos-latest, windows-latest]
         python-version: [ '3.10', '3.11', '3.12', '3.13' ]
         clang-version: ['17', '18', '19']

    steps:
    - uses: actions/checkout@v4
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        python-version: ${{ matrix.python-version }}
    - name: Install Clang
      uses: egor-tensin/setup-clang@v1
      with:
        version: ${{ matrix.clang-version }}
        platform: x64
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip 
        pip install setuptools setuptools_scm clang==${{ matrix.clang-version }}.* coveralls coverage[toml]
    - name: build test libs
      run: |
        CFLAGS="-Wall -Wextra -Werror -std=c99 -pedantic -fpic"
        LDFLAGS="-shared"
        clang $CFLAGS $LDFLAGS -o test/data/test-callbacks.so test/data/test-callbacks.c
    - name: Show  LD_LIBRARY_PATH
      run: |
        echo $LD_LIBRARY_PATH
        echo $PWD
        echo $(pwd)
        echo ${{runner.os == 'Linux' }}
    - name: Update Linux LD_LIBRARY_PATH
      if: ${{runner.os == 'Linux' }}
      run: |
        echo "LD_LIBRARY_PATH=$(pwd)/test/data/:$LD_LIBRARY_PATH" >> $GITHUB_ENV
    - name: Update Windows PATH
      if: ${{runner.os == 'Windows' }}
      run: |
        echo "PATH=$(pwd)/test/data/:$Env:PATH" >> $GITHUB_ENV
    - name: Update macOS PATH
      if: ${{runner.os == 'macOS' }}
      run: |
        echo "DYLD_LIBRARY_PATH=$(pwd)/test/data/:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
    - uses: actions/download-artifact@v4
      with:
        name: Packages
        path: ~/packages/
    - name: Install the package that was built
      run: |
        pip install ~/packages/ctypeslib2*.whl
    - name: Show the versions involved
      run: clang2py --version
    - name: Run tests with Unittest and coverage
      run: |
        coverage run --source=ctypeslib -m unittest test.alltests
    - name: Coveralls
      uses: coverallsapp/github-action@v2
      with:
        parallel: true
        flag-name: run-${{ join(matrix.*, ' - ') }}

  coveralls_finish:
    needs: test
    runs-on: ubuntu-latest
    steps:
    - name: Coveralls Finished
      uses: coverallsapp/github-action@v2
      with:
        parallel-finished: true

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.

 
# good example https://github.com/thenewguy/django-randomfields/blob/master/.github/workflows/sdist.yml
name: ctypeslib-linux
 
on: [push, pull_request]
 
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  check-package-build:
    timeout-minutes: 30
    name: Build & inspect our package.
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
        with:
          # get all history and tags for setuptools_scm to find the right version
          fetch-depth: 0
      - name: Install build dependencies
        run: |
          pip install setuptools setuptools_scm wheel build
      - name: Build package wheel
        run: python -m build -w
      - name: Upload built artifacts.
        uses: actions/upload-artifact@v4
        # By default, the artifacts and log files generated by workflows are retained for 90 days before they are automatically deleted.
        with:
          name: Packages
          path: ./dist/*
#      - uses: hynek/build-and-inspect-python-package@v1
#        id: build-package
      # packages are uploaded to Packages
 
  test:
    timeout-minutes: 30
    needs: check-package-build
    runs-on: latchkey-small
    strategy:
      matrix:
#         os: [ubuntu-latest]
#         python-version: [3.13]
#         clang-version: ['19']
         os: [ubuntu-latest, macos-latest, windows-latest]
         python-version: [ '3.10', '3.11', '3.12', '3.13' ]
         clang-version: ['17', '18', '19']
 
    steps:
    - uses: actions/checkout@v4
    - name: Set up Python
      uses: actions/setup-python@v5
      with:
        cache: 'pip'
        python-version: ${{ matrix.python-version }}
    - name: Install Clang
      uses: egor-tensin/setup-clang@v1
      with:
        version: ${{ matrix.clang-version }}
        platform: x64
    - name: Install dependencies
      run: |
        python -m pip install --upgrade pip 
        pip install setuptools setuptools_scm clang==${{ matrix.clang-version }}.* coveralls coverage[toml]
    - name: build test libs
      run: |
        CFLAGS="-Wall -Wextra -Werror -std=c99 -pedantic -fpic"
        LDFLAGS="-shared"
        clang $CFLAGS $LDFLAGS -o test/data/test-callbacks.so test/data/test-callbacks.c
    - name: Show  LD_LIBRARY_PATH
      run: |
        echo $LD_LIBRARY_PATH
        echo $PWD
        echo $(pwd)
        echo ${{runner.os == 'Linux' }}
    - name: Update Linux LD_LIBRARY_PATH
      if: ${{runner.os == 'Linux' }}
      run: |
        echo "LD_LIBRARY_PATH=$(pwd)/test/data/:$LD_LIBRARY_PATH" >> $GITHUB_ENV
    - name: Update Windows PATH
      if: ${{runner.os == 'Windows' }}
      run: |
        echo "PATH=$(pwd)/test/data/:$Env:PATH" >> $GITHUB_ENV
    - name: Update macOS PATH
      if: ${{runner.os == 'macOS' }}
      run: |
        echo "DYLD_LIBRARY_PATH=$(pwd)/test/data/:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
    - uses: actions/download-artifact@v4
      with:
        name: Packages
        path: ~/packages/
    - name: Install the package that was built
      run: |
        pip install ~/packages/ctypeslib2*.whl
    - name: Show the versions involved
      run: clang2py --version
    - name: Run tests with Unittest and coverage
      run: |
        coverage run --source=ctypeslib -m unittest test.alltests
    - name: Coveralls
      uses: coverallsapp/github-action@v2
      with:
        parallel: true
        flag-name: run-${{ join(matrix.*, ' - ') }}
 
  coveralls_finish:
    timeout-minutes: 30
    needs: test
    runs-on: latchkey-small
    steps:
    - name: Coveralls Finished
      uses: coverallsapp/github-action@v2
      with:
        parallel-finished: true
 
 

What changed

3 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 (38 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