Skip to content
Latchkey

Integration - ClickHouse workflow (MotleyAI/slayer)

The Integration - ClickHouse workflow from MotleyAI/slayer, explained and optimized by Latchkey.

D

CI health: D - needs work

Point runs-on at Latchkey and get caching, 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: MotleyAI/slayer.github/workflows/integration-clickhouse.ymlLicense MITView source

What it does

This is the Integration - ClickHouse workflow from the MotleyAI/slayer 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: Integration - ClickHouse

# DEV-1564: per-dialect CI for ClickHouse - pytest suite + verify.py
# end-to-end check. Path-gated to ClickHouse-specific files plus the
# shared SQL generator + dialect base.

on:
  pull_request:
    branches: [main]
    paths:
      - 'slayer/sql/dialects/clickhouse.py'
      - 'slayer/sql/dialects/base.py'
      - 'slayer/sql/generator.py'
      - 'examples/clickhouse/**'
      - 'tests/integration/test_integration_clickhouse.py'
      - '.github/workflows/integration-clickhouse.yml'
  push:
    branches: [main]
    paths:
      - 'slayer/sql/dialects/clickhouse.py'
      - 'slayer/sql/dialects/base.py'
      - 'slayer/sql/generator.py'
      - 'examples/clickhouse/**'
      - 'tests/integration/test_integration_clickhouse.py'
      - '.github/workflows/integration-clickhouse.yml'
  workflow_dispatch:

jobs:
  pytest:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python 3.11
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install Poetry
        run: pip install poetry

      - name: Install dependencies
        run: poetry install -E all --with dev

      - name: Verify testcontainers[clickhouse] extra is importable
        run: poetry run python -c "import testcontainers.clickhouse"

      - name: Run ClickHouse integration tests
        timeout-minutes: 20
        run: |
          poetry run pytest tests/integration/test_integration_clickhouse.py \
            -v -m integration --timeout=300

  verify-example:
    runs-on: ubuntu-latest
    steps:
      - uses: actions/checkout@v4

      - name: Set up Python 3.11
        uses: actions/setup-python@v5
        with:
          python-version: "3.11"

      - name: Install verify.py dependencies
        run: pip install sqlalchemy

      - name: Make slayer_data writable for container user
        working-directory: examples/clickhouse
        run: chmod -R 777 slayer_data

      - name: Build images
        working-directory: examples/clickhouse
        run: docker compose build

      - name: Start DB + seed
        working-directory: examples/clickhouse
        run: docker compose up -d --wait --wait-timeout 180 seed

      - name: Start slayer service
        working-directory: examples/clickhouse
        run: docker compose up -d slayer

      - name: Wait for SLayer API to accept connections
        working-directory: examples/clickhouse
        run: |
          for i in $(seq 1 120); do
            if curl -sf http://localhost:5143/datasources >/dev/null; then
              echo "SLayer API ready after ${i} attempts"
              exit 0
            fi
            if [ "$(docker compose ps -q slayer | xargs -r docker inspect -f '{{.State.Running}}')" = "false" ]; then
              echo "slayer container exited before becoming ready - logs:" >&2
              docker compose logs --no-color slayer
              exit 1
            fi
            sleep 2
          done
          echo "SLayer API never came up - logs:" >&2
          docker compose logs --no-color slayer
          exit 1

      - name: Run verify.py
        timeout-minutes: 5
        run: python examples/clickhouse/verify.py

      - name: Dump all container logs
        if: always()
        working-directory: examples/clickhouse
        run: docker compose logs --no-color

      - name: Tear down stack
        if: always()
        working-directory: examples/clickhouse
        run: docker compose down -v

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: Integration - ClickHouse
 
# DEV-1564: per-dialect CI for ClickHouse - pytest suite + verify.py
# end-to-end check. Path-gated to ClickHouse-specific files plus the
# shared SQL generator + dialect base.
 
on:
  pull_request:
    branches: [main]
    paths:
      - 'slayer/sql/dialects/clickhouse.py'
      - 'slayer/sql/dialects/base.py'
      - 'slayer/sql/generator.py'
      - 'examples/clickhouse/**'
      - 'tests/integration/test_integration_clickhouse.py'
      - '.github/workflows/integration-clickhouse.yml'
  push:
    branches: [main]
    paths:
      - 'slayer/sql/dialects/clickhouse.py'
      - 'slayer/sql/dialects/base.py'
      - 'slayer/sql/generator.py'
      - 'examples/clickhouse/**'
      - 'tests/integration/test_integration_clickhouse.py'
      - '.github/workflows/integration-clickhouse.yml'
  workflow_dispatch:
 
concurrency:
  group: ${{ github.workflow }}-${{ github.ref }}
  cancel-in-progress: true
 
jobs:
  pytest:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
 
      - name: Set up Python 3.11
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: "3.11"
 
      - name: Install Poetry
        run: pip install poetry
 
      - name: Install dependencies
        run: poetry install -E all --with dev
 
      - name: Verify testcontainers[clickhouse] extra is importable
        run: poetry run python -c "import testcontainers.clickhouse"
 
      - name: Run ClickHouse integration tests
        timeout-minutes: 20
        run: |
          poetry run pytest tests/integration/test_integration_clickhouse.py \
            -v -m integration --timeout=300
 
  verify-example:
    timeout-minutes: 30
    runs-on: latchkey-small
    steps:
      - uses: actions/checkout@v4
 
      - name: Set up Python 3.11
        uses: actions/setup-python@v5
        with:
          cache: 'pip'
          python-version: "3.11"
 
      - name: Install verify.py dependencies
        run: pip install sqlalchemy
 
      - name: Make slayer_data writable for container user
        working-directory: examples/clickhouse
        run: chmod -R 777 slayer_data
 
      - name: Build images
        working-directory: examples/clickhouse
        run: docker compose build
 
      - name: Start DB + seed
        working-directory: examples/clickhouse
        run: docker compose up -d --wait --wait-timeout 180 seed
 
      - name: Start slayer service
        working-directory: examples/clickhouse
        run: docker compose up -d slayer
 
      - name: Wait for SLayer API to accept connections
        working-directory: examples/clickhouse
        run: |
          for i in $(seq 1 120); do
            if curl -sf http://localhost:5143/datasources >/dev/null; then
              echo "SLayer API ready after ${i} attempts"
              exit 0
            fi
            if [ "$(docker compose ps -q slayer | xargs -r docker inspect -f '{{.State.Running}}')" = "false" ]; then
              echo "slayer container exited before becoming ready - logs:" >&2
              docker compose logs --no-color slayer
              exit 1
            fi
            sleep 2
          done
          echo "SLayer API never came up - logs:" >&2
          docker compose logs --no-color slayer
          exit 1
 
      - name: Run verify.py
        timeout-minutes: 5
        run: python examples/clickhouse/verify.py
 
      - name: Dump all container logs
        if: always()
        working-directory: examples/clickhouse
        run: docker compose logs --no-color
 
      - name: Tear down stack
        if: always()
        working-directory: examples/clickhouse
        run: docker compose down -v
 

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