Skip to content

Commit dadacda

Browse files
authored
Merge branch 'main' into feat/cargo-testutils-feature-flag
2 parents 867d9b3 + 66864ca commit dadacda

90 files changed

Lines changed: 43460 additions & 409 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: Check ABI Drift
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- 'contracts/src/**'
7+
- 'frontend/src/generated/**'
8+
- '.github/workflows/check-bindings.yml'
9+
10+
jobs:
11+
check-bindings:
12+
runs-on: ubuntu-latest
13+
steps:
14+
- uses: actions/checkout@v4
15+
16+
- name: Setup Node.js
17+
uses: actions/setup-node@v4
18+
with:
19+
node-version: '18'
20+
21+
- name: Install dependencies
22+
run: npm ci
23+
24+
- name: Install Stellar CLI
25+
run: |
26+
curl -L https://github.com/stellar/js-stellar-sdk/releases/download/v14.0.0/stellar-cli-linux-x86_64.tar.gz -o stellar-cli.tar.gz
27+
tar -xzf stellar-cli.tar.gz
28+
chmod +x stellar
29+
30+
- name: Regenerate bindings
31+
run: npm run gen:bindings
32+
env:
33+
CONTRACT_ID: ${{ secrets.CONTRACT_ID }}
34+
RPC_URL: https://soroban-testnet.stellar.org
35+
NETWORK_PASSPHRASE: 'Test SDF Network ; September 2015'
36+
37+
- name: Check for ABI drift
38+
run: |
39+
if ! git diff --exit-code frontend/src/generated/; then
40+
echo "❌ ABI drift detected!"
41+
echo "Contract ABI changed but bindings were not regenerated."
42+
echo "Run 'npm run gen:bindings' and commit the changes."
43+
exit 1
44+
fi
45+
echo "✅ Bindings are up to date"

.github/workflows/load-test.yml

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
name: Load Test
2+
3+
on:
4+
schedule:
5+
- cron: '0 6 * * 1'
6+
workflow_dispatch:
7+
8+
jobs:
9+
load-test:
10+
runs-on: ubuntu-latest
11+
name: Load Test
12+
13+
steps:
14+
- name: Checkout code
15+
uses: actions/checkout@v4
16+
17+
- name: Setup Node.js
18+
uses: actions/setup-node@v4
19+
with:
20+
node-version: 20
21+
cache: 'npm'
22+
cache-dependency-path: 'backend/package-lock.json'
23+
24+
- name: Install backend dependencies
25+
working-directory: backend
26+
run: npm ci
27+
28+
- name: Install autocannon
29+
working-directory: backend
30+
run: npm install --no-save autocannon
31+
32+
- name: Build backend
33+
working-directory: backend
34+
run: npm run build
35+
36+
- name: Start backend (in-memory SQLite)
37+
working-directory: backend
38+
run: |
39+
NODE_ENV=test DB_PATH=:memory: node dist/index.js &
40+
BACKEND_PID=$!
41+
echo "Backend PID: $BACKEND_PID"
42+
echo "BACKEND_PID=$BACKEND_PID" >> $GITHUB_ENV
43+
for i in $(seq 1 30); do
44+
if curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:3001/api/health | grep -q 200; then
45+
echo "Backend is ready"
46+
break
47+
fi
48+
echo "Waiting for backend... attempt $i"
49+
sleep 2
50+
done
51+
52+
- name: Run CI load test
53+
id: load-test
54+
working-directory: backend
55+
run: |
56+
node scripts/ci-load-test.js 2>&1 | tee load-test-output.txt
57+
58+
- name: Check thresholds from JSON output
59+
id: check-thresholds
60+
run: |
61+
python3 << 'EOF'
62+
import json, os
63+
64+
with open("backend/load-test-output.txt") as f:
65+
content = f.read()
66+
67+
start = content.index("---JSON-START---") + len("---JSON-START---")
68+
end = content.index("---JSON-END---")
69+
summary = json.loads(content[start:end].strip())
70+
71+
p99 = summary["latency"]["p99"]
72+
error_rate = summary["requests"]["errorRate"]
73+
passed = summary["passed"]
74+
75+
with open(os.environ["GITHUB_OUTPUT"], "a") as out:
76+
out.write(f"summary={json.dumps(summary)}\n")
77+
out.write(f"p99={p99}\n")
78+
out.write(f"error-rate={error_rate}\n")
79+
out.write(f"passed={passed}\n")
80+
81+
print(f"p99: {p99}ms")
82+
print(f"Error rate: {error_rate}%")
83+
print(f"Passed: {passed}")
84+
85+
if not passed:
86+
print("❌ Thresholds exceeded!")
87+
exit(1)
88+
else:
89+
print("✅ All thresholds passed!")
90+
EOF
91+
92+
- name: Upload load test results
93+
if: always()
94+
uses: actions/upload-artifact@v4
95+
with:
96+
name: load-test-results
97+
path: backend/load-test-output.txt
98+
99+
- name: Cleanup backend
100+
if: always()
101+
run: |
102+
if [ -n "$BACKEND_PID" ]; then
103+
kill $BACKEND_PID 2>/dev/null || true
104+
fi

