14
14
CARGO_INCREMENTAL : 0
15
15
CARGO_NET_RETRY : 10
16
16
PAYMENTS_CONNECTORS : " cybersource stripe"
17
+ ALPHA_PAYMENTS_CONNECTORS : " silverflow"
17
18
RUST_BACKTRACE : short
18
19
RUSTUP_MAX_RETRIES : 10
19
20
RUN_TESTS : ${{ ((github.event_name == 'pull_request') && (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name)) || (github.event_name == 'merge_group')}}
80
81
git push
81
82
fi
82
83
84
+ build-hyperswitch :
85
+ name : Build hyperswitch server
86
+ runs-on : ubuntu-latest
87
+ steps :
88
+ - name : Skip tests for PRs from forks
89
+ shell : bash
90
+ if : ${{ env.RUN_TESTS == 'false' }}
91
+ run : echo 'Skipping tests for PRs from forks'
92
+
93
+ - name : Checkout repository
94
+ if : ${{ env.RUN_TESTS == 'true' }}
95
+ uses : actions/checkout@v4
96
+
97
+ - name : Install mold linker
98
+ if : ${{ env.RUN_TESTS == 'true' }}
99
+ uses : rui314/setup-mold@v1
100
+ with :
101
+ make-default : true
102
+
103
+ - name : Install Rust
104
+ if : ${{ env.RUN_TESTS == 'true' }}
105
+ uses : dtolnay/rust-toolchain@master
106
+ with :
107
+ toolchain : stable 2 weeks ago
108
+ components : clippy
109
+
110
+ - name : Install Protoc
111
+ if : ${{ env.RUN_TESTS == 'true' }}
112
+ uses : arduino/setup-protoc@v3
113
+ with :
114
+ repo-token : ${{ secrets.GITHUB_TOKEN }}
115
+
116
+ - name : Install sccache
117
+ if : ${{ env.RUN_TESTS == 'true' }}
118
+ uses : taiki-e/install-action@v2
119
+ with :
120
+ tool : sccache
121
+ checksum : true
122
+
123
+ - name : Build project
124
+ if : ${{ env.RUN_TESTS == 'true' }}
125
+ run : cargo build --package router --bin router --jobs 3
126
+
127
+ - name : Upload binary artifact
128
+ if : ${{ env.RUN_TESTS == 'true' }}
129
+ uses : actions/upload-artifact@v4
130
+ with :
131
+ name : hyperswitch-server
132
+ overwrite : true
133
+ path : target/debug/router
134
+ retention-days : 1
135
+
83
136
runner :
84
- name : Run Cypress tests
137
+ name : Run mandatory Cypress tests
138
+ needs : build-hyperswitch
85
139
runs-on : ubuntu-latest
86
140
87
141
services :
@@ -110,14 +164,25 @@ jobs:
110
164
111
165
steps :
112
166
- name : Skip tests for PRs from forks
113
- shell : bash
114
167
if : ${{ env.RUN_TESTS == 'false' }}
168
+ shell : bash
115
169
run : echo 'Skipping tests for PRs from forks'
116
170
117
171
- name : Checkout repository
118
172
if : ${{ env.RUN_TESTS == 'true' }}
119
173
uses : actions/checkout@v4
120
174
175
+ - name : Download hyperswitch server artifact
176
+ if : ${{ env.RUN_TESTS == 'true' }}
177
+ uses : actions/download-artifact@v4
178
+ with :
179
+ name : hyperswitch-server
180
+ path : target/debug
181
+
182
+ - name : Make server executable
183
+ if : ${{ env.RUN_TESTS == 'true' }}
184
+ run : chmod +x target/debug/router
185
+
121
186
- name : Download Encrypted TOML from S3 and Decrypt
122
187
if : ${{ env.RUN_TESTS == 'true' }}
123
188
env :
@@ -127,7 +192,7 @@ jobs:
127
192
CONNECTOR_AUTH_PASSPHRASE : ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }}
128
193
CONNECTOR_CREDS_S3_BUCKET_URI : ${{ secrets.CONNECTOR_CREDS_S3_BUCKET_URI}}
129
194
DESTINATION_FILE_NAME : " creds.json.gpg"
130
- S3_SOURCE_FILE_NAME : " fa1c07a5-f9c8-4e90-b9c7-b90cb8263015 .json.gpg"
195
+ S3_SOURCE_FILE_NAME : " 6859bf7e-735b-4589-979a-ac057ed50425 .json.gpg"
131
196
shell : bash
132
197
run : |
133
198
mkdir -p ".github/secrets" ".github/test"
@@ -149,30 +214,171 @@ jobs:
149
214
LOCAL_ADMIN_API_KEY=$(yq '.secrets.admin_api_key' ${TOML_PATH})
150
215
echo "CYPRESS_ADMINAPIKEY=${LOCAL_ADMIN_API_KEY}" >> $GITHUB_ENV
151
216
152
- - name : Install mold linker
153
- if : ${{ runner.os == 'Linux' && env.RUN_TESTS == 'true' }}
154
- uses : rui314/setup-mold@v1
217
+ - name : Install Diesel CLI
218
+ if : ${{ env.RUN_TESTS == 'true' }}
219
+ uses :
baptiste0928/[email protected]
155
220
with :
156
- make-default : true
221
+ crate : diesel_cli
222
+ features : postgres
223
+ args : --no-default-features
157
224
158
- - name : Install Rust
225
+ - name : Install Just
159
226
if : ${{ env.RUN_TESTS == 'true' }}
160
- uses : dtolnay/rust-toolchain@master
227
+ uses : taiki-e/install-action@v2
161
228
with :
162
- toolchain : stable 2 weeks ago
163
- components : clippy
229
+ tool : just
230
+ checksum : true
164
231
165
- - name : Install Protoc
166
- uses : arduino/setup-protoc@v3
232
+ - name : Install Node.js
233
+ if : ${{ env.RUN_TESTS == 'true' }}
234
+ uses : actions/setup-node@v4
167
235
with :
168
- repo-token : ${{ secrets.GITHUB_TOKEN }}
236
+ node-version : " 20 "
169
237
170
- - name : Install sccache
238
+ - name : Install Cypress and dependencies
171
239
if : ${{ env.RUN_TESTS == 'true' }}
172
- uses : taiki-e/install-action@v2
240
+ run : |
241
+ npm ci --prefix ./cypress-tests
242
+
243
+ - name : Run database migrations
244
+ if : ${{ env.RUN_TESTS == 'true' }}
245
+ shell : bash
246
+ env :
247
+ DATABASE_URL : postgres://db_user:db_pass@localhost:5432/hyperswitch_db
248
+ run : just migrate run --locked-schema
249
+
250
+ - name : Insert card info into the database
251
+ if : ${{ env.RUN_TESTS == 'true' }}
252
+ run : |
253
+ PGPASSWORD=db_pass psql --host=localhost --port=5432 --username=db_user --dbname=hyperswitch_db --command "\copy cards_info FROM '.github/data/cards_info.csv' DELIMITER ',' CSV HEADER;"
254
+
255
+ - name : Setup Local Server
256
+ if : ${{ env.RUN_TESTS == 'true' }}
257
+ env :
258
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC : ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE }}
259
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC_KEY : ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE_KEY }}
260
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT : ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE }}
261
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT_KEY : ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE_KEY }}
262
+ run : |
263
+ # Start the server in the background
264
+ target/debug/router &
265
+
266
+ SERVER_PID=$!
267
+ echo "PID=${SERVER_PID}" >> $GITHUB_ENV
268
+
269
+ # Wait for the server to start in port 8080
270
+ COUNT=0
271
+ while ! nc -z localhost 8080; do
272
+ if [ $COUNT -gt 12 ]; then # Wait for up to 2 minutes (12 * 10 seconds)
273
+ echo "Server did not start within a reasonable time. Exiting."
274
+ kill ${SERVER_PID}
275
+ exit 1
276
+ else
277
+ COUNT=$((COUNT+1))
278
+ sleep 10
279
+ fi
280
+ done
281
+
282
+ - name : Run Cypress tests
283
+ if : ${{ env.RUN_TESTS == 'true' }}
284
+ env :
285
+ CYPRESS_BASEURL : " http://localhost:8080"
286
+ ROUTER__SERVER__WORKERS : 4
287
+ shell : bash -leuo pipefail {0}
288
+ run : |
289
+ scripts/execute_cypress.sh
290
+
291
+ kill "${{ env.PID }}"
292
+
293
+ - name : Upload Cypress test results
294
+ if : env.RUN_TESTS == 'true' && failure()
295
+ uses : actions/upload-artifact@v4
173
296
with :
174
- tool : sccache
175
- checksum : true
297
+ name : cypress-test-results
298
+ path : |
299
+ cypress-tests/cypress/reports/
300
+ retention-days : 1
301
+
302
+ runner_alpha :
303
+ name : Run optional Cypress tests for alpha connectors
304
+ needs : build-hyperswitch
305
+ runs-on : ubuntu-latest
306
+
307
+ services :
308
+ redis :
309
+ image : " public.ecr.aws/docker/library/redis:alpine"
310
+ options : >-
311
+ --health-cmd "redis-cli ping"
312
+ --health-interval 10s
313
+ --health-timeout 5s
314
+ --health-retries 5
315
+ ports :
316
+ - 6379:6379
317
+ postgres :
318
+ image : " public.ecr.aws/docker/library/postgres:alpine"
319
+ env :
320
+ POSTGRES_USER : db_user
321
+ POSTGRES_PASSWORD : db_pass
322
+ POSTGRES_DB : hyperswitch_db
323
+ options : >-
324
+ --health-cmd pg_isready
325
+ --health-interval 10s
326
+ --health-timeout 5s
327
+ --health-retries 5
328
+ ports :
329
+ - 5432:5432
330
+
331
+ steps :
332
+ - name : Skip tests for PRs from forks
333
+ if : ${{ env.RUN_TESTS == 'false' }}
334
+ shell : bash
335
+ run : echo 'Skipping tests for PRs from forks'
336
+
337
+ - name : Checkout repository
338
+ if : ${{ env.RUN_TESTS == 'true' }}
339
+ uses : actions/checkout@v4
340
+
341
+ - name : Download hyperswitch server artifact
342
+ if : ${{ env.RUN_TESTS == 'true' }}
343
+ uses : actions/download-artifact@v4
344
+ with :
345
+ name : hyperswitch-server
346
+ path : target/debug
347
+
348
+ - name : Make server executable
349
+ if : ${{ env.RUN_TESTS == 'true' }}
350
+ run : chmod +x target/debug/router
351
+
352
+ - name : Download Encrypted JSON from S3 and Decrypt
353
+ if : ${{ env.RUN_TESTS == 'true' }}
354
+ env :
355
+ AWS_ACCESS_KEY_ID : ${{ secrets.CONNECTOR_CREDS_AWS_ACCESS_KEY_ID }}
356
+ AWS_REGION : ${{ secrets.CONNECTOR_CREDS_AWS_REGION }}
357
+ AWS_SECRET_ACCESS_KEY : ${{ secrets.CONNECTOR_CREDS_AWS_SECRET_ACCESS_KEY }}
358
+ CONNECTOR_AUTH_PASSPHRASE : ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }}
359
+ CONNECTOR_CREDS_S3_BUCKET_URI : ${{ secrets.CONNECTOR_CREDS_S3_BUCKET_URI}}
360
+ DESTINATION_FILE_NAME : " creds.json.gpg"
361
+ S3_SOURCE_FILE_NAME : " 6859bf7e-735b-4589-979a-ac057ed50425.json.gpg"
362
+ shell : bash
363
+ run : |
364
+ mkdir -p ".github/secrets" ".github/test"
365
+
366
+ aws s3 cp "${CONNECTOR_CREDS_S3_BUCKET_URI}/${S3_SOURCE_FILE_NAME}" ".github/secrets/${DESTINATION_FILE_NAME}"
367
+ gpg --quiet --batch --yes --decrypt --passphrase="${CONNECTOR_AUTH_PASSPHRASE}" --output ".github/test/creds.json" ".github/secrets/${DESTINATION_FILE_NAME}"
368
+
369
+ - name : Set paths in env
370
+ if : ${{ env.RUN_TESTS == 'true' }}
371
+ shell : bash
372
+ run : |
373
+ echo "CYPRESS_CONNECTOR_AUTH_FILE_PATH=${{ github.workspace }}/.github/test/creds.json" >> $GITHUB_ENV
374
+
375
+ - name : Fetch keys
376
+ if : ${{ env.RUN_TESTS == 'true' }}
377
+ env :
378
+ TOML_PATH : " ./config/development.toml"
379
+ run : |
380
+ LOCAL_ADMIN_API_KEY=$(yq '.secrets.admin_api_key' ${TOML_PATH})
381
+ echo "CYPRESS_ADMINAPIKEY=${LOCAL_ADMIN_API_KEY}" >> $GITHUB_ENV
176
382
177
383
- name : Install Diesel CLI
178
384
if : ${{ env.RUN_TESTS == 'true' }}
@@ -212,18 +418,52 @@ jobs:
212
418
run : |
213
419
PGPASSWORD=db_pass psql --host=localhost --port=5432 --username=db_user --dbname=hyperswitch_db --command "\copy cards_info FROM '.github/data/cards_info.csv' DELIMITER ',' CSV HEADER;"
214
420
215
- - name : Build project
421
+ - name : Start mock servers for alpha connectors
216
422
if : ${{ env.RUN_TESTS == 'true' }}
217
- run : cargo build --package router --bin router --jobs 3
423
+ run : |
424
+ # Start mock servers for each alpha connector
425
+ for connector in ${{ env.ALPHA_PAYMENTS_CONNECTORS }}; do
426
+ pascal_case_connector="$(echo "$connector" | sed -E 's/(^|_)([a-z])/\U\2/g')"
427
+ if [ -f "cypress-tests/cypress/e2e/configs/mock-server/${pascal_case_connector}.js" ]; then
428
+ echo "Starting mock server for ${connector}"
429
+ cd cypress-tests
430
+
431
+ node "cypress/e2e/configs/mock-server/${pascal_case_connector}.js" &
432
+
433
+ MOCK_PID=$!
434
+ echo "MOCK_${connector^^}_PID=${MOCK_PID}" >> $GITHUB_ENV
435
+ cd ..
436
+
437
+ # Wait for mock server to be ready
438
+ COUNT=0
439
+ while ! nc -z localhost 3010; do
440
+ if [ $COUNT -gt 6 ]; then # Wait for up to 1 minute (6 * 10 seconds)
441
+ echo "Mock server for ${connector} did not start within a reasonable time."
442
+ exit 1
443
+ else
444
+ COUNT=$((COUNT+1))
445
+ sleep 10
446
+ fi
447
+ done
448
+ echo "Mock server for ${connector} is ready"
449
+ fi
450
+ done
218
451
219
- - name : Setup Local Server
452
+ - name : Setup Local Server with Alpha Connector Configs
220
453
if : ${{ env.RUN_TESTS == 'true' }}
221
454
env :
222
455
ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC : ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE }}
223
456
ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC_KEY : ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE_KEY }}
224
457
ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT : ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE }}
225
458
ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT_KEY : ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE_KEY }}
226
459
run : |
460
+ # Set base URLs for alpha connectors to point to mock servers
461
+ for connector in ${{ env.ALPHA_PAYMENTS_CONNECTORS }}; do
462
+ CONNECTOR_ENV_VAR="ROUTER__CONNECTORS__$(echo ${connector} | tr '[:lower:]' '[:upper:]')__BASE_URL"
463
+ export ${CONNECTOR_ENV_VAR}="http://localhost:3010"
464
+ echo "${CONNECTOR_ENV_VAR}=http://localhost:3010" >> $GITHUB_ENV
465
+ done
466
+
227
467
# Start the server in the background
228
468
target/debug/router &
229
469
@@ -243,22 +483,33 @@ jobs:
243
483
fi
244
484
done
245
485
246
- - name : Run Cypress tests
486
+ - name : Run Cypress tests for Alpha Connectors
247
487
if : ${{ env.RUN_TESTS == 'true' }}
248
488
env :
249
489
CYPRESS_BASEURL : " http://localhost:8080"
250
490
ROUTER__SERVER__WORKERS : 4
491
+ PAYMENTS_CONNECTORS : ${{ env.ALPHA_PAYMENTS_CONNECTORS }}
251
492
shell : bash -leuo pipefail {0}
252
493
run : |
494
+ # Run tests for alpha connectors
253
495
scripts/execute_cypress.sh
254
496
497
+ # Cleanup
255
498
kill "${{ env.PID }}"
256
499
257
- - name : Upload Cypress test results
500
+ # Kill mock servers
501
+ for connector in ${{ env.ALPHA_PAYMENTS_CONNECTORS }}; do
502
+ VAR_NAME="MOCK_${connector^^}_PID"
503
+ if [ -n "${!VAR_NAME:-}" ]; then
504
+ kill "${!VAR_NAME}" || true
505
+ fi
506
+ done
507
+
508
+ - name : Upload Cypress test results for Alpha Connectors
258
509
if : env.RUN_TESTS == 'true' && failure()
259
510
uses : actions/upload-artifact@v4
260
511
with :
261
- name : cypress-test-results
512
+ name : cypress-test-results-alpha
262
513
path : |
263
514
cypress-tests/cypress/reports/
264
515
retention-days : 1
@@ -312,7 +563,7 @@ jobs:
312
563
CONNECTOR_AUTH_PASSPHRASE : ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }}
313
564
CONNECTOR_CREDS_S3_BUCKET_URI : ${{ secrets.CONNECTOR_CREDS_S3_BUCKET_URI}}
314
565
DESTINATION_FILE_NAME : " creds.json.gpg"
315
- S3_SOURCE_FILE_NAME : " aa328308-b34e-41b7-a590-4fe45cfe7991 .json.gpg"
566
+ S3_SOURCE_FILE_NAME : " 6859bf7e-735b-4589-979a-ac057ed50425 .json.gpg"
316
567
shell : bash
317
568
run : |
318
569
mkdir -p ".github/secrets" ".github/test"
0 commit comments