Skip to content

Commit 7799ce4

Browse files
authored
Merge pull request #66 from akordavid373/feature/user-authentication
Feature/user authentication
2 parents 853990c + d667b47 commit 7799ce4

28 files changed

Lines changed: 5508 additions & 2 deletions

.env.test

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# Test Environment Variables
2+
NODE_ENV=test
3+
DATABASE_URL=postgresql://test:test@localhost:5432/nepa_test
4+
5+
# JWT Secrets for testing
6+
JWT_SECRET=test_jwt_secret_key_for_testing_only
7+
JWT_REFRESH_SECRET=test_refresh_secret_key_for_testing_only
8+
9+
# Stellar Testnet
10+
STELLAR_NETWORK=testnet
11+
STELLAR_HORIZON_URL=https://horizon-testnet.stellar.org
12+
13+
# Redis (for testing, can be in-memory)
14+
REDIS_URL=redis://localhost:6379/1
15+
16+
# Email (disable for testing)
17+
EMAIL_SERVICE=none
18+
SMTP_HOST=
19+
SMTP_PORT=
20+
SMTP_USER=
21+
SMTP_PASS=
22+
23+
# File Storage (local for testing)
24+
FILE_STORAGE_TYPE=local
25+
UPLOAD_DIR=./test-uploads
26+
27+
# Rate Limiting (relaxed for testing)
28+
RATE_LIMIT_WINDOW_MS=60000
29+
RATE_LIMIT_MAX_REQUESTS=1000
30+
31+
# Logging
32+
LOG_LEVEL=error

.github/workflows/ci-cd.yml