.vscode/settings.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
{}
1+
{
2+
}

CONTRIBUTING.md

Lines changed: 110 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,118 @@ Thank you for your interest in contributing to **Stellar Goal Vault**!
1818
- Check the [FAQ.md](./FAQ.md) for answers to common questions.
1919
- Browse `OPEN_SOURCE_ISSUES.md` for curated contribution ideas.
2020

21+
## Backend Development
22+
23+
### Prerequisites
24+
25+
- **Node.js** 18+ (check with `node --version`)
26+
- **npm** 9+ (comes with Node.js)
27+
28+
### Setup
29+
30+
1. Navigate to the backend directory:
31+
```bash
32+
cd backend
33+
```
34+
35+
2. Install dependencies:
36+
```bash
37+
npm install
38+
```
39+
40+
3. Copy the environment file:
41+
```bash
42+
cp .env.example .env
43+
```
44+
45+
4. Configure environment variables in `.env`:
46+
- `DB_PATH`: Path to SQLite database file (default: `../../data/campaigns.db`)
47+
- `NODE_ENV`: Set to `development` for local development
48+
- `PORT`: Server port (default: 3000)
49+
- `CORS_ALLOWED_ORIGINS`: Comma-separated list of allowed origins
50+
- `CONTRACT_ID`: Stellar contract ID (required for pledge operations)
51+
- `SOROBAN_RPC_URL`: URL to Soroban RPC endpoint
52+
- `NETWORK_PASSPHRASE`: Stellar network (default: `Test SDF Network ; September 2015` for testnet)
53+
54+
### Running the Backend
55+
56+
- **Development mode** (with auto-reload):
57+
```bash
58+
npm run dev
59+
```
60+
Server listens on `http://localhost:3000` by default.
61+
62+
- **Production mode** (build and run):
63+
```bash
64+
npm run build
65+
npm start
66+
```
67+
68+
- **Watch mode** (for editing and testing):
69+
```bash
70+
npm run dev
71+
```
72+
73+
### Testing
74+
75+
- **Run all tests once**:
76+
```bash
77+
npm test
78+
```
79+
80+
- **Run tests in watch mode** (re-run on file changes):
81+
```bash
82+
npm run test:watch
83+
```
84+
85+
- **Run with coverage**:
86+
```bash
87+
npm test -- --coverage
88+
```
89+
90+
### Database
91+
92+
- **Seeding**: The application automatically initializes the SQLite database with the schema on first run. To seed deterministic test campaigns:
93+
```bash
94+
npm test -- tests/services/seedDeterministic.test.ts
95+
```
96+
97+
- **Viewing the database**:
98+
- Use SQLite CLI: `sqlite3 ../../data/campaigns.db`
99+
- Or use a GUI tool like [DB Browser for SQLite](https://sqlitebrowser.org/)
100+
101+
- **Resetting the database** (for testing):
102+
- Delete the database file: `rm ../../data/campaigns.db`
103+
- Next run will recreate it with the schema
104+
105+
### Troubleshooting
106+
107+
#### "SQLITE_CANTOPEN" or database file not found
108+
- Ensure the directory specified in `DB_PATH` exists
109+
- Check file permissions on the database directory
110+
- If the directory doesn't exist, create it: `mkdir -p data`
111+
112+
#### Tests fail with "database is locked"
113+
- This indicates concurrent access issues. Ensure only one test process is running.
114+
- Try clearing the test database: `rm test-temp-*.db*`
115+
- Run tests serially: `npm test -- --no-coverage`
116+
117+
#### "Cannot find module" errors
118+
- Run `npm install` in the `backend` directory
119+
- Clear node_modules and reinstall: `rm -rf node_modules && npm install`
120+
121+
#### Port already in use
122+
- Change the `PORT` in `.env` to an available port (e.g., 3001)
123+
- Or kill the process on the current port
124+
125+
#### Environment variable not picked up
126+
- Ensure `.env` file is in the `backend` directory
127+
- Restart the development server after editing `.env`
128+
- Check for syntax errors in `.env` (no spaces around `=`)
129+
21130
## Testing
22131

23-
- Backend: `cd backend && npx vitest`
132+
- Backend: `cd backend && npm test`
24133
- Contract: `cd contracts && cargo test`
25134
- E2E: `npm run test:e2e`
26135

0 commit comments

Comments
 (0)