Skip to content

feat: add AMI-based PR validation workflow#116

Open
bnsoni wants to merge 4 commits into
mainfrom
feat/spa-pr-validation-new
Open

feat: add AMI-based PR validation workflow#116
bnsoni wants to merge 4 commits into
mainfrom
feat/spa-pr-validation-new

Conversation

@bnsoni

@bnsoni bnsoni commented Apr 8, 2026

Copy link
Copy Markdown
Contributor

Summary

New spa-pr-validation-new.yml workflow that launches isolated EC2 instances from pre-built AMIs for PR testing instead of deploying to shared OCI VMs.

Flow

  1. Gate → detect changes, decide build strategy
  2. Acquire stg slot → domain-lock claims stg1-4
  3. Code quality → lint, typecheck, coverage, claude reviews (parallel, unchanged)
  4. Build images → ECR (app) + OCIR (playwright) (parallel, unchanged)
  5. Launch infra → EC2 from AMI via reusable-service-update.yml
  6. Deploy → PR mentor image + prod auth onto launched instance
  7. Test → all 4 browsers in parallel (chrome, firefox, safari, edge)
  8. Cleanup → save status → release slot → terminate EC2

Key differences from existing workflow

  • Isolated environments — fresh EC2 per PR, not shared VMs
  • Always parallel — all 4 browsers run simultaneously
  • Auto-cleanup — EC2 terminated after tests, clean slate every run
  • stg1-4 slots — domain-lock picks available slot, maps to infra variables

Prerequisites

  • STG1-4 variables set on mentorai (AMI IDs, subnet, SG, TG, key pair)
  • STG1-4 SSH key secrets set on mentorai
  • SERVICE_UPDATE_ACCESS_KEY and SERVICE_UPDATE_SECRET_KEY secrets needed on mentorai

Test plan

  • Set SERVICE_UPDATE secrets on mentorai
  • Create test PR, add run-tests label
  • Verify: stg slot acquired → EC2 launched → PR image deployed → 4 browsers pass → EC2 terminated

🤖 Generated with Claude Code

bnsoni and others added 4 commits April 8, 2026 13:05
New spa-pr-validation-new.yml that launches fresh EC2 from pre-built
AMI per PR run instead of deploying to shared OCI VMs.

Flow: acquire stg slot (1-4) via domain-lock → launch EC2 from AMI →
deploy PR mentor image + prod auth → run 4 browser tests in parallel →
save status → release slot → terminate EC2

Key differences from existing workflow:
- Isolated environment per PR (not shared VMs)
- All 4 browsers always parallel (no sequential mode)
- EC2 terminated after tests (clean slate every run)
- Uses reusable-service-update.yml for infra launch
- Domain-number maps to stg1-4 infrastructure

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
GitHub Actions doesn't allow dynamic secret selection in reusable
workflow secrets: blocks. Replaced reusable-service-update.yml +
reusable-spa-deployment.yml calls with a single inline
launch-and-deploy job that:

1. Resolves stg config based on domain-lock slot (1-4)
2. Selects the correct SSH key (STG1-4_SSH_KEY) via case statement
3. Opens SSH SG rule for runner IP
4. Launches EC2 from AMI (boto3)
5. Waits for SSH + runs service-update (Ansible)
6. Registers in ALB target group
7. Deploys PR mentor image + prod auth image
8. Waits for mentor health (with auto-restart on empty reply)
9. Revokes SSH SG rule

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Allows running the workflow from the Actions tab with a stg-slot
input (1-4). Skips domain-lock and code quality checks for dispatch.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Prevents split-brain routing where ALB sends some requests to old
instance with stale OAuth creds. Now deregisters all existing targets
from the target group before registering the new instance.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant