Skip to content

Commit 140e373

Browse files
authored
Merge branch 'main' into main
2 parents 9433d0c + 29085e9 commit 140e373

37 files changed

Lines changed: 4872 additions & 935 deletions
Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Staging Deployment
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
jobs:
9+
deploy-staging:
10+
name: Deploy to Staging
11+
runs-on: ubuntu-latest
12+
if: github.event.head_commit.author.name != 'github-actions[bot]'
13+
14+
steps:
15+
- name: Checkout repository
16+
uses: actions/checkout@v4
17+
with:
18+
fetch-depth: 0
19+
20+
- name: Set up Rust
21+
uses: dtolnay/rust-toolchain@stable
22+
with:
23+
targets: wasm32-unknown-unknown
24+
25+
- name: Install Soroban CLI
26+
run: |
27+
cargo install --locked soroban-cli
28+
29+
- name: Deploy Contracts to Testnet
30+
id: deploy_contracts
31+
env:
32+
SOROBAN_SECRET_KEY: ${{ secrets.STAGING_SOROBAN_SECRET_KEY }}
33+
SOROBAN_NETWORK: testnet
34+
run: |
35+
./scripts/deploy_contracts.sh testnet
36+
VAULT_ID=$(jq -r '.contracts.vault' deployments/contracts.testnet.json)
37+
STRATEGY_ID=$(jq -r '.contracts.mock_korean_strategy' deployments/contracts.testnet.json)
38+
echo "vault_id=$VAULT_ID" >> $GITHUB_OUTPUT
39+
echo "strategy_id=$STRATEGY_ID" >> $GITHUB_OUTPUT
40+
41+
- name: Set up Node.js
42+
uses: actions/setup-node@v4
43+
with:
44+
node-version: 20
45+
cache: 'npm'
46+
47+
- name: Deploy Backend
48+
working-directory: backend
49+
env:
50+
DATABASE_URL: ${{ secrets.STAGING_DATABASE_URL }}
51+
VAULT_CONTRACT_ID: ${{ steps.deploy_contracts.outputs.vault_id }}
52+
run: |
53+
npm ci
54+
npx prisma migrate deploy
55+
# Replace with your actual backend deployment command (e.g., Vercel, Railway, Render)
56+
# Example: npx vercel --token ${{ secrets.VERCEL_TOKEN }} --prod --yes
57+
echo "Backend deployment simulated"
58+
echo "BACKEND_URL=https://yieldvault-backend-staging.vercel.app" >> $GITHUB_ENV
59+
60+
- name: Deploy Frontend
61+
working-directory: frontend
62+
env:
63+
VITE_VAULT_CONTRACT_ID: ${{ steps.deploy_contracts.outputs.vault_id }}
64+
VITE_API_URL: ${{ env.BACKEND_URL }}
65+
run: |
66+
npm ci
67+
npm run build
68+
# Replace with your actual frontend deployment command
69+
# Example: npx vercel --token ${{ secrets.VERCEL_TOKEN }} --prod --yes
70+
echo "Frontend deployment simulated"
71+
echo "STAGING_URL=https://yieldvault-staging.vercel.app" >> $GITHUB_ENV
72+
73+
- name: Post Staging URL to PR
74+
uses: actions/github-script@v7
75+
with:
76+
script: |
77+
const { owner, repo } = context.repo;
78+
const sha = context.sha;
79+
80+
// Find PRs associated with this commit
81+
const prs = await github.rest.repos.listPullRequestsAssociatedWithCommit({
82+
owner,
83+
repo,
84+
commit_sha: sha,
85+
});
86+
87+
if (prs.data.length > 0) {
88+
const prNumber = prs.data[0].number;
89+
const body = `🚀 **Staging Environment Updated!**\n\n- **Frontend:** [${process.env.STAGING_URL}](${process.env.STAGING_URL})\n- **Backend API:** [${process.env.BACKEND_URL}](${process.env.BACKEND_URL})\n- **Vault Contract ID:** \`${{ steps.deploy_contracts.outputs.vault_id }}\`\n\n_This environment was automatically deployed to reflect the latest state of the \`main\` branch._`;
90+
91+
await github.rest.issues.createComment({
92+
owner,
93+
repo,
94+
issue_number: prNumber,
95+
body,
96+
});
97+
}

backend/.env.example

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,3 +39,29 @@ CORS_ALLOWED_ORIGINS=http://localhost:3000,https://app.yieldvault.finance
3939
EMAIL_PROVIDER=resend
4040
EMAIL_API_KEY=
4141
EMAIL_FROM_ADDRESS=notifications@yieldvault.finance
42+
43+
# ─── OpenTelemetry Distributed Tracing (Task 1) ──────────────────────────────
44+
# Set to "false" to disable tracing entirely
45+
OTEL_ENABLED=true
46+
# OTLP collector endpoint (Jaeger / Grafana Tempo / etc.)
47+
OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4318
48+
OTEL_SERVICE_NAME=yieldvault-backend
49+
50+
# ─── Soroban RPC Circuit Breaker (Task 2) ────────────────────────────────────
51+
# Number of consecutive failures before the circuit opens
52+
CIRCUIT_BREAKER_FAILURE_THRESHOLD=5
53+
# Sliding window in which failures are counted (ms)
54+
CIRCUIT_BREAKER_WINDOW_MS=30000
55+
# Time the circuit stays open before transitioning to half-open (ms)
56+
CIRCUIT_BREAKER_COOLDOWN_MS=30000
57+
58+
# ─── Request Deduplication (Task 3) ──────────────────────────────────────────
59+
# TTL for idempotency keys in milliseconds (default: 24 hours)
60+
IDEMPOTENCY_KEY_TTL_MS=86400000
61+
62+
# ─── Feature Flags (Task 4) ──────────────────────────────────────────────────
63+
# Path to a JSON file containing flag definitions (re-read on every evaluation)
64+
# FEATURE_FLAGS_PATH=/etc/yieldvault/flags.json
65+
# Alternatively, inline JSON (used when FEATURE_FLAGS_PATH is not set)
66+
# FEATURE_FLAGS={"deposit-v2":{"enabled":true},"strategy-selection":{"enabled":false}}
67+

0 commit comments

Comments
 (0)