How satorici/satori-cli works
Purpose and Runtime
Satori CLI is a Python command-line client for Satori CI, a remote testing platform. It submits playbooks plus relevant local files for execution, then exposes reports, repositories, schedules/monitors, teams, and account configuration. The remote platform executes tests in Docker instances hosted on AWS; the CLI communicates with Satori’s API.
Entry points are src/satoricli/__main__.py and package initialization in src/satoricli/__init__.py. Packaging/dependency definitions are in pyproject.toml.
CLI Dispatch Layer
The command hierarchy is rooted in src/satoricli/cli/commands/root.py, with argument parsing in src/satoricli/cli/arguments.py and shared command behavior in src/satoricli/cli/commands/base.py.
Command modules form the public control boundary. Important domains include:
• Run and local execution: src/satoricli/cli/commands/run.py, src/satoricli/cli/commands/local.py
• Remote resource management: src/satoricli/cli/commands/repo.py, src/satoricli/cli/commands/monitor.py, src/satoricli/cli/commands/playbook.py
• Result retrieval/presentation: src/satoricli/cli/commands/report.py, src/satoricli/cli/commands/reports.py
Authentication, Configuration, and API Boundary
src/satoricli/cli/commands/config.py and src/satoricli/cli/commands/settings.py manage user-facing configuration, notably the API token required to use Satori.
src/satoricli/api.py is the primary client-to-service boundary: command handlers should delegate remote operations through it rather than encode service interactions themselves. API failures and CLI-level error translation are represented by src/satoricli/exceptions.py.
External services include the Satori CI web/API platform, GitHub-connected repositories and GitHub App workflows, and optional notification destinations configured through playbooks (Slack, email, GitHub issues, Discord, Telegram).
Playbook Input Model
Playbooks are YAML-based test specifications that define commands, assertions on stdout/stderr/return codes, imports, and monitoring settings. Playbook-specific handling is centralized in src/satoricli/playbooks.py; validation boundaries are in src/satoricli/validations.py.
The CLI accepts files or directories, resolves playbook inputs and imports, and preserves a test payload for remote execution. Repository examples under .satori/ demonstrate supported input modes, imports, failures, file inclusion, and monitoring, including .satori/input.yml and .satori/import/pass.yml.
Bundling and Submission Flow
src/satoricli/bundler.py is the material packaging stage. It gathers the target project/playbook content into an uploadable bundle while separating local filesystem concerns from the remote execution API.
The main on-demand flow is:
1. run command accepts a path and execution flags.
2. Playbook parsing/validation resolves instructions and imports.
3. Bundler prepares files and playbook payload.
4. API client uploads/submits the run.
5. CLI prints the returned UUID/report URL and may poll for completion when synchronous execution is requested.
Relevant paths: src/satoricli/cli/commands/run.py, src/satoricli/bundler.py, src/satoricli/api.py.
Execution Modes and Result Lifecycle
Remote runs create reports containing overall status, individual test outcomes, assertions, and elapsed time. Report commands fetch and render this lifecycle, while scan commands apply it to repository history.
Key command surfaces are src/satoricli/cli/commands/scan.py, src/satoricli/cli/commands/report.py, and src/satoricli/cli/commands/repo.py. --sync-style behavior is a control-flow distinction: asynchronous submission returns a remote identifier; synchronous mode waits and displays finalized status.
Scheduled Monitoring and Managed Resources
A playbook with a cron-like schedule becomes a monitor managed by the platform. Monitor commands visualize and manage these scheduled executions, while related plural commands support resource listing.
Core paths: src/satoricli/cli/commands/monitor.py, src/satoricli/cli/commands/monitors.py, src/satoricli/cli/commands/playbooks.py.
Repository, team, template, shard, and AI commands are additional API-backed management domains under src/satoricli/cli/commands/; they share the same CLI dispatch, authentication, and service-client boundaries rather than defining separate runtimes.
Main entry points: api.py API client · base.py Command base · root.py Command root · run.py Run command
Components 17
CLI control plane
- CLI entry point
src/satoricli/__main__.py - Command root
src/satoricli/cli/commands/root.py - Argument parsing
src/satoricli/cli/arguments.py - Command base
src/satoricli/cli/commands/base.py - Run command · Submits playbooks and can wait for completion.
src/satoricli/cli/commands/run.py - Local command
src/satoricli/cli/commands/local.py - Resource commands · Repositories, monitors, playbooks, teams, templates, shards, and AI.
src/satoricli/cli/commands/repo.py - Report and scan commands
src/satoricli/cli/commands/report.py - Config and settings · Manages the API token and user configuration.
src/satoricli/cli/commands/config.py
Playbook packaging
- Playbook handling · Resolves specifications and imports.
src/satoricli/playbooks.py - Validation
src/satoricli/validations.py - Bundler · Collects project files and playbook payloads for upload.
src/satoricli/bundler.py
Satori CI platform
- API client · Single boundary for remote Satori operations.
src/satoricli/api.py - Error translation
src/satoricli/exceptions.py - Satori CI API · Executes Docker-hosted tests on AWS and stores resources and reports.
- Run reports · Status, test outcomes, assertions, and elapsed time.
- GitHub and notifications · GitHub App workflows plus optional Slack, email, issue, Discord, and Telegram delivery.
Connections 21
- CLI entry point → Command root: starts
- Command root → Argument parsing: parses
- Command root → Command base: dispatches through
- Command base → Run command: shared behavior
- Command base → Local command: shared behavior
- Command base → Resource commands: shared behavior
- Command base → Report and scan commands: shared behavior
- Command base → Config and settings: shared behavior
- Run command → Playbook handling: resolves input
- Playbook handling → Validation: validates
- Playbook handling → Bundler: provides payload
- Bundler → API client: upload bundle
- Run command → API client: submit and poll
- Resource commands → API client: manage remote resources
- Report and scan commands → API client: fetch reports and scans
- Config and settings → API client: configures token use
- API client → Error translation: translates failures
- API client → Satori CI API: HTTPS API
- Satori CI API → Run reports: creates and stores
- Run reports → API client: returned for rendering
- Satori CI API → GitHub and notifications: connects and notifies