forked from llinsss/payCrypt_v2
-
Notifications
You must be signed in to change notification settings - Fork 0
187 lines (164 loc) · 5.2 KB
/
Copy pathbackend-tests.yml
File metadata and controls
187 lines (164 loc) · 5.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
name: Backend Tests
on:
push:
branches: [main, develop, 'fix/**']
paths:
- 'backend/**'
- '.github/workflows/backend-tests.yml'
pull_request:
branches: [main, develop]
paths:
- 'backend/**'
jobs:
unit-tests:
name: Unit Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x, 20.x]
steps:
- uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'backend/package-lock.json'
- name: Install dependencies
working-directory: backend
run: npm ci
- name: Run unit tests
working-directory: backend
run: npm run test:unit
continue-on-error: false
- name: Upload unit test results
if: always()
uses: actions/upload-artifact@v3
with:
name: unit-test-results-${{ matrix.node-version }}
path: backend/test-results/
retention-days: 30
integration-tests:
name: Integration Tests
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
services:
postgres:
image: postgres:14
env:
POSTGRES_DB: paycrypt_test
POSTGRES_USER: taggedpay_user
POSTGRES_PASSWORD: taggedpay_password
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
redis:
image: redis:7-alpine
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v3
- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
cache-dependency-path: 'backend/package-lock.json'
- name: Install dependencies
working-directory: backend
run: npm ci
- name: Wait for PostgreSQL
run: |
until pg_isready -h localhost -p 5432 -U taggedpay_user; do
echo "Waiting for PostgreSQL..."
sleep 1
done
- name: Run database migrations
working-directory: backend
env:
DATABASE_URL: postgres://taggedpay_user:taggedpay_password@localhost:5432/paycrypt_test
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: paycrypt_test
DB_USER: taggedpay_user
DB_PASSWORD: taggedpay_password
REDIS_URL: redis://localhost:6379
run: npm run migrate
- name: Run integration tests
working-directory: backend
env:
DATABASE_URL: postgres://taggedpay_user:taggedpay_password@localhost:5432/paycrypt_test
DB_HOST: localhost
DB_PORT: 5432
DB_NAME: paycrypt_test
DB_USER: taggedpay_user
DB_PASSWORD: taggedpay_password
REDIS_URL: redis://localhost:6379
run: npm run test:integration
continue-on-error: false
- name: Upload integration test results
if: always()
uses: actions/upload-artifact@v3
with:
name: integration-test-results-${{ matrix.node-version }}
path: backend/test-results/
retention-days: 30
test-summary:
name: Test Summary
runs-on: ubuntu-latest
needs: [unit-tests, integration-tests]
if: always()
steps:
- name: Download all test results
uses: actions/download-artifact@v3
with:
path: test-results
- name: Publish test results
run: |
echo "## Backend Test Results" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Unit Tests" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Passed (see artifacts)" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Integration Tests" >> $GITHUB_STEP_SUMMARY
echo "- ✅ Passed (see artifacts)" >> $GITHUB_STEP_SUMMARY
nested-projects:
name: Nested Project Tests (Stellar, Multi-Chain)
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [18.x]
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- name: Install Stellar Horizon backend dependencies
working-directory: backend/Real-Time Stellar Horizon/backend
run: npm ci
continue-on-error: true
- name: Run Stellar Horizon tests
working-directory: backend/Real-Time Stellar Horizon/backend
run: npm test
continue-on-error: true
- name: Install Multi-Chain backend dependencies
working-directory: backend/Multi-Chain Transaction/backend
run: npm ci
continue-on-error: true
- name: Run Multi-Chain tests
working-directory: backend/Multi-Chain Transaction/backend
run: npm test
continue-on-error: true