Skip to content

preset-io/superset-showtime

Repository files navigation

πŸŽͺ Superset Showtime

Modern ephemeral environment management for Apache Superset using circus tent emoji labels

PyPI version Python 3.8+

🎯 What is Showtime?

Superset Showtime is a CLI tool designed primarily for GitHub Actions to manage Apache Superset ephemeral environments. It uses circus tent emoji labels as a visual state management system and depends on Superset's existing build infrastructure.

πŸš€ Quick Start for Superset Contributors

Create an ephemeral environment:

  1. Go to your PR in GitHub
  2. Add label: πŸŽͺ ⚑ showtime-trigger-start
  3. Watch the magic happen - labels will update automatically
  4. When you see πŸŽͺ 🚦 {sha} running, your environment is ready!
  5. Get URL from πŸŽͺ 🌐 {sha} {ip} β†’ http://{ip}:8080
  6. Every new commit automatically deploys a fresh environment (zero-downtime)

To test a specific commit without auto-updates:

  • Add label: πŸŽͺ 🧊 showtime-freeze (prevents auto-sync on new commits)

Clean up when done:

# Add this label:
πŸŽͺ πŸ›‘ showtime-trigger-stop
# All circus labels disappear, AWS resources cleaned up

πŸŽͺ How It Works

πŸŽͺ GitHub labels become a visual state machine:

# User adds trigger label in GitHub UI:
πŸŽͺ ⚑ showtime-trigger-start

# System responds with state labels:
πŸŽͺ abc123f 🚦 building      # Environment abc123f is building
πŸŽͺ 🎯 abc123f               # abc123f is the active environment
πŸŽͺ abc123f πŸ“… 2024-01-15T14-30  # Created timestamp
πŸŽͺ abc123f βŒ› 24h           # Time-to-live policy
πŸŽͺ abc123f 🀑 maxime        # Requested by maxime (clown emoji!)

# When ready:
πŸŽͺ abc123f 🚦 running       # Environment is now running
πŸŽͺ abc123f 🌐 52-1-2-3      # Available at http://52.1.2.3:8080

πŸ”„ Showtime Workflow

flowchart TD
    A[User adds πŸŽͺ ⚑ trigger-start] --> B[GitHub Actions: sync]
    B --> C{Current state?}

    C -->|No environment| D[πŸ”’ Claim: Remove trigger + Set building]
    C -->|Running + new SHA| E[πŸ”’ Claim: Remove trigger + Set building]
    C -->|Already building| F[❌ Exit: Another job active]
    C -->|No triggers| G[❌ Exit: Nothing to do]

    D --> H[πŸ“‹ State: building]
    E --> H
    H --> I[🐳 Docker build]
    I -->|Success| J[πŸ“‹ State: built]
    I -->|Fail| K[πŸ“‹ State: failed]

    J --> L[πŸ“‹ State: deploying]
    L --> M[☁️ AWS Deploy]
    M -->|Success| N[πŸ“‹ State: running]
    M -->|Fail| O[πŸ“‹ State: failed]

    N --> P[πŸŽͺ Environment ready!]

    Q[User adds πŸŽͺ πŸ›‘ trigger-stop] --> R[🧹 Cleanup AWS + Remove labels]
Loading

Install CLI for debugging:

pip install superset-showtime
export GITHUB_TOKEN=your_token

Monitor and debug:

showtime list                    # See all active environments
showtime status 1234            # Debug specific environment
showtime labels                 # Complete label reference

Testing/development:

showtime sync 1234 --dry-run-aws --dry-run-docker  # Test without costs
showtime cleanup --dry-run --older-than 1h         # Test cleanup logic

Architecture: This CLI implements ACID-style atomic transactions with direct Docker integration. It handles complete environment lifecycle from Docker build to AWS deployment with race condition prevention.

πŸŽͺ Complete Label Reference

🎯 Trigger Labels (Add These to Your PR)

Label Action Result
πŸŽͺ ⚑ showtime-trigger-start Create environment Builds and deploys ephemeral environment with blue-green deployment
πŸŽͺ πŸ›‘ showtime-trigger-stop Destroy environment Cleans up AWS resources and removes all labels
πŸŽͺ 🧊 showtime-freeze Freeze environment Prevents auto-sync on new commits (for testing specific SHAs)

πŸ“Š State Labels (Automatically Managed)

Label Pattern Meaning Example
πŸŽͺ {sha} 🚦 {status} Environment status πŸŽͺ abc123f 🚦 running
πŸŽͺ 🎯 {sha} Active environment pointer πŸŽͺ 🎯 abc123f
πŸŽͺ πŸ—οΈ {sha} Building environment pointer πŸŽͺ πŸ—οΈ def456a
πŸŽͺ {sha} πŸ“… {timestamp} Creation time πŸŽͺ abc123f πŸ“… 2024-01-15T14-30
πŸŽͺ {sha} 🌐 {ip:port} Environment URL πŸŽͺ abc123f 🌐 52.1.2.3:8080
πŸŽͺ {sha} βŒ› {ttl} Time-to-live policy πŸŽͺ abc123f βŒ› 24h
πŸŽͺ {sha} 🀑 {username} Who requested πŸŽͺ abc123f 🀑 maxime

πŸ”§ Testing Configuration Changes

Approach: Modify configuration directly in your PR code, then trigger environment.

Workflow:

  1. Modify superset_config.py with your changes
  2. Push commit β†’ Creates new SHA (e.g., def456a)
  3. Add πŸŽͺ ⚑ showtime-trigger-start β†’ Deploys with your config
  4. Test environment reflects your exact code changes

This approach creates traceable, reviewable changes that are part of your git history.

πŸ”„ Complete Workflows

Creating Your First Environment

  1. Add trigger label in GitHub UI: πŸŽͺ ⚑ showtime-trigger-start
  2. Watch state labels appear:
    πŸŽͺ abc123f 🚦 building      ← Environment is building
    πŸŽͺ 🎯 abc123f               ← This is the active environment
    πŸŽͺ abc123f πŸ“… 2024-01-15T14-30  ← Started building at this time
    
  3. Wait for completion:
    πŸŽͺ abc123f 🚦 running       ← Now ready!
    πŸŽͺ abc123f 🌐 52.1.2.3:8080  ← Visit http://52.1.2.3:8080
    

Testing Specific Commits

  1. Add freeze label: πŸŽͺ 🧊 showtime-freeze
  2. Result: Environment won't auto-update on new commits
  3. Use case: Test specific SHA while continuing development
  4. Override: Add πŸŽͺ ⚑ showtime-trigger-start to force update despite freeze

Rolling Updates (Automatic!)

When you push new commits, Showtime automatically:

  1. Detects new commit via GitHub webhook
  2. Builds new environment alongside old one
  3. Switches traffic when new environment is ready
  4. Cleans up old environment

You'll see:

# During update:
πŸŽͺ abc123f 🚦 running       # Old environment still serving
πŸŽͺ def456a 🚦 building      # New environment building
πŸŽͺ 🎯 abc123f               # Traffic still on old
πŸŽͺ πŸ—οΈ def456a               # New one being prepared

# After update:
πŸŽͺ def456a 🚦 running       # New environment live
πŸŽͺ 🎯 def456a               # Traffic switched
πŸŽͺ def456a 🌐 52-4-5-6      # New IP address
# All abc123f labels removed automatically

πŸ”’ Security & Permissions

Who Can Use This?

  • βœ… Superset maintainers (with write access) can add trigger labels
  • ❌ External contributors cannot trigger environments (no write access to add labels)
  • πŸ”’ Secure by design - only trusted users can create expensive AWS resources

GitHub Actions Integration

🎯 Live Workflow: showtime-trigger.yml

How it works:

  • Triggers on PR label changes, commits, and closures
  • Installs superset-showtime from PyPI (trusted code, not PR code)
  • Runs showtime sync to handle trigger processing and deployments
  • Supports manual testing via workflow_dispatch with specific SHA override

Commands used:

showtime sync PR_NUMBER --check-only    # Determine build_needed + target_sha
showtime sync PR_NUMBER --sha SHA       # Execute atomic claim + build + deploy

πŸ› οΈ CLI Usage

The CLI is primarily used by GitHub Actions, but available for debugging and advanced users:

pip install superset-showtime
export GITHUB_TOKEN=your_token

# Core commands:
showtime sync PR_NUMBER              # Sync to desired state (main command)
showtime start PR_NUMBER             # Create new environment
showtime stop PR_NUMBER              # Delete environment
showtime status PR_NUMBER            # Show current state
showtime list                        # List all environments
showtime cleanup --older-than 48h    # Clean up expired environments

🀝 Contributing

Testing Your Changes

Test with real PRs safely:

# Test full workflow without costs:
showtime sync YOUR_PR_NUMBER --dry-run-aws --dry-run-docker

# Test cleanup logic:
showtime cleanup --dry-run --older-than 24h

Development Setup

git clone https://github.com/mistercrunch/superset-showtime
cd superset-showtime

# Using uv (recommended):
uv pip install -e ".[dev]"
make pre-commit
make test

# Traditional pip:
pip install -e ".[dev]"
pre-commit install
pytest

πŸ“„ License

Apache License 2.0 - same as Apache Superset.


πŸŽͺ "Ladies and gentlemen, welcome to Superset Showtime - where ephemeral environments are always under the big top!" πŸŽͺ🀑✨

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors 5

Languages