Jump to content

Connect SuperML | Leeroopedia MCP: Equip your AI agents with best practices, code verification, and debugging knowledge. Powered by Leeroo — building Organizational Superintelligence. Contact us at founders@leeroo.com.

Implementation:TobikoData Sqlmesh Bot CLI Entry

From Leeroopedia


Knowledge Sources
Domains Data_Engineering, CICD
Last Updated 2026-02-07 00:00 GMT

Overview

Concrete CLI entry point for integrating SQLMesh CI/CD workflows with GitHub Actions provided by SQLMesh.

Description

The bot CLI command serves as the primary entry point for executing SQLMesh CI/CD operations within GitHub Actions workflows. It initializes logging configuration for CI environments, accepts project paths and configuration files, creates a Click context for passing parameters to subcommands, and delegates to the platform-specific github command group. This command provides the bridge between GitHub Actions runners and SQLMesh deployment automation.

Usage

Use the bot CLI entry when setting up GitHub Actions workflows for automated data transformation deployments. This command is invoked from workflow YAML files and requires GitHub Actions environment variables to be present for proper operation.

Code Reference

Source Location

  • Repository: sqlmesh
  • File: sqlmesh/cicd/bot.py:L13-32

Signature

@click.group(no_args_is_help=True)
@opt.paths
@opt.config
@click.pass_context
@error_handler
def bot(
    ctx: click.Context,
    paths: t.List[str],
    config: t.Optional[str] = None,
) -> None:
    """SQLMesh CI/CD Bot. Currently only Github Actions is supported.
    See https://sqlmesh.readthedocs.io/en/stable/integrations/github/ for details"""
    configure_logging(write_to_stdout=True, write_to_file=False)

    ctx.obj = {
        "paths": paths,
        "config": config,
    }

Import

from sqlmesh.cicd.bot import bot

I/O Contract

Inputs

Name Type Required Description
ctx click.Context Yes Click context object for passing data to subcommands
paths List[str] Yes List of paths to SQLMesh project directories containing models and configurations
config str No Optional path to SQLMesh configuration file (defaults to searching in project paths)

Outputs

Name Type Description
None None Command sets up context and delegates to subcommands; no direct return value

Usage Examples

Basic Usage

# In GitHub Actions workflow (.github/workflows/sqlmesh_cicd.yml):
# name: SQLMesh CI/CD
# on: [pull_request, issue_comment]
# jobs:
#   sqlmesh:
#     runs-on: ubuntu-latest
#     steps:
#       - uses: actions/checkout@v3
#       - uses: actions/setup-python@v4
#         with:
#           python-version: '3.9'
#       - name: Install SQLMesh
#         run: pip install sqlmesh
#       - name: Run SQLMesh Bot
#         env:
#           GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
#         run: sqlmesh_cicd bot github run-all

# Command-line invocation with default paths
# sqlmesh_cicd bot github run-all

# Command-line invocation with custom paths
# sqlmesh_cicd bot --paths /path/to/project github run-all

# Command-line invocation with custom config
# sqlmesh_cicd bot --config config/prod.yaml github run-all

# Programmatic usage:
from click.testing import CliRunner
from sqlmesh.cicd.bot import bot

runner = CliRunner()
result = runner.invoke(bot, ['github', 'run-all'],
                      env={'GITHUB_TOKEN': 'token',
                           'GITHUB_EVENT_PATH': '/path/to/event.json'})

Related Pages

Implements Principle

Page Connections

Double-click a node to navigate. Hold to expand connections.
Principle
Implementation
Heuristic
Environment