Skip to content
Latchkey

Python Conformance CI (asgi) workflow (GoogleCloudPlatform/functions-framework-python)

The Python Conformance CI (asgi) workflow from GoogleCloudPlatform/functions-framework-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 →
Source: GoogleCloudPlatform/functions-framework-python.github/workflows/conformance-asgi.ymlLicense Apache-2.0View source

What it does

This is the Python Conformance CI (asgi) workflow from the GoogleCloudPlatform/functions-framework-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: Python Conformance CI (asgi)
on:
  push:
    branches:
      - 'main'
  pull_request:

# Declare default permissions as read only.
permissions: read-all

jobs:
  build:
    strategy:
      matrix:
        python: ['3.8', '3.9', '3.10', '3.11', '3.12']
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Harden Runner
      uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
      with:
        disable-sudo: true
        egress-policy: block
        allowed-endpoints: >
          api.github.com:443
          files.pythonhosted.org:443
          github.com:443
          objects.githubusercontent.com:443
          proxy.golang.org:443
          pypi.org:443
          storage.googleapis.com:443
          release-assets.githubusercontent.com:443

    - name: Checkout code
      uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2

    - name: Setup Python
      uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
      with:
        python-version: ${{ matrix.python }}

    - name: Install the framework
      run: python -m pip install -e .

    - name: Setup Go
      uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
      with:
        go-version: '1.26'

    - name: Run HTTP conformance tests
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'http'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http --signature-type http --asgi'"
        startDelay: 5

    - name: Run CloudEvents conformance tests
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'cloudevent'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event --signature-type cloudevent --asgi'"
        startDelay: 5

    - name: Run HTTP conformance tests declarative
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'http'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative --asgi'"
        startDelay: 5

    - name: Run CloudEvents conformance tests declarative
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'cloudevent'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event_declarative --asgi'"
        startDelay: 5

    - name: Run HTTP concurrency tests declarative
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'http'
        useBuildpacks: false
        validateConcurrency: true
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative_concurrent --asgi'"
        startDelay: 5

    # Note: Event (legacy) and Typed tests are not supported in ASGI mode
    # Note: validateMapping is set to false for CloudEvent tests because ASGI mode
    # does not support automatic conversion from legacy events to CloudEvents

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: Python Conformance CI (asgi)
on:
  push:
    branches:
      - 'main'
  pull_request:
 
# Declare default permissions as read only.
permissions: read-all
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    strategy:
      matrix:
        python: ['3.8', '3.9', '3.10', '3.11', '3.12']
        platform: [ubuntu-latest]
    runs-on: ${{ matrix.platform }}
    steps:
    - name: Harden Runner
      uses: step-security/harden-runner@5ef0c079ce82195b2a36a210272d6b661572d83e # v2.14.2
      with:
        disable-sudo: true
        egress-policy: block
        allowed-endpoints: >
          api.github.com:443
          files.pythonhosted.org:443
          github.com:443
          objects.githubusercontent.com:443
          proxy.golang.org:443
          pypi.org:443
          storage.googleapis.com:443
          release-assets.githubusercontent.com:443
 
    - name: Checkout code
      uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
 
    - name: Setup Python
      uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065 # v5.6.0
      with:
        cache: 'pip'
        python-version: ${{ matrix.python }}
 
    - name: Install the framework
      run: python -m pip install -e .
 
    - name: Setup Go
      uses: actions/setup-go@7a3fe6cf4cb3a834922a1244abfce67bcef6a0c5 # v6.2.0
      with:
        go-version: '1.26'
 
    - name: Run HTTP conformance tests
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'http'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http --signature-type http --asgi'"
        startDelay: 5
 
    - name: Run CloudEvents conformance tests
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'cloudevent'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event --signature-type cloudevent --asgi'"
        startDelay: 5
 
    - name: Run HTTP conformance tests declarative
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'http'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative --asgi'"
        startDelay: 5
 
    - name: Run CloudEvents conformance tests declarative
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'cloudevent'
        useBuildpacks: false
        validateMapping: false
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_cloud_event_declarative --asgi'"
        startDelay: 5
 
    - name: Run HTTP concurrency tests declarative
      uses: GoogleCloudPlatform/functions-framework-conformance/action@403fda9e6e176aae87646aace9bed075cee8e7fd # v1.8.8
      with:
        functionType: 'http'
        useBuildpacks: false
        validateConcurrency: true
        cmd: "'functions-framework --source tests/conformance/async_main.py --target write_http_declarative_concurrent --asgi'"
        startDelay: 5
 
    # Note: Event (legacy) and Typed tests are not supported in ASGI mode
    # Note: validateMapping is set to false for CloudEvent tests because ASGI mode
    # does not support automatic conversion from legacy events to CloudEvents

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 1 job (5 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