feat: add real Stripe integration, e2e tests, and Pi deployment

Replace documentation-only repo with working code:

- Stripe integration: webhook handler (8 event types), billing API
  (customers, checkout, payments, subscriptions, invoices)
- Express API server with health endpoint, structured logging
- E2E tests (Playwright): health, webhook signature verification,
  billing API validation
- Unit tests: webhook event handler coverage for all event types
- Pi deployment: deploy.sh (rsync + systemd), NGINX load balancer
  across Pi cluster, Docker support
- CI/CD: test workflow, Pi deploy workflow, updated auto-deploy
  and self-healing to run real tests before deploying
- Move resume docs to docs/ to separate code from documentation

https://claude.ai/code/session_01Mf5Pg82fV6BTRS9GnpV7nr
This commit is contained in:
Claude
2026-03-04 09:00:51 +00:00
parent dfa351891e
commit 20232bfd69
31 changed files with 1409 additions and 299 deletions

View File

@@ -1,78 +1,73 @@
name: 🔧 Self-Healing
name: Self-Healing
on:
schedule:
- cron: '*/30 * * * *' # Every 30 minutes
- cron: '*/30 * * * *'
workflow_dispatch:
workflow_run:
workflows: ["🚀 Auto Deploy"]
workflows: ["Auto Deploy"]
types: [completed]
jobs:
monitor:
name: Monitor Deployments
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/checkout@v4
- name: Check Health
id: health
run: |
if [ ! -z "${{ secrets.DEPLOY_URL }}" ]; then
STATUS=$(curl -s -o /dev/null -w "%{http_code}" ${{ secrets.DEPLOY_URL }}/api/health || echo "000")
if [ -n "${{ secrets.DEPLOY_URL }}" ]; then
STATUS=$(curl -s -o /dev/null -w "%{http_code}" "${{ secrets.DEPLOY_URL }}/api/health" || echo "000")
echo "status=$STATUS" >> $GITHUB_OUTPUT
else
echo "status=skip" >> $GITHUB_OUTPUT
fi
- name: Auto-Rollback
if: steps.health.outputs.status != '200' && steps.health.outputs.status != 'skip'
run: |
echo "🚨 Health check failed (Status: ${{ steps.health.outputs.status }})"
echo "Health check failed (Status: ${{ steps.health.outputs.status }})"
echo "Triggering rollback..."
gh workflow run auto-deploy.yml --ref $(git rev-parse HEAD~1)
gh workflow run auto-deploy.yml --ref $(git rev-parse HEAD~1) || true
env:
GH_TOKEN: ${{ github.token }}
- name: Attempt Auto-Fix
if: steps.health.outputs.status != '200' && steps.health.outputs.status != 'skip'
run: |
echo "🔧 Attempting automatic fixes..."
# Check for common issues
if [ -f "package.json" ]; then
npm ci || true
npm run build || true
fi
- name: Create Issue on Failure
if: failure()
if: steps.health.outputs.status != '200' && steps.health.outputs.status != 'skip'
uses: actions/github-script@v7
with:
script: |
github.rest.issues.create({
const issues = await github.rest.issues.listForRepo({
owner: context.repo.owner,
repo: context.repo.repo,
title: '🚨 Self-Healing: Deployment Health Check Failed',
body: `Deployment health check failed.\n\nStatus: ${{ steps.health.outputs.status }}\nWorkflow: ${context.workflow}\nRun: ${context.runId}`,
labels: ['bug', 'deployment', 'auto-generated']
})
labels: 'deployment,auto-generated',
state: 'open',
});
if (issues.data.length < 3) {
github.rest.issues.create({
owner: context.repo.owner,
repo: context.repo.repo,
title: 'Self-Healing: Health Check Failed (Status: ${{ steps.health.outputs.status }})',
body: `Health check failed.\n\nStatus: ${{ steps.health.outputs.status }}\nWorkflow: ${context.workflow}\nRun: ${context.runId}\nTimestamp: ${new Date().toISOString()}`,
labels: ['bug', 'deployment', 'auto-generated']
});
}
dependency-updates:
name: Auto Update Dependencies
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
- uses: actions/checkout@v4
- uses: actions/setup-node@v4
if: hashFiles('package.json') != ''
uses: actions/setup-node@v4
with:
node-version: '20'
- name: Update npm dependencies
if: hashFiles('package.json') != ''
run: |