Skip to content
Latchkey

Build Burr workflow (apache/burr)

The Build Burr workflow from apache/burr, explained and optimized by Latchkey.

D

CI health: D - needs work

The optimized version below adds caching, run de-duplication, job timeouts.

Source: apache/burr.github/workflows/python-package.ymlLicense Apache-2.0View source

What it does

This is the Build Burr workflow from the apache/burr 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)
#<!--
#     Licensed to the Apache Software Foundation (ASF) under one
#     or more contributor license agreements.  See the NOTICE file
#     distributed with this work for additional information
#     regarding copyright ownership.  The ASF licenses this file
#     to you under the Apache License, Version 2.0 (the
#     "License"); you may not use this file except in compliance
#     with the License.  You may obtain a copy of the License at
#
#       http://www.apache.org/licenses/LICENSE-2.0
#
#     Unless required by applicable law or agreed to in writing,
#     software distributed under the License is distributed on an
#     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
#     KIND, either express or implied.  See the License for the
#     specific language governing permissions and limitations
#     under the License.
#-->
# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python

name: Build Burr

on:
  push:
    branches:
      - main # Triggers the workflow on push events to the main branch
  pull_request:
    # Triggers the workflow on pull request events for any branch
    types: [opened, synchronize, reopened]

jobs:
  pre-commit:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with:
          python-version: '3.12'
      - name: Cache pre-commit environments
        uses: actions/cache@v3
        with:
          path: ~/.cache/pre-commit
          key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
      - name: Install pre-commit
        run: pip install pre-commit
      - name: Run pre-commit hooks
        run: pre-commit run --all-files

  test:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.9', '3.10', '3.11', '3.12']

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install Graphviz system dependency
        run: |
          sudo apt-get install -y --no-install-recommends graphviz
          sudo apt-get clean

      - name: Install dependencies
        run: |
          python -m pip install -e ".[tests,tracking-client,tracking-server,graphviz]"

      - name: Run tests
        run: |
          python -m pytest tests --ignore=tests/integrations/persisters --ignore=tests/integrations/test_bip0042_bedrock.py

  test-tracking-server-s3:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.9', '3.10', '3.11', '3.12']

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install -e ".[tests,tracking-client,tracking-server-s3]"

      - name: Run S3 tracking server tests
        run: |
          python -m pytest tests/tracking/test_bip0042_s3_buffering.py -v

  test-bedrock:
    runs-on: ubuntu-latest
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.9', '3.10', '3.11', '3.12']

    steps:
      - uses: actions/checkout@v4

      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}

      - name: Install dependencies
        run: |
          python -m pip install -e ".[tests,bedrock]"

      - name: Run Bedrock integration tests
        run: |
          python -m pytest tests/integrations/test_bip0042_bedrock.py -v

  validate-examples:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4
      - uses: actions/setup-python@v4
        with:
          python-version: '3.12'
      - name: Install dependencies
        run: |
          python -m pip install -e ".[tests]"
      - name: Validate examples
        working-directory: ./examples
        run: |
          python -m pytest validate_examples.py

  test-persister-dbs:
    runs-on: ubuntu-latest
    services:
      mongodb:
        image: mongo:7.0
        ports:
          - 27017:27017
      postgres:
        image: postgres:15
        env:
          POSTGRES_PASSWORD: postgres
        ports:
          - 5432:5432
      redis:
        image: redis:7
        ports:
          - 6379:6379
    strategy:
      fail-fast: false
      matrix:
        python-version: ['3.9', '3.10', '3.11', '3.12']

    steps:
      - uses: actions/checkout@v4
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v4
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install -e ".[tests,tracking-client]"
      - name: Run tests
        run: |
          BURR_CI_INTEGRATION_TESTS=true python -m pytest tests/integrations/persisters/

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.

#<!--#     Licensed to the Apache Software Foundation (ASF) under one#     or more contributor license agreements.  See the NOTICE file#     distributed with this work for additional information#     regarding copyright ownership.  The ASF licenses this file#     to you under the Apache License, Version 2.0 (the#     "License"); you may not use this file except in compliance#     with the License.  You may obtain a copy of the License at##       http://www.apache.org/licenses/LICENSE-2.0##     Unless required by applicable law or agreed to in writing,#     software distributed under the License is distributed on an#     "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY#     KIND, either express or implied.  See the License for the#     specific language governing permissions and limitations#     under the License.#--># This workflow will install Python dependencies, run tests and lint with a variety of Python versions# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-python name: Build Burr on:  push:    branches:      - main # Triggers the workflow on push events to the main branch  pull_request:    # Triggers the workflow on pull request events for any branch    types: [opened, synchronize, reopened] concurrency:  group: ${{ github.workflow }}-${{ github.ref }}  cancel-in-progress: true jobs:  pre-commit:    timeout-minutes: 30    runs-on: latchkey-small    steps:      - uses: actions/checkout@v4      - uses: actions/setup-python@v4        with:          cache: 'pip'          python-version: '3.12'      - name: Cache pre-commit environments        uses: actions/cache@v3        with:          path: ~/.cache/pre-commit          key: pre-commit-${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}      - name: Install pre-commit        run: pip install pre-commit      - name: Run pre-commit hooks        run: pre-commit run --all-files   test:    timeout-minutes: 30    runs-on: latchkey-small    strategy:      fail-fast: false      matrix:        python-version: ['3.9', '3.10', '3.11', '3.12']     steps:      - uses: actions/checkout@v4       - name: Set up Python ${{ matrix.python-version }}        uses: actions/setup-python@v4        with:          cache: 'pip'          python-version: ${{ matrix.python-version }}       - name: Install Graphviz system dependency        run: |          sudo apt-get install -y --no-install-recommends graphviz          sudo apt-get clean       - name: Install dependencies        run: |          python -m pip install -e ".[tests,tracking-client,tracking-server,graphviz]"       - name: Run tests        run: |          python -m pytest tests --ignore=tests/integrations/persisters --ignore=tests/integrations/test_bip0042_bedrock.py   test-tracking-server-s3:    timeout-minutes: 30    runs-on: latchkey-small    strategy:      fail-fast: false      matrix:        python-version: ['3.9', '3.10', '3.11', '3.12']     steps:      - uses: actions/checkout@v4       - name: Set up Python ${{ matrix.python-version }}        uses: actions/setup-python@v4        with:          cache: 'pip'          python-version: ${{ matrix.python-version }}       - name: Install dependencies        run: |          python -m pip install -e ".[tests,tracking-client,tracking-server-s3]"       - name: Run S3 tracking server tests        run: |          python -m pytest tests/tracking/test_bip0042_s3_buffering.py -v   test-bedrock:    timeout-minutes: 30    runs-on: latchkey-small    strategy:      fail-fast: false      matrix:        python-version: ['3.9', '3.10', '3.11', '3.12']     steps:      - uses: actions/checkout@v4       - name: Set up Python ${{ matrix.python-version }}        uses: actions/setup-python@v4        with:          cache: 'pip'          python-version: ${{ matrix.python-version }}       - name: Install dependencies        run: |          python -m pip install -e ".[tests,bedrock]"       - name: Run Bedrock integration tests        run: |          python -m pytest tests/integrations/test_bip0042_bedrock.py -v   validate-examples:    timeout-minutes: 30    runs-on: latchkey-small    steps:      - uses: actions/checkout@v4      - uses: actions/setup-python@v4        with:          cache: 'pip'          python-version: '3.12'      - name: Install dependencies        run: |          python -m pip install -e ".[tests]"      - name: Validate examples        working-directory: ./examples        run: |          python -m pytest validate_examples.py   test-persister-dbs:    timeout-minutes: 30    runs-on: latchkey-small    services:      mongodb:        image: mongo:7.0        ports:          - 27017:27017      postgres:        image: postgres:15        env:          POSTGRES_PASSWORD: postgres        ports:          - 5432:5432      redis:        image: redis:7        ports:          - 6379:6379    strategy:      fail-fast: false      matrix:        python-version: ['3.9', '3.10', '3.11', '3.12']     steps:      - uses: actions/checkout@v4      - name: Set up Python ${{ matrix.python-version }}        uses: actions/setup-python@v4        with:          cache: 'pip'          python-version: ${{ matrix.python-version }}      - name: Install dependencies        run: |          python -m pip install -e ".[tests,tracking-client]"      - name: Run tests        run: |          BURR_CI_INTEGRATION_TESTS=true python -m pytest tests/integrations/persisters/ 

What changed

  • Run on Latchkey managed runners with one line (runs-on), which apply the fixes below automatically and self-heal transient failures. This example uses latchkey-small; pick the runner size that fits the job.
  • 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.

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:

  • Dependency installs

This workflow runs 6 jobs (18 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

Frequently asked questions

What does the Build Burr workflow (apache/burr) workflow do?
This is the Build Burr workflow from the apache/burr repository, a real project running GitHub Actions. It is shown here with attribution under its Apache-2.0 license.
What CI health grade does this workflow get?
This Python workflow grades D. Paste your own workflow into the Latchkey grader to see its grade and the exact fixes.
How can I improve this Python workflow?
Apply caching, run de-duplication, job timeouts. Latchkey applies these automatically on managed runners when you point runs-on at Latchkey.

References