Skip to content
Latchkey

Run tests workflow (graphite-project/graphite-web)

The Run tests workflow from graphite-project/graphite-web, 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: graphite-project/graphite-web.github/workflows/tests.ymlLicense Apache-2.0View source

What it does

This is the Run tests workflow from the graphite-project/graphite-web 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: Run tests

on:
  push:
    branches: [master, 1.0.x, 1.1.x]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [master, 1.0.x, 1.1.x]
  workflow_dispatch:

jobs:
  build:
    runs-on: ubuntu-22.04

    services:
      redis:
        image: redis
        ports:
          - 6379/tcp
        options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5
      mariadb:
        image: mariadb:latest
        ports:
          - 3306/tcp
        env:
          MARIADB_USER: graphite
          MARIADB_PASSWORD: graphite
          MARIADB_DATABASE: test_graphite
          MARIADB_ROOT_PASSWORD: root
        options: --health-cmd="/usr/local/bin/healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
      postgres:
        image: postgres
        ports:
          - 5432/tcp
        env:
          POSTGRES_PASSWORD: postgres
        options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=5

    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13"]

    steps:
      - uses: actions/checkout@v4
      - name: Install global dependencies
        run: |
          sudo apt-get -y install libcairo2-dev librrd-dev libboost-python-dev redis-tools python3-distutils-extra
      - name: Verify Redis connection
        env:
          REDIS_PORT: ${{ job.services.redis.ports[6379] }}
        run: |
          redis-cli -h "127.0.0.1" -p "${REDIS_PORT}" ping
      - name: Verify MariaDB connection
        env:
          MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
        run: |
          mysql -h"127.0.0.1" -P"${MYSQL_PORT}" -uroot -proot -e "GRANT ALL ON test_graphite.* TO 'graphite'@'localhost' IDENTIFIED BY 'graphite';"
      - name: Verify PostgreSQL connection
        env:
          POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
        run: |
          PGPASSWORD=postgres psql -h"127.0.0.1" -p"${POSTGRES_PORT}" -U postgres -c "CREATE USER graphite WITH CREATEDB PASSWORD 'graphite';"
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip 'setuptools>=67.0.0' wheel --force-reinstall
          pip install 'tox<4' tox-gh-actions flake8 pytest pytz
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
      - name: Test with tox
        env:
          TEST_REDIS_HOST: localhost
          TEST_REDIS_PORT: ${{ job.services.redis.ports[6379] }}
          TEST_MYSQL_HOST: localhost
          TEST_MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
          TEST_MYSQL_PASSWORD: graphite
          TEST_POSTGRES_HOST: localhost
          TEST_POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
          TEST_POSTGRESQL_PASSWORD: graphite
        run: |
          tox
      - name: Linting
        if: ${{ matrix.python-version==3.13 }}
        env:
          TOXENV: lint
        run: |
          tox
      - name: Testing documentation
        if: ${{ matrix.python-version==3.13 }}
        env:
          TOXENV: docs
        run: |
          tox
      - name: Run Codecov
        if: ${{ matrix.python-version==3.13 }}
        env:
          TOXENV: lint
        run: |
          pip install codecov
          codecov
      - name: Upload coverage to Codecov
        if: ${{ matrix.python-version==3.13 }}
        uses: codecov/codecov-action@v5

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: Run tests
 
on:
  push:
    branches: [master, 1.0.x, 1.1.x]
  pull_request:
    # The branches below must be a subset of the branches above
    branches: [master, 1.0.x, 1.1.x]
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  build:
    timeout-minutes: 30
    runs-on: latchkey-small
 
    services:
      redis:
        image: redis
        ports:
          - 6379/tcp
        options: --health-cmd="redis-cli ping" --health-interval=10s --health-timeout=5s --health-retries=5
      mariadb:
        image: mariadb:latest
        ports:
          - 3306/tcp
        env:
          MARIADB_USER: graphite
          MARIADB_PASSWORD: graphite
          MARIADB_DATABASE: test_graphite
          MARIADB_ROOT_PASSWORD: root
        options: --health-cmd="/usr/local/bin/healthcheck.sh --su-mysql --connect --innodb_initialized" --health-interval=5s --health-timeout=2s --health-retries=3
      postgres:
        image: postgres
        ports:
          - 5432/tcp
        env:
          POSTGRES_PASSWORD: postgres
        options: --health-cmd="pg_isready" --health-interval=10s --health-timeout=5s --health-retries=5
 
    strategy:
      matrix:
        python-version: ["3.10", "3.11", "3.12", "3.13"]
 
    steps:
      - uses: actions/checkout@v4
      - name: Install global dependencies
        run: |
          sudo apt-get -y install libcairo2-dev librrd-dev libboost-python-dev redis-tools python3-distutils-extra
      - name: Verify Redis connection
        env:
          REDIS_PORT: ${{ job.services.redis.ports[6379] }}
        run: |
          redis-cli -h "127.0.0.1" -p "${REDIS_PORT}" ping
      - name: Verify MariaDB connection
        env:
          MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
        run: |
          mysql -h"127.0.0.1" -P"${MYSQL_PORT}" -uroot -proot -e "GRANT ALL ON test_graphite.* TO 'graphite'@'localhost' IDENTIFIED BY 'graphite';"
      - name: Verify PostgreSQL connection
        env:
          POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
        run: |
          PGPASSWORD=postgres psql -h"127.0.0.1" -p"${POSTGRES_PORT}" -U postgres -c "CREATE USER graphite WITH CREATEDB PASSWORD 'graphite';"
      - name: Set up Python ${{ matrix.python-version }}
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: ${{ matrix.python-version }}
      - name: Install dependencies
        run: |
          python -m pip install --upgrade pip 'setuptools>=67.0.0' wheel --force-reinstall
          pip install 'tox<4' tox-gh-actions flake8 pytest pytz
          if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
      - name: Test with tox
        env:
          TEST_REDIS_HOST: localhost
          TEST_REDIS_PORT: ${{ job.services.redis.ports[6379] }}
          TEST_MYSQL_HOST: localhost
          TEST_MYSQL_PORT: ${{ job.services.mariadb.ports[3306] }}
          TEST_MYSQL_PASSWORD: graphite
          TEST_POSTGRES_HOST: localhost
          TEST_POSTGRES_PORT: ${{ job.services.postgres.ports[5432] }}
          TEST_POSTGRESQL_PASSWORD: graphite
        run: |
          tox
      - name: Linting
        if: ${{ matrix.python-version==3.13 }}
        env:
          TOXENV: lint
        run: |
          tox
      - name: Testing documentation
        if: ${{ matrix.python-version==3.13 }}
        env:
          TOXENV: docs
        run: |
          tox
      - name: Run Codecov
        if: ${{ matrix.python-version==3.13 }}
        env:
          TOXENV: lint
        run: |
          pip install codecov
          codecov
      - name: Upload coverage to Codecov
        if: ${{ matrix.python-version==3.13 }}
        uses: codecov/codecov-action@v5
 

What changed

1 third-party action is referenced by a movable tag. Pin it 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 1 job (4 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