Lines changed: 246 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,246 @@
1+
name: CI/CD Pipeline
2+
3+
on:
4+
push:
5+
branches: [ main, develop ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
test:
11+
runs-on: ubuntu-latest
12+
13+
services:
14+
postgres:
15+
image: postgres:15
16+
env:
17+
POSTGRES_PASSWORD: test
18+
POSTGRES_USER: test
19+
POSTGRES_DB: nepa_test
20+
options: >-
21+
--health-cmd pg_isready
22+
--health-interval 10s
23+
--health-timeout 5s
24+
--health-retries 5
25+
ports:
26+
- 5432:5432
27+
28+
redis:
29+
image: redis:7
30+
options: >-
31+
--health-cmd "redis-cli ping"
32+
--health-interval 10s
33+
--health-timeout 5s
34+
--health-retries 5
35+
ports:
36+
- 6379:6379
37+
38+
strategy:
39+
matrix:
40+
node-version: [18.x, 20.x]
41+
42+
steps:
43+
- name: Checkout code
44+
uses: actions/checkout@v4
45+
46+
- name: Setup Node.js ${{ matrix.node-version }}
47+
uses: actions/setup-node@v4
48+
with:
49+
node-version: ${{ matrix.node-version }}
50+
cache: 'npm'
51+
52+
- name: Install dependencies
53+
run: npm ci
54+
55+
- name: Copy test environment
56+
run: cp .env.test .env
57+
58+
- name: Wait for services to be ready
59+
run: |
60+
echo "Waiting for PostgreSQL..."
61+
while ! pg_isready -h localhost -p 5432 -U test; do
62+
sleep 1
63+
done
64+
echo "PostgreSQL is ready!"
65+
66+
echo "Waiting for Redis..."
67+
while ! redis-cli -h localhost -p 6379 ping; do
68+
sleep 1
69+
done
70+
echo "Redis is ready!"
71+
72+
- name: Generate Prisma client
73+
run: npx prisma generate
74+
75+
- name: Run database migrations
76+
run: npx prisma migrate deploy
77+
env:
78+
DATABASE_URL: postgresql://test:test@localhost:5432/nepa_test
79+
80+
- name: Run linting
81+
run: |
82+
if [ -f "package.json" ] && grep -q "lint" package.json; then
83+
npm run lint
84+
else
85+
echo "No lint script found, skipping..."
86+
fi
87+
88+
- name: Run type checking
89+
run: |
90+
if [ -f "package.json" ] && grep -q "type-check" package.json; then
91+
npm run type-check
92+
else
93+
echo "No type-check script found, running tsc..."
94+
npx tsc --noEmit
95+
fi
96+
97+
- name: Run unit tests
98+
run: npm run test:unit -- --coverage --watchAll=false
99+
env:
100+
NODE_ENV: test
101+
DATABASE_URL: postgresql://test:test@localhost:5432/nepa_test
102+
103+
- name: Run integration tests
104+
run: npm run test:integration -- --watchAll=false
105+
env:
106+
NODE_ENV: test
107+
DATABASE_URL: postgresql://test:test@localhost:5432/nepa_test
108+
109+
- name: Upload coverage to Codecov
110+
uses: codecov/codecov-action@v3
111+
with:
112+
file: ./coverage/lcov.info
113+
flags: unittests
114+
name: codecov-umbrella
115+
fail_ci_if_error: false
116+
117+
security:
118+
runs-on: ubuntu-latest
119+
steps:
120+
- name: Checkout code
121+
uses: actions/checkout@v4
122+
123+
- name: Setup Node.js
124+
uses: actions/setup-node@v4
125+
with:
126+
node-version: '20.x'
127+
cache: 'npm'
128+
129+
- name: Install dependencies
130+
run: npm ci
131+
132+
- name: Run security audit
133+
run: npm audit --audit-level=moderate
134+
135+
- name: Run dependency check
136+
run: |
137+
if command -v snyk &> /dev/null; then
138+
snyk test --severity-threshold=high
139+
else
140+
echo "Snyk not installed, skipping..."
141+
fi
142+
143+
build:
144+
needs: [test, security]
145+
runs-on: ubuntu-latest
146+
147+
steps:
148+
- name: Checkout code
149+
uses: actions/checkout@v4
150+
151+
- name: Setup Node.js
152+
uses: actions/setup-node@v4
153+
with:
154+
node-version: '20.x'
155+
cache: 'npm'
156+
157+
- name: Install dependencies
158+
run: npm ci
159+
160+
- name: Build application
161+
run: npm run build
162+
163+
- name: Upload build artifacts
164+
uses: actions/upload-artifact@v3
165+
with:
166+
name: build-files
167+
path: dist/
168+
retention-days: 30
169+
170+
deploy-staging:
171+
needs: build
172+
runs-on: ubuntu-latest
173+
if: github.ref == 'refs/heads/develop'
174+
environment: staging
175+
176+
steps:
177+
- name: Checkout code
178+
uses: actions/checkout@v4
179+
180+
- name: Download build artifacts
181+
uses: actions/download-artifact@v3
182+
with:
183+
name: build-files
184+
path: dist/
185+
186+
- name: Deploy to staging
187+
run: |
188+
echo "Deploying to staging environment..."
189+
# Add your staging deployment commands here
190+
# Example: docker build, kubectl apply, etc.
191+
192+
deploy-production:
193+
needs: build
194+
runs-on: ubuntu-latest
195+
if: github.ref == 'refs/heads/main'
196+
environment: production
197+
198+
steps:
199+
- name: Checkout code
200+
uses: actions/checkout@v4
201+
202+
- name: Download build artifacts
203+
uses: actions/download-artifact@v3
204+
with:
205+
name: build-files
206+
path: dist/
207+
208+
- name: Deploy to production
209+
run: |
210+
echo "Deploying to production environment..."
211+
# Add your production deployment commands here
212+
# Example: docker build, kubectl apply, etc.
213+
214+
e2e-tests:
215+
needs: deploy-staging
216+
runs-on: ubuntu-latest
217+
if: github.ref == 'refs/heads/develop'
218+
219+
steps:
220+
- name: Checkout code
221+
uses: actions/checkout@v4
222+
223+
- name: Setup Node.js
224+
uses: actions/setup-node@v4
225+
with:
226+
node-version: '20.x'
227+
cache: 'npm'
228+
229+
- name: Install dependencies
230+
run: npm ci
231+
232+
- name: Install Playwright
233+
run: npx playwright install --with-deps
234+
235+
- name: Run E2E tests
236+
run: npm run test:e2e
237+
env:
238+
BASE_URL: https://staging.nepa.example.com
239+
240+
- name: Upload E2E test results
241+
uses: actions/upload-artifact@v3
242+
if: failure()
243+
with:
244+
name: playwright-report
245+
path: playwright-report/
246+
retention-days: 7

0 commit comments

Comments
 (0)