Files
superset2/.github/workflows/showtime-trigger.yml
Maxime Beauchemin e394f98687 perf: Skip Docker Compose installation in showtime workflow
Add install-docker-compose: false to setup-docker action since showtime workflows don't need Docker Compose. This saves 1-2 minutes by skipping unnecessary apt operations.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-08-25 13:23:22 -07:00

188 lines
6.8 KiB
YAML

name: 🎪 Superset Showtime
# Ultra-simple: just sync on any PR state change
on:
push:
branches: [showtime_gha] # Temporary trigger to register workflow
pull_request_target:
types: [labeled, unlabeled, synchronize, closed]
# Manual testing
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to sync'
required: true
type: number
sha:
description: 'Specific SHA to deploy (optional, defaults to latest)'
required: false
type: string
# Common environment variables for all jobs
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_REGION: us-west-2
GITHUB_ORG: ${{ github.repository_owner }}
GITHUB_REPO: ${{ github.event.repository.name }}
GITHUB_ACTOR: ${{ github.actor }}
DOCKERHUB_USER: ${{ secrets.DOCKERHUB_USER }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
jobs:
sync:
name: 🎪 Sync PR to desired state
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- name: Install Superset Showtime
run: |
pip install superset-showtime
showtime version
- name: Check what actions are needed
id: check
run: |
# Handle push events - sync environments for this branch's PRs
if [[ "${{ github.event_name }}" == "push" ]]; then
BRANCH_NAME="${{ github.ref_name }}"
echo "🎪 Push event on branch: $BRANCH_NAME"
# Use showtime CLI to handle branch-based sync (it can find related PRs)
python -m showtime sync-branch "$BRANCH_NAME"
# Set outputs to skip the rest of the workflow
echo "action_needed=branch_sync_complete" >> $GITHUB_OUTPUT
echo "build_needed=false" >> $GITHUB_OUTPUT
echo "deploy_needed=false" >> $GITHUB_OUTPUT
echo "pr_number=0" >> $GITHUB_OUTPUT
exit 0
fi
# Bulletproof PR number extraction
if [[ -n "${{ github.event.pull_request.number }}" ]]; then
PR_NUM="${{ github.event.pull_request.number }}"
elif [[ -n "${{ github.event.inputs.pr_number }}" ]]; then
PR_NUM="${{ github.event.inputs.pr_number }}"
else
echo "❌ No PR number found in event or inputs"
exit 1
fi
echo "Using PR number: $PR_NUM"
OUTPUT=$(python -m showtime sync $PR_NUM --check-only)
echo "$OUTPUT"
# Extract outputs for conditional steps
ACTION=$(echo "$OUTPUT" | grep "action_needed=" | cut -d'=' -f2)
BUILD=$(echo "$OUTPUT" | grep "build_needed=" | cut -d'=' -f2)
DEPLOY=$(echo "$OUTPUT" | grep "deploy_needed=" | cut -d'=' -f2)
echo "action_needed=$ACTION" >> $GITHUB_OUTPUT
echo "build_needed=$BUILD" >> $GITHUB_OUTPUT
echo "deploy_needed=$DEPLOY" >> $GITHUB_OUTPUT
echo "pr_number=$PR_NUM" >> $GITHUB_OUTPUT
- name: Get SHA for potential build
id: sha
if: steps.check.outputs.build_needed == 'true'
run: |
# SHA handling for different event types
if [[ -n "${{ github.event.inputs.sha }}" ]]; then
SHA="${{ github.event.inputs.sha }}"
echo "Using override SHA: $SHA"
elif [[ -n "${{ github.event.pull_request.head.sha }}" ]]; then
SHA="${{ github.event.pull_request.head.sha }}"
echo "Using PR head SHA: $SHA"
elif [[ "${{ github.event_name }}" == "workflow_dispatch" && -n "${{ github.event.inputs.pr_number }}" ]]; then
# For manual dispatch with PR number, fetch the latest PR SHA via API
PR_NUM="${{ github.event.inputs.pr_number }}"
echo "Fetching latest SHA for PR $PR_NUM via GitHub API..."
SHA=$(gh api repos/${{ github.repository }}/pulls/$PR_NUM --jq '.head.sha')
echo "Using PR $PR_NUM latest SHA: $SHA"
elif [[ "${{ github.event_name }}" == "push" ]]; then
SHA="${{ github.sha }}"
echo "Using push SHA: $SHA"
else
echo "❌ No SHA available from any source"
exit 1
fi
# Validate SHA format (40-char hex)
if [[ ! "$SHA" =~ ^[a-f0-9]{40}$ ]]; then
echo "❌ Invalid SHA format: $SHA"
exit 1
fi
echo "build_sha=$SHA" >> $GITHUB_OUTPUT
# Extract short SHA (first 7 chars) for readable tagging
SHORT_SHA=${SHA:0:7}
echo "build_short_sha=$SHORT_SHA" >> $GITHUB_OUTPUT
- name: Checkout PR code
if: steps.check.outputs.build_needed == 'true'
uses: actions/checkout@v4
with:
ref: ${{ steps.sha.outputs.build_sha }}
fetch-depth: 1
persist-credentials: false
- name: Setup Docker Environment
if: steps.check.outputs.build_needed == 'true'
uses: ./.github/actions/setup-docker
with:
dockerhub-user: ${{ env.DOCKERHUB_USER }}
dockerhub-token: ${{ env.DOCKERHUB_TOKEN }}
build: "true"
install-docker-compose: "false"
- name: Setup supersetbot
if: steps.check.outputs.build_needed == 'true'
uses: ./.github/actions/setup-supersetbot/
- name: Build Docker image
if: steps.check.outputs.build_needed == 'true'
id: build
run: |
PR_NUM="${{ steps.check.outputs.pr_number }}"
SHA="${{ steps.sha.outputs.build_sha }}"
SHORT_SHA="${{ steps.sha.outputs.build_short_sha }}"
# Create custom tag: pr-{PR_NUMBER}-{SHORT_SHA}-ci
CUSTOM_TAG="apache/superset:pr-$PR_NUM-$SHORT_SHA-ci"
echo "Building with custom tag: $CUSTOM_TAG"
# Build with custom tag via extraFlags
supersetbot docker \
--push \
--load \
--preset ci \
--platform linux/amd64 \
--context-ref "$SHA" \
--extra-flags "--build-arg INCLUDE_CHROMIUM=false --build-arg LOAD_EXAMPLES_DUCKDB=true -t $CUSTOM_TAG"
# Output the specific tag for showtime to use
echo "docker_tag=$CUSTOM_TAG" >> $GITHUB_OUTPUT
- name: Execute sync deployment
if: steps.check.outputs.deploy_needed == 'true'
run: |
PR_NUM="${{ steps.check.outputs.pr_number }}"
# Log the Docker tag that was built (for debugging)
if [[ "${{ steps.check.outputs.build_needed }}" == "true" ]]; then
DOCKER_TAG="${{ steps.build.outputs.docker_tag }}"
echo "Built Docker tag: $DOCKER_TAG"
echo "Showtime CLI will need to use this tag when --docker-image is implemented"
fi
# For now, let showtime CLI determine which image to use
python -m showtime sync $PR_NUM --deploy