superset-showtime 0.5.11__py3-none-any.whl → 0.5.18__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of superset-showtime might be problematic. Click here for more details.
- showtime/__init__.py +1 -1
- showtime/core/emojis.py +1 -0
- showtime/core/git_validation.py +3 -0
- showtime/core/github.py +0 -8
- showtime/core/label_colors.py +4 -0
- showtime/core/pull_request.py +204 -82
- showtime/core/show.py +23 -17
- showtime/data/ecs-task-definition.json +1 -1
- {superset_showtime-0.5.11.dist-info → superset_showtime-0.5.18.dist-info}/METADATA +1 -1
- superset_showtime-0.5.18.dist-info/RECORD +17 -0
- superset_showtime-0.5.11.dist-info/RECORD +0 -17
- {superset_showtime-0.5.11.dist-info → superset_showtime-0.5.18.dist-info}/WHEEL +0 -0
- {superset_showtime-0.5.11.dist-info → superset_showtime-0.5.18.dist-info}/entry_points.txt +0 -0
showtime/__init__.py
CHANGED
showtime/core/emojis.py
CHANGED
|
@@ -13,6 +13,7 @@ EMOJI_MEANINGS = {
|
|
|
13
13
|
"🚦": "status", # Traffic light for environment status
|
|
14
14
|
"🏗️": "building", # Construction for building environments
|
|
15
15
|
"🎯": "active", # Target for currently active environment
|
|
16
|
+
"🔒": "blocked", # Lock for blocking all operations
|
|
16
17
|
# Metadata
|
|
17
18
|
"📅": "created_at", # Calendar for creation timestamp
|
|
18
19
|
"🌐": "ip", # Globe for IP address
|
showtime/core/git_validation.py
CHANGED
|
@@ -134,6 +134,9 @@ def _validate_sha_via_github_api(required_sha: str) -> Tuple[bool, Optional[str]
|
|
|
134
134
|
# If status is 'ahead' or 'identical', required SHA is ancestor (good)
|
|
135
135
|
# If status is 'behind', current is behind required (bad)
|
|
136
136
|
if status in ["ahead", "identical"]:
|
|
137
|
+
print(
|
|
138
|
+
f"✅ Validated that required SHA {required_sha[:7]} is included in current branch"
|
|
139
|
+
)
|
|
137
140
|
return True, None
|
|
138
141
|
else:
|
|
139
142
|
return (
|
showtime/core/github.py
CHANGED
|
@@ -111,14 +111,6 @@ class GitHubInterface:
|
|
|
111
111
|
if response.status_code not in (200, 204, 404):
|
|
112
112
|
response.raise_for_status()
|
|
113
113
|
|
|
114
|
-
def set_labels(self, pr_number: int, labels: List[str]) -> None:
|
|
115
|
-
"""Replace all labels on a PR"""
|
|
116
|
-
url = f"{self.base_url}/repos/{self.org}/{self.repo}/issues/{pr_number}/labels"
|
|
117
|
-
|
|
118
|
-
with httpx.Client() as client:
|
|
119
|
-
response = client.put(url, headers=self.headers, json={"labels": labels})
|
|
120
|
-
response.raise_for_status()
|
|
121
|
-
|
|
122
114
|
def get_latest_commit_sha(self, pr_number: int) -> str:
|
|
123
115
|
"""Get the latest commit SHA for a PR"""
|
|
124
116
|
pr_data = self.get_pr_data(pr_number)
|
showtime/core/label_colors.py
CHANGED
|
@@ -31,6 +31,10 @@ LABEL_DEFINITIONS = {
|
|
|
31
31
|
"color": "FFE4B5", # Light orange
|
|
32
32
|
"description": "Freeze PR - prevent auto-sync on new commits",
|
|
33
33
|
},
|
|
34
|
+
"🎪 🔒 showtime-blocked": {
|
|
35
|
+
"color": "dc3545", # Red - blocking/danger
|
|
36
|
+
"description": "Block all Showtime operations - maintenance mode",
|
|
37
|
+
},
|
|
34
38
|
}
|
|
35
39
|
|
|
36
40
|
# Status-specific label patterns (generated dynamically)
|
showtime/core/pull_request.py
CHANGED
|
@@ -60,7 +60,7 @@ class PullRequest:
|
|
|
60
60
|
|
|
61
61
|
def __init__(self, pr_number: int, labels: List[str]):
|
|
62
62
|
self.pr_number = pr_number
|
|
63
|
-
self.labels = labels
|
|
63
|
+
self.labels = set(labels) # Convert to set for O(1) operations
|
|
64
64
|
self._shows = self._parse_shows_from_labels()
|
|
65
65
|
|
|
66
66
|
@property
|
|
@@ -90,20 +90,10 @@ class PullRequest:
|
|
|
90
90
|
|
|
91
91
|
@property
|
|
92
92
|
def building_show(self) -> Optional[Show]:
|
|
93
|
-
"""The currently building show (from
|
|
94
|
-
building_sha = None
|
|
95
|
-
for label in self.labels:
|
|
96
|
-
if label.startswith("🎪 🏗️ "):
|
|
97
|
-
building_sha = label.split(" ")[2]
|
|
98
|
-
break
|
|
99
|
-
|
|
100
|
-
if not building_sha:
|
|
101
|
-
return None
|
|
102
|
-
|
|
93
|
+
"""The currently building show (from building/deploying status)"""
|
|
103
94
|
for show in self.shows:
|
|
104
|
-
if show.
|
|
95
|
+
if show.status in ["building", "deploying"]:
|
|
105
96
|
return show
|
|
106
|
-
|
|
107
97
|
return None
|
|
108
98
|
|
|
109
99
|
@property
|
|
@@ -151,9 +141,122 @@ class PullRequest:
|
|
|
151
141
|
|
|
152
142
|
def refresh_labels(self) -> None:
|
|
153
143
|
"""Refresh labels from GitHub and reparse shows"""
|
|
154
|
-
self.labels = get_github().get_labels(self.pr_number)
|
|
144
|
+
self.labels = set(get_github().get_labels(self.pr_number))
|
|
155
145
|
self._shows = self._parse_shows_from_labels()
|
|
156
146
|
|
|
147
|
+
def add_label(self, label: str) -> None:
|
|
148
|
+
"""Add label with logging and optimistic state update"""
|
|
149
|
+
print(f"🏷️ Added: {label}")
|
|
150
|
+
get_github().add_label(self.pr_number, label)
|
|
151
|
+
self.labels.add(label)
|
|
152
|
+
|
|
153
|
+
def remove_label(self, label: str) -> None:
|
|
154
|
+
"""Remove label with logging and optimistic state update"""
|
|
155
|
+
print(f"🗑️ Removed: {label}")
|
|
156
|
+
get_github().remove_label(self.pr_number, label)
|
|
157
|
+
self.labels.discard(label) # Safe - won't raise if not present
|
|
158
|
+
|
|
159
|
+
def remove_sha_labels(self, sha: str) -> None:
|
|
160
|
+
"""Remove all labels for a specific SHA"""
|
|
161
|
+
sha_short = sha[:7]
|
|
162
|
+
labels_to_remove = [
|
|
163
|
+
label for label in self.labels if label.startswith("🎪") and sha_short in label
|
|
164
|
+
]
|
|
165
|
+
if labels_to_remove:
|
|
166
|
+
print(f"🗑️ Removing SHA {sha_short} labels: {labels_to_remove}")
|
|
167
|
+
for label in labels_to_remove:
|
|
168
|
+
self.remove_label(label)
|
|
169
|
+
|
|
170
|
+
def remove_showtime_labels(self) -> None:
|
|
171
|
+
"""Remove ALL circus tent labels"""
|
|
172
|
+
circus_labels = [label for label in self.labels if label.startswith("🎪 ")]
|
|
173
|
+
if circus_labels:
|
|
174
|
+
print(f"🎪 Removing all showtime labels: {circus_labels}")
|
|
175
|
+
for label in circus_labels:
|
|
176
|
+
self.remove_label(label)
|
|
177
|
+
|
|
178
|
+
def set_show_status(self, show: Show, new_status: str) -> None:
|
|
179
|
+
"""Atomically update show status with thorough label cleanup"""
|
|
180
|
+
show.status = new_status
|
|
181
|
+
|
|
182
|
+
# 1. Refresh labels to get current GitHub state
|
|
183
|
+
self.refresh_labels()
|
|
184
|
+
|
|
185
|
+
# 2. Remove ALL existing status labels for this SHA (not just the "expected" one)
|
|
186
|
+
status_labels_to_remove = [
|
|
187
|
+
label for label in self.labels if label.startswith(f"🎪 {show.sha} 🚦 ")
|
|
188
|
+
]
|
|
189
|
+
|
|
190
|
+
for label in status_labels_to_remove:
|
|
191
|
+
self.remove_label(label)
|
|
192
|
+
|
|
193
|
+
# 3. Add the new status label
|
|
194
|
+
new_status_label = f"🎪 {show.sha} 🚦 {new_status}"
|
|
195
|
+
self.add_label(new_status_label)
|
|
196
|
+
|
|
197
|
+
def set_active_show(self, show: Show) -> None:
|
|
198
|
+
"""Atomically set this show as the active environment"""
|
|
199
|
+
from .emojis import CIRCUS_PREFIX, MEANING_TO_EMOJI
|
|
200
|
+
|
|
201
|
+
# 1. Refresh to get current state
|
|
202
|
+
self.refresh_labels()
|
|
203
|
+
|
|
204
|
+
# 2. Remove ALL existing active pointers (ensure only one)
|
|
205
|
+
active_emoji = MEANING_TO_EMOJI["active"] # Gets 🎯
|
|
206
|
+
active_prefix = f"{CIRCUS_PREFIX} {active_emoji} " # "🎪 🎯 "
|
|
207
|
+
active_pointers = [label for label in self.labels if label.startswith(active_prefix)]
|
|
208
|
+
|
|
209
|
+
for pointer in active_pointers:
|
|
210
|
+
self.remove_label(pointer)
|
|
211
|
+
|
|
212
|
+
# 3. Set this show as the new active one
|
|
213
|
+
active_pointer = f"{active_prefix}{show.sha}" # "🎪 🎯 abc123f"
|
|
214
|
+
self.add_label(active_pointer)
|
|
215
|
+
|
|
216
|
+
def _check_authorization(self) -> bool:
|
|
217
|
+
"""Check if current GitHub actor is authorized for operations"""
|
|
218
|
+
import os
|
|
219
|
+
|
|
220
|
+
import httpx
|
|
221
|
+
|
|
222
|
+
# Only check in GitHub Actions context
|
|
223
|
+
if os.getenv("GITHUB_ACTIONS") != "true":
|
|
224
|
+
return True
|
|
225
|
+
|
|
226
|
+
actor = os.getenv("GITHUB_ACTOR")
|
|
227
|
+
if not actor:
|
|
228
|
+
return True # No actor info, allow operation
|
|
229
|
+
|
|
230
|
+
try:
|
|
231
|
+
# Use existing GitHubInterface for consistency
|
|
232
|
+
github = get_github()
|
|
233
|
+
|
|
234
|
+
# Check collaborator permissions
|
|
235
|
+
perm_url = f"{github.base_url}/repos/{github.org}/{github.repo}/collaborators/{actor}/permission"
|
|
236
|
+
|
|
237
|
+
with httpx.Client() as client:
|
|
238
|
+
response = client.get(perm_url, headers=github.headers)
|
|
239
|
+
if response.status_code == 404:
|
|
240
|
+
return False # Not a collaborator
|
|
241
|
+
response.raise_for_status()
|
|
242
|
+
|
|
243
|
+
data = response.json()
|
|
244
|
+
permission = data.get("permission", "none")
|
|
245
|
+
|
|
246
|
+
# Allow write and admin permissions only
|
|
247
|
+
authorized = permission in ["write", "admin"]
|
|
248
|
+
|
|
249
|
+
if not authorized:
|
|
250
|
+
print(f"🚨 Unauthorized actor {actor} (permission: {permission})")
|
|
251
|
+
# Set blocked label for security
|
|
252
|
+
self.add_label("🎪 🔒 showtime-blocked")
|
|
253
|
+
|
|
254
|
+
return authorized
|
|
255
|
+
|
|
256
|
+
except Exception as e:
|
|
257
|
+
print(f"⚠️ Authorization check failed: {e}")
|
|
258
|
+
return True # Fail open for non-security operations
|
|
259
|
+
|
|
157
260
|
def analyze(self, target_sha: str, pr_state: str = "open") -> AnalysisResult:
|
|
158
261
|
"""Analyze what actions are needed (read-only, for --check-only)
|
|
159
262
|
|
|
@@ -177,7 +280,7 @@ class PullRequest:
|
|
|
177
280
|
build_needed = action_needed in ["create_environment", "rolling_update", "auto_sync"]
|
|
178
281
|
|
|
179
282
|
# Determine if sync execution is needed
|
|
180
|
-
sync_needed = action_needed
|
|
283
|
+
sync_needed = action_needed not in ["no_action", "blocked"]
|
|
181
284
|
|
|
182
285
|
return AnalysisResult(
|
|
183
286
|
action_needed=action_needed,
|
|
@@ -213,7 +316,15 @@ class PullRequest:
|
|
|
213
316
|
# 1. Determine what action is needed
|
|
214
317
|
action_needed = self._determine_action(target_sha)
|
|
215
318
|
|
|
216
|
-
# 2.
|
|
319
|
+
# 2. Check for blocked state (fast bailout)
|
|
320
|
+
if action_needed == "blocked":
|
|
321
|
+
return SyncResult(
|
|
322
|
+
success=False,
|
|
323
|
+
action_taken="blocked",
|
|
324
|
+
error="🔒 Showtime operations are blocked for this PR. Remove '🎪 🔒 showtime-blocked' label to re-enable.",
|
|
325
|
+
)
|
|
326
|
+
|
|
327
|
+
# 3. Atomic claim for environment changes (PR-level lock)
|
|
217
328
|
if action_needed in ["create_environment", "rolling_update", "auto_sync"]:
|
|
218
329
|
print(f"🔒 Claiming environment for {action_needed}...")
|
|
219
330
|
if not self._atomic_claim(target_sha, action_needed, dry_run_github):
|
|
@@ -235,20 +346,22 @@ class PullRequest:
|
|
|
235
346
|
# Phase 1: Docker build
|
|
236
347
|
print("🐳 Building Docker image...")
|
|
237
348
|
show.build_docker(dry_run_docker)
|
|
238
|
-
show.status = "built"
|
|
239
349
|
print("✅ Docker build completed")
|
|
240
|
-
self._update_show_labels(show, dry_run_github)
|
|
241
350
|
|
|
242
351
|
# Phase 2: AWS deployment
|
|
243
352
|
print("☁️ Deploying to AWS ECS...")
|
|
353
|
+
self.set_show_status(show, "deploying")
|
|
244
354
|
show.deploy_aws(dry_run_aws)
|
|
245
|
-
show
|
|
355
|
+
self.set_show_status(show, "running")
|
|
356
|
+
self.set_active_show(show)
|
|
246
357
|
print(f"✅ Deployment completed - environment running at {show.ip}:8080")
|
|
247
358
|
self._update_show_labels(show, dry_run_github)
|
|
248
|
-
|
|
359
|
+
|
|
249
360
|
# Blue-green cleanup: stop all other environments for this PR
|
|
250
|
-
cleaned_count = self.stop_previous_environments(
|
|
251
|
-
|
|
361
|
+
cleaned_count = self.stop_previous_environments(
|
|
362
|
+
show.sha, dry_run_github, dry_run_aws
|
|
363
|
+
)
|
|
364
|
+
|
|
252
365
|
# Show AWS console URLs for monitoring
|
|
253
366
|
self._show_service_urls(show)
|
|
254
367
|
|
|
@@ -267,23 +380,25 @@ class PullRequest:
|
|
|
267
380
|
print(f"🔄 Rolling update: {old_show.sha} → {new_show.sha}")
|
|
268
381
|
self._post_rolling_start_comment(old_show, new_show, dry_run_github)
|
|
269
382
|
|
|
270
|
-
# Phase 1: Docker build
|
|
383
|
+
# Phase 1: Docker build
|
|
271
384
|
print("🐳 Building updated Docker image...")
|
|
272
385
|
new_show.build_docker(dry_run_docker)
|
|
273
|
-
new_show.status = "built"
|
|
274
386
|
print("✅ Docker build completed")
|
|
275
|
-
self._update_show_labels(new_show, dry_run_github)
|
|
276
387
|
|
|
277
388
|
# Phase 2: Blue-green deployment
|
|
278
389
|
print("☁️ Deploying updated environment...")
|
|
390
|
+
self.set_show_status(new_show, "deploying")
|
|
279
391
|
new_show.deploy_aws(dry_run_aws)
|
|
280
|
-
new_show
|
|
392
|
+
self.set_show_status(new_show, "running")
|
|
393
|
+
self.set_active_show(new_show)
|
|
281
394
|
print(f"✅ Rolling update completed - new environment at {new_show.ip}:8080")
|
|
282
395
|
self._update_show_labels(new_show, dry_run_github)
|
|
283
|
-
|
|
396
|
+
|
|
284
397
|
# Blue-green cleanup: stop all other environments for this PR
|
|
285
|
-
cleaned_count = self.stop_previous_environments(
|
|
286
|
-
|
|
398
|
+
cleaned_count = self.stop_previous_environments(
|
|
399
|
+
new_show.sha, dry_run_github, dry_run_aws
|
|
400
|
+
)
|
|
401
|
+
|
|
287
402
|
# Show AWS console URLs for monitoring
|
|
288
403
|
self._show_service_urls(new_show)
|
|
289
404
|
|
|
@@ -298,7 +413,7 @@ class PullRequest:
|
|
|
298
413
|
self._post_cleanup_comment(self.current_show, dry_run_github)
|
|
299
414
|
# Remove all circus labels after successful stop
|
|
300
415
|
if not dry_run_github:
|
|
301
|
-
|
|
416
|
+
self.remove_showtime_labels()
|
|
302
417
|
print("🏷️ GitHub labels cleaned up")
|
|
303
418
|
print("✅ Environment destroyed")
|
|
304
419
|
return SyncResult(success=True, action_taken="destroy_environment")
|
|
@@ -330,7 +445,7 @@ class PullRequest:
|
|
|
330
445
|
self.current_show.stop(**kwargs)
|
|
331
446
|
# Remove all circus labels after successful stop
|
|
332
447
|
if not kwargs.get("dry_run_github", False):
|
|
333
|
-
|
|
448
|
+
self.remove_showtime_labels()
|
|
334
449
|
return SyncResult(success=True, action_taken="stopped")
|
|
335
450
|
except Exception as e:
|
|
336
451
|
return SyncResult(success=False, action_taken="stop_failed", error=str(e))
|
|
@@ -366,15 +481,15 @@ class PullRequest:
|
|
|
366
481
|
for show in pr.shows:
|
|
367
482
|
# Determine show type based on pointer presence
|
|
368
483
|
show_type = "orphaned" # Default
|
|
369
|
-
|
|
484
|
+
|
|
370
485
|
# Check for active pointer
|
|
371
486
|
if any(label == f"🎪 🎯 {show.sha}" for label in pr.labels):
|
|
372
487
|
show_type = "active"
|
|
373
|
-
# Check for building pointer
|
|
374
|
-
elif
|
|
488
|
+
# Check for building pointer
|
|
489
|
+
elif show.status in ["building", "deploying"]:
|
|
375
490
|
show_type = "building"
|
|
376
491
|
# No pointer = orphaned
|
|
377
|
-
|
|
492
|
+
|
|
378
493
|
environment_data = {
|
|
379
494
|
"pr_number": pr_number,
|
|
380
495
|
"status": "active", # Keep for compatibility
|
|
@@ -397,12 +512,20 @@ class PullRequest:
|
|
|
397
512
|
"""Determine what sync action is needed based on target SHA state"""
|
|
398
513
|
# CRITICAL: Get fresh labels before any decisions
|
|
399
514
|
self.refresh_labels()
|
|
400
|
-
|
|
515
|
+
|
|
516
|
+
# Check for blocked state first (fast bailout)
|
|
517
|
+
if "🎪 🔒 showtime-blocked" in self.labels:
|
|
518
|
+
return "blocked"
|
|
519
|
+
|
|
520
|
+
# Check authorization (security layer)
|
|
521
|
+
if not self._check_authorization():
|
|
522
|
+
return "blocked"
|
|
523
|
+
|
|
401
524
|
target_sha_short = target_sha[:7] # Ensure we're working with short SHA
|
|
402
|
-
|
|
525
|
+
|
|
403
526
|
# Get the specific show for the target SHA
|
|
404
527
|
target_show = self.get_show_by_sha(target_sha_short)
|
|
405
|
-
|
|
528
|
+
|
|
406
529
|
# Check for explicit trigger labels
|
|
407
530
|
trigger_labels = [label for label in self.labels if "showtime-trigger-" in label]
|
|
408
531
|
|
|
@@ -440,16 +563,16 @@ class PullRequest:
|
|
|
440
563
|
"""Atomically claim this PR for the current job based on target SHA state"""
|
|
441
564
|
# CRITICAL: Get fresh labels before any decisions
|
|
442
565
|
self.refresh_labels()
|
|
443
|
-
|
|
566
|
+
|
|
444
567
|
target_sha_short = target_sha[:7]
|
|
445
568
|
target_show = self.get_show_by_sha(target_sha_short)
|
|
446
|
-
|
|
447
|
-
# 1. Validate current state allows this action for target SHA
|
|
569
|
+
|
|
570
|
+
# 1. Validate current state allows this action for target SHA
|
|
448
571
|
if action in ["create_environment", "rolling_update", "auto_sync"]:
|
|
449
572
|
if target_show and target_show.status in [
|
|
450
573
|
"building",
|
|
451
|
-
"built",
|
|
452
|
-
"deploying",
|
|
574
|
+
"built",
|
|
575
|
+
"deploying",
|
|
453
576
|
]:
|
|
454
577
|
return False # Target SHA already in progress - ONLY conflict case returns
|
|
455
578
|
|
|
@@ -462,7 +585,7 @@ class PullRequest:
|
|
|
462
585
|
if trigger_labels:
|
|
463
586
|
print(f"🏷️ Removing trigger labels: {trigger_labels}")
|
|
464
587
|
for trigger_label in trigger_labels:
|
|
465
|
-
|
|
588
|
+
self.remove_label(trigger_label)
|
|
466
589
|
else:
|
|
467
590
|
print("🏷️ No trigger labels to remove")
|
|
468
591
|
|
|
@@ -470,17 +593,16 @@ class PullRequest:
|
|
|
470
593
|
if action in ["create_environment", "rolling_update", "auto_sync"]:
|
|
471
594
|
building_show = self._create_new_show(target_sha)
|
|
472
595
|
building_show.status = "building"
|
|
473
|
-
|
|
474
|
-
# Update labels to reflect building state
|
|
475
|
-
print(f"🏷️ Removing
|
|
476
|
-
|
|
477
|
-
|
|
596
|
+
|
|
597
|
+
# Update labels to reflect building state - only remove for this SHA
|
|
598
|
+
print(f"🏷️ Removing labels for SHA {target_sha[:7]}...")
|
|
599
|
+
self.remove_sha_labels(target_sha)
|
|
600
|
+
|
|
478
601
|
new_labels = building_show.to_circus_labels()
|
|
479
602
|
print(f"🏷️ Creating new labels: {new_labels}")
|
|
480
603
|
for label in new_labels:
|
|
481
604
|
try:
|
|
482
|
-
|
|
483
|
-
print(f" ✅ Added: {label}")
|
|
605
|
+
self.add_label(label)
|
|
484
606
|
except Exception as e:
|
|
485
607
|
print(f" ❌ Failed to add {label}: {e}")
|
|
486
608
|
raise
|
|
@@ -583,23 +705,21 @@ class PullRequest:
|
|
|
583
705
|
|
|
584
706
|
# First, remove any existing status labels for this SHA to ensure clean transitions
|
|
585
707
|
sha_status_labels = [
|
|
586
|
-
label for label in self.labels
|
|
587
|
-
if label.startswith(f"🎪 {show.sha} 🚦 ")
|
|
708
|
+
label for label in self.labels if label.startswith(f"🎪 {show.sha} 🚦 ")
|
|
588
709
|
]
|
|
589
710
|
for old_status_label in sha_status_labels:
|
|
590
|
-
|
|
711
|
+
self.remove_label(old_status_label)
|
|
591
712
|
|
|
592
713
|
# For running environments, ensure only ONE active pointer exists
|
|
593
714
|
if show.status == "running":
|
|
594
715
|
# Remove ALL existing active pointers (there should only be one)
|
|
595
716
|
existing_active_pointers = [
|
|
596
|
-
label for label in self.labels
|
|
597
|
-
if label.startswith("🎪 🎯 ")
|
|
717
|
+
label for label in self.labels if label.startswith("🎪 🎯 ")
|
|
598
718
|
]
|
|
599
719
|
for old_pointer in existing_active_pointers:
|
|
600
720
|
print(f"🎯 Removing old active pointer: {old_pointer}")
|
|
601
|
-
|
|
602
|
-
|
|
721
|
+
self.remove_label(old_pointer)
|
|
722
|
+
|
|
603
723
|
# CRITICAL: Refresh after removals before differential calculation
|
|
604
724
|
if existing_active_pointers:
|
|
605
725
|
print("🔄 Refreshing labels after pointer cleanup...")
|
|
@@ -607,11 +727,12 @@ class PullRequest:
|
|
|
607
727
|
|
|
608
728
|
# Now do normal differential updates - only for this SHA
|
|
609
729
|
current_sha_labels = {
|
|
610
|
-
label
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
label.startswith(f"🎪
|
|
730
|
+
label
|
|
731
|
+
for label in self.labels
|
|
732
|
+
if label.startswith("🎪")
|
|
733
|
+
and (
|
|
734
|
+
label.startswith(f"🎪 {show.sha} ") # SHA-first format: 🎪 abc123f 📅 ...
|
|
735
|
+
or label.startswith(f"🎪 🎯 {show.sha}") # Pointer format: 🎪 🎯 abc123f
|
|
615
736
|
)
|
|
616
737
|
}
|
|
617
738
|
desired_labels = set(show.to_circus_labels())
|
|
@@ -622,12 +743,12 @@ class PullRequest:
|
|
|
622
743
|
# Only add labels that don't exist
|
|
623
744
|
labels_to_add = desired_labels - current_sha_labels
|
|
624
745
|
for label in labels_to_add:
|
|
625
|
-
|
|
746
|
+
self.add_label(label)
|
|
626
747
|
|
|
627
748
|
# Only remove labels that shouldn't exist (excluding status labels already handled)
|
|
628
749
|
labels_to_remove = current_sha_labels - desired_labels
|
|
629
750
|
for label in labels_to_remove:
|
|
630
|
-
|
|
751
|
+
self.remove_label(label)
|
|
631
752
|
|
|
632
753
|
# Final refresh to update cache with all changes
|
|
633
754
|
self.refresh_labels()
|
|
@@ -635,54 +756,55 @@ class PullRequest:
|
|
|
635
756
|
def _show_service_urls(self, show: Show) -> None:
|
|
636
757
|
"""Show AWS console URLs for monitoring deployment"""
|
|
637
758
|
from .github_messages import get_aws_console_urls
|
|
638
|
-
|
|
759
|
+
|
|
639
760
|
urls = get_aws_console_urls(show.ecs_service_name)
|
|
640
|
-
print(
|
|
761
|
+
print("\n🎪 Monitor deployment progress:")
|
|
641
762
|
print(f"📝 Logs: {urls['logs']}")
|
|
642
763
|
print(f"📊 Service: {urls['service']}")
|
|
643
764
|
print("")
|
|
644
765
|
|
|
645
|
-
def stop_previous_environments(
|
|
766
|
+
def stop_previous_environments(
|
|
767
|
+
self, keep_sha: str, dry_run_github: bool = False, dry_run_aws: bool = False
|
|
768
|
+
) -> int:
|
|
646
769
|
"""Stop all environments except the specified SHA (blue-green cleanup)
|
|
647
|
-
|
|
770
|
+
|
|
648
771
|
Args:
|
|
649
772
|
keep_sha: SHA of environment to keep running
|
|
650
|
-
dry_run_github: Skip GitHub label operations
|
|
773
|
+
dry_run_github: Skip GitHub label operations
|
|
651
774
|
dry_run_aws: Skip AWS operations
|
|
652
|
-
|
|
775
|
+
|
|
653
776
|
Returns:
|
|
654
777
|
Number of environments stopped
|
|
655
778
|
"""
|
|
656
779
|
# Note: Labels should be fresh from recent _update_show_labels() call
|
|
657
780
|
stopped_count = 0
|
|
658
|
-
|
|
781
|
+
|
|
659
782
|
for show in self.shows:
|
|
660
783
|
if show.sha != keep_sha:
|
|
661
784
|
print(f"🧹 Cleaning up old environment: {show.sha} ({show.status})")
|
|
662
785
|
try:
|
|
663
786
|
show.stop(dry_run_github=dry_run_github, dry_run_aws=dry_run_aws)
|
|
664
|
-
|
|
787
|
+
|
|
665
788
|
# Remove ONLY existing labels for this old environment (not theoretical ones)
|
|
666
789
|
if not dry_run_github:
|
|
667
790
|
existing_labels = [
|
|
668
|
-
label
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
label == f"🎪 🏗️ {show.sha}"
|
|
791
|
+
label
|
|
792
|
+
for label in self.labels
|
|
793
|
+
if label.startswith(f"🎪 {show.sha} ") or label == f"🎪 🎯 {show.sha}"
|
|
672
794
|
]
|
|
673
795
|
print(f"🏷️ Removing existing labels for {show.sha}: {existing_labels}")
|
|
674
796
|
for label in existing_labels:
|
|
675
797
|
try:
|
|
676
|
-
|
|
798
|
+
self.remove_label(label)
|
|
677
799
|
except Exception as e:
|
|
678
800
|
print(f"⚠️ Failed to remove label {label}: {e}")
|
|
679
|
-
|
|
801
|
+
|
|
680
802
|
stopped_count += 1
|
|
681
803
|
print(f"✅ Stopped environment {show.sha}")
|
|
682
|
-
|
|
804
|
+
|
|
683
805
|
except Exception as e:
|
|
684
806
|
print(f"❌ Failed to stop environment {show.sha}: {e}")
|
|
685
|
-
|
|
807
|
+
|
|
686
808
|
if stopped_count > 0:
|
|
687
809
|
print(f"🧹 Blue-green cleanup: stopped {stopped_count} old environments")
|
|
688
810
|
# Refresh labels after cleanup
|
|
@@ -690,5 +812,5 @@ class PullRequest:
|
|
|
690
812
|
self.refresh_labels()
|
|
691
813
|
else:
|
|
692
814
|
print("ℹ️ No old environments to clean up")
|
|
693
|
-
|
|
815
|
+
|
|
694
816
|
return stopped_count
|
showtime/core/show.py
CHANGED
|
@@ -96,21 +96,24 @@ class Show:
|
|
|
96
96
|
|
|
97
97
|
def to_circus_labels(self) -> List[str]:
|
|
98
98
|
"""Convert show state to circus tent emoji labels (per-SHA format)"""
|
|
99
|
+
from .emojis import CIRCUS_PREFIX, MEANING_TO_EMOJI
|
|
100
|
+
|
|
99
101
|
if not self.created_at:
|
|
100
102
|
self.created_at = datetime.utcnow().strftime("%Y-%m-%dT%H-%M")
|
|
101
103
|
|
|
102
104
|
labels = [
|
|
103
|
-
f"
|
|
104
|
-
f"
|
|
105
|
-
f"
|
|
106
|
-
f"🎪 {self.sha} ⌛ {self.ttl}", # SHA-first TTL
|
|
105
|
+
f"{CIRCUS_PREFIX} {self.sha} {MEANING_TO_EMOJI['status']} {self.status}", # SHA-first status
|
|
106
|
+
f"{CIRCUS_PREFIX} {self.sha} {MEANING_TO_EMOJI['created_at']} {self.created_at}", # SHA-first timestamp
|
|
107
|
+
f"{CIRCUS_PREFIX} {self.sha} {MEANING_TO_EMOJI['ttl']} {self.ttl}", # SHA-first TTL
|
|
107
108
|
]
|
|
108
109
|
|
|
109
110
|
if self.ip:
|
|
110
|
-
labels.append(f"
|
|
111
|
+
labels.append(f"{CIRCUS_PREFIX} {self.sha} {MEANING_TO_EMOJI['ip']} {self.ip}:8080")
|
|
111
112
|
|
|
112
113
|
if self.requested_by:
|
|
113
|
-
labels.append(
|
|
114
|
+
labels.append(
|
|
115
|
+
f"{CIRCUS_PREFIX} {self.sha} {MEANING_TO_EMOJI['requested_by']} {self.requested_by}"
|
|
116
|
+
)
|
|
114
117
|
|
|
115
118
|
return labels
|
|
116
119
|
|
|
@@ -158,7 +161,6 @@ class Show:
|
|
|
158
161
|
def _build_docker_image(self) -> None:
|
|
159
162
|
"""Build Docker image for this environment"""
|
|
160
163
|
import os
|
|
161
|
-
import platform
|
|
162
164
|
import subprocess
|
|
163
165
|
|
|
164
166
|
tag = f"apache/superset:pr-{self.pr_number}-{self.sha}-ci"
|
|
@@ -187,19 +189,23 @@ class Show:
|
|
|
187
189
|
# Add caching based on environment
|
|
188
190
|
if is_ci:
|
|
189
191
|
# Full registry caching in CI (Docker driver supports it)
|
|
190
|
-
cmd.extend(
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
192
|
+
cmd.extend(
|
|
193
|
+
[
|
|
194
|
+
"--cache-from",
|
|
195
|
+
"type=registry,ref=apache/superset-cache:showtime",
|
|
196
|
+
"--cache-to",
|
|
197
|
+
"type=registry,mode=max,ref=apache/superset-cache:showtime",
|
|
198
|
+
]
|
|
199
|
+
)
|
|
196
200
|
print("🐳 CI environment: Using full registry caching")
|
|
197
201
|
else:
|
|
198
202
|
# Local build: cache-from only (no cache export)
|
|
199
|
-
cmd.extend(
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
+
cmd.extend(
|
|
204
|
+
[
|
|
205
|
+
"--cache-from",
|
|
206
|
+
"type=registry,ref=apache/superset-cache:showtime",
|
|
207
|
+
]
|
|
208
|
+
)
|
|
203
209
|
print("🐳 Local environment: Using cache-from only (no export)")
|
|
204
210
|
|
|
205
211
|
# Add --load only when explicitly requested for local testing
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: superset-showtime
|
|
3
|
-
Version: 0.5.
|
|
3
|
+
Version: 0.5.18
|
|
4
4
|
Summary: 🎪 Apache Superset ephemeral environment management with circus tent emoji state tracking
|
|
5
5
|
Project-URL: Homepage, https://github.com/apache/superset-showtime
|
|
6
6
|
Project-URL: Documentation, https://superset-showtime.readthedocs.io/
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
showtime/__init__.py,sha256=apR60gqUgO9WuV06_c-B1cXzwzdQRcEaY-uYSPrrX0A,449
|
|
2
|
+
showtime/__main__.py,sha256=EVaDaTX69yIhCzChg99vqvFSCN4ELstEt7Mpb9FMZX8,109
|
|
3
|
+
showtime/cli.py,sha256=8vIJT5TiqXuHDGxRBg6jV3oNv5nKrmDOs5OgltycPeI,31664
|
|
4
|
+
showtime/core/__init__.py,sha256=54hbdFNGrzuNMBdraezfjT8Zi6g221pKlJ9mREnKwCw,34
|
|
5
|
+
showtime/core/aws.py,sha256=uTjJAvEBQMyTccS93WZeNPhfeKQhJgOQQ0BJdnQjvCU,35007
|
|
6
|
+
showtime/core/emojis.py,sha256=arK0N5Q5FLkvOkci-lacb3WS56LTvY8NjYRqt_lhP9s,2188
|
|
7
|
+
showtime/core/git_validation.py,sha256=3dmSGpMDplDAmKWHUyoUEPgt3__8oTuBZxbfuhocT00,6831
|
|
8
|
+
showtime/core/github.py,sha256=gMPJ5TOT6DdZk4y0XqW-C69I7O8A4eI40TgT4IFPqhQ,9623
|
|
9
|
+
showtime/core/github_messages.py,sha256=MfgwCukrEsWWesMsuL8saciDgP4nS-gijzu8DXr-Alg,7450
|
|
10
|
+
showtime/core/label_colors.py,sha256=gSe7EIMl4YjWkIgKHUvuaRSwgEB_B-NYQBxFFlF8Z3s,4065
|
|
11
|
+
showtime/core/pull_request.py,sha256=r-4tCjEjsZOcTk4cjw57yyhNzq1sLPt4SYa1S7RcDlQ,31998
|
|
12
|
+
showtime/core/show.py,sha256=sOgZvGXwdcNDsidF1F_XwPXlSeTb8-Zeqhqb8w1pqAM,9973
|
|
13
|
+
showtime/data/ecs-task-definition.json,sha256=d-NLkIhvr4C6AnwDfDIwUTx-6KFMH9wRkt6pVCbqZY4,2365
|
|
14
|
+
superset_showtime-0.5.18.dist-info/METADATA,sha256=aTfADzrQ7S-eVsJJDlOvIOaDeSJ4WHqdfW0MtKsqFpg,12053
|
|
15
|
+
superset_showtime-0.5.18.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
+
superset_showtime-0.5.18.dist-info/entry_points.txt,sha256=rDW7oZ57mqyBUS4N_3_R7bZNGVHB-104jwmY-hHC_ck,85
|
|
17
|
+
superset_showtime-0.5.18.dist-info/RECORD,,
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
showtime/__init__.py,sha256=HcxA_d-Wu3K1hL8OL_1I6y3u8cclS3dbUSMbv4RG2GA,449
|
|
2
|
-
showtime/__main__.py,sha256=EVaDaTX69yIhCzChg99vqvFSCN4ELstEt7Mpb9FMZX8,109
|
|
3
|
-
showtime/cli.py,sha256=8vIJT5TiqXuHDGxRBg6jV3oNv5nKrmDOs5OgltycPeI,31664
|
|
4
|
-
showtime/core/__init__.py,sha256=54hbdFNGrzuNMBdraezfjT8Zi6g221pKlJ9mREnKwCw,34
|
|
5
|
-
showtime/core/aws.py,sha256=uTjJAvEBQMyTccS93WZeNPhfeKQhJgOQQ0BJdnQjvCU,35007
|
|
6
|
-
showtime/core/emojis.py,sha256=MHEDuPIdfNiop4zbNLuviz3eY05QiftYSHHCVbkfKhw,2129
|
|
7
|
-
showtime/core/git_validation.py,sha256=Knr-9IAHXlhhkBeReJPlqzBG_TDWlevIqYaB26OPM04,6686
|
|
8
|
-
showtime/core/github.py,sha256=uETvKDO2Yhpqg3fxLtrKaCuZR3b-1LVmgnf5aLcqrAQ,9988
|
|
9
|
-
showtime/core/github_messages.py,sha256=MfgwCukrEsWWesMsuL8saciDgP4nS-gijzu8DXr-Alg,7450
|
|
10
|
-
showtime/core/label_colors.py,sha256=efhbFnz_3nqEnEqmgyF6_hZbxtCu_fmb68BIIUpSsnk,3895
|
|
11
|
-
showtime/core/pull_request.py,sha256=vKlPPlIeSNT_WmlZkOekLH_tGYm4pyJUZFHQC9dVCKY,27756
|
|
12
|
-
showtime/core/show.py,sha256=FpxDm52LASCJvf8UF998AtNiVzfdYIwNEsPAsOAAwL0,9701
|
|
13
|
-
showtime/data/ecs-task-definition.json,sha256=Y8ZbAAXdIDMnM-8zzfdUTlwp5RpWSyhe1gtfygKkqW8,2343
|
|
14
|
-
superset_showtime-0.5.11.dist-info/METADATA,sha256=Ekcs0XHNPJC-W8ZfULfh8CqbZTpKehGk1yJWirNOYAE,12053
|
|
15
|
-
superset_showtime-0.5.11.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
16
|
-
superset_showtime-0.5.11.dist-info/entry_points.txt,sha256=rDW7oZ57mqyBUS4N_3_R7bZNGVHB-104jwmY-hHC_ck,85
|
|
17
|
-
superset_showtime-0.5.11.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|