Skip to content

Open source, composable payments platform | PCI compliant | SaaS and Self-host options | Enables connectivity to multiple payment, payout, fraud, vault and tokenization providers | Uplifts authorization with intelligent routing and revenue recovery | Reduce payment processing costs with cost observability | Reduces payment ops with reconciliation

ci(cypress): pause the optional connector runs, add delay to parallel jobs, run tests on both github and hyperswitch-runners, add retry config for cypress (#11036)

CHALLA NISHANTH BABUd9290fb6d7a7
diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.yml
index 6e576b4031..8bc32f0ba2 100644
--- a/.github/workflows/cypress-tests-runner.yml
+++ b/.github/workflows/cypress-tests-runner.yml
@@ -16,7 +16,7 @@ concurrency:
env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
- PAYMENTS_CONNECTORS: "cybersource stripe"
+ PAYMENTS_CONNECTORS: "stripe cybersource"
OPTIONAL_PAYMENTS_CONNECTORS_BATCH_1: "noon payload nmi"
OPTIONAL_PAYMENTS_CONNECTORS_BATCH_2: "trustpay braintree adyen"
OPTIONAL_PAYMENTS_CONNECTORS_BATCH_3: "nexixpay cryptopay finix"
@@ -97,7 +97,7 @@ jobs:
if: |
github.event_name == 'merge_group' ||
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'S-test-ready'))
- runs-on: hyperswitch-runners
+ runs-on: ubuntu-latest
env:
# Use `sccache` for caching compilation artifacts
RUSTC_WRAPPER: sccache
@@ -149,7 +149,65 @@ jobs:
overwrite: true
path: target/debug/router
retention-days: 1
+
+ build-hyperswitch-runners:
+ name: Build hyperswitch server(hyperswitch-runners)
+ if: |
+ github.event_name == 'merge_group' ||
+ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'S-test-ready'))
+ runs-on: hyperswitch-runners
+ env:
+ # Use `sccache` for caching compilation artifacts
+ RUSTC_WRAPPER: sccache
+ steps:
+ - name: Skip tests for PRs from forks
+ shell: bash
+ if: ${{ env.RUN_TESTS == 'false' }}
+ run: echo 'Skipping tests for PRs from forks'
+ - name: Checkout repository
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: actions/checkout@v5
+
+ - name: Install mold linker
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: rui314/setup-mold@v1
+ with:
+ make-default: true
+
+ - name: Install Rust
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: stable 2 weeks ago
+ components: clippy
+
+ - name: Install Protoc
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: arduino/setup-protoc@v3
+ with:
+ repo-token: ${{ secrets.GITHUB_TOKEN }}
+
+ - name: Install sccache
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: taiki-e/install-action@v2
+ with:
+ tool: sccache
+ checksum: true
+
+ - name: Build project
+ if: ${{ env.RUN_TESTS == 'true' }}
+ run: cargo build --package router --bin router
+
+ - name: Upload binary artifact
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: actions/upload-artifact@v4
+ with:
+ name: hyperswitch-server-hyperswitch-runners
+ overwrite: true
+ path: target/debug/router
+ retention-days: 1
+
runner:
name: Run mandatory Cypress tests
needs: build-hyperswitch
@@ -158,7 +216,7 @@ jobs:
(github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'S-test-ready'))
permissions:
pull-requests: write
- runs-on: hyperswitch-runners
+ runs-on: ubuntu-latest
env:
# Use `sccache` for caching compilation artifacts
RUSTC_WRAPPER: sccache
@@ -330,7 +388,7 @@ jobs:
ROUTER__SERVER__WORKERS: 4
shell: bash -leuo pipefail {0}
run: |
- scripts/execute_cypress.sh --parallel 2
+ scripts/execute_cypress.sh
kill "${{ env.PID }}"
@@ -338,7 +396,7 @@ jobs:
if: env.RUN_TESTS == 'true' && failure()
uses: actions/upload-artifact@v4
with:
- name: cypress-test-results-mandatory
+ name: cypress-test-results-mandatory-github-runners
path: |
cypress-tests/cypress/reports/
retention-days: 1
@@ -350,9 +408,222 @@ jobs:
run: |
gh pr edit ${{ github.event.pull_request.number }} --remove-label "S-test-ready" --repo ${{ github.repository }}
+ runner-hyperswitch-runners:
+ name: Run mandatory Cypress tests (hyperswitch-runners)
+ needs: build-hyperswitch-runners
+ if: |
+ github.event_name == 'merge_group' ||
+ (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'S-test-ready'))
+ permissions:
+ pull-requests: write
+ runs-on: hyperswitch-runners
+ env:
+ # Use `sccache` for caching compilation artifacts
+ RUSTC_WRAPPER: sccache
+
+ services:
+ redis:
+ image: "public.ecr.aws/docker/library/redis:alpine"
+ options: >-
+ --health-cmd "redis-cli ping"
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ ports:
+ - 6379:6379
+ postgres:
+ image: "public.ecr.aws/docker/library/postgres:alpine"
+ env:
+ POSTGRES_USER: db_user
+ POSTGRES_PASSWORD: db_pass
+ POSTGRES_DB: hyperswitch_db
+ options: >-
+ --health-cmd pg_isready
+ --health-interval 10s
+ --health-timeout 5s
+ --health-retries 5
+ ports:
+ - 5432:5432
+
+ steps:
+ - name: Skip tests for PRs from forks
+ if: ${{ env.RUN_TESTS == 'false' }}
+ shell: bash
+ run: echo 'Skipping tests for PRs from forks'
+
+ - name: Checkout repository
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: actions/checkout@v5
+
+ - name: Install Rust
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: stable 2 weeks ago
+ components: rustfmt
+
+ - name: Install sccache
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: taiki-e/install-action@v2
+ with:
+ tool: sccache
+ checksum: true
+
+ - name: Download hyperswitch server artifact
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: actions/download-artifact@v4
+ with:
+ name: hyperswitch-server-hyperswitch-runners
+ path: target/debug
+
+ - name: Make server executable
+ if: ${{ env.RUN_TESTS == 'true' }}
+ run: chmod +x target/debug/router
+
+ - name: Download Encrypted TOML from S3 and Decrypt
+ if: ${{ env.RUN_TESTS == 'true' }}
+ env:
+ AWS_ACCESS_KEY_ID: ${{ secrets.CONNECTOR_CREDS_AWS_ACCESS_KEY_ID }}
+ AWS_REGION: ${{ secrets.CONNECTOR_CREDS_AWS_REGION }}
+ AWS_SECRET_ACCESS_KEY: ${{ secrets.CONNECTOR_CREDS_AWS_SECRET_ACCESS_KEY }}
+ CONNECTOR_AUTH_PASSPHRASE: ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }}
+ CONNECTOR_CREDS_S3_BUCKET_URI: ${{ secrets.CONNECTOR_CREDS_S3_BUCKET_URI}}
+ DESTINATION_FILE_NAME: "creds.json.gpg"
+ S3_SOURCE_FILE_NAME: "f387f657-cac4-4e4f-bb63-e570abcc201f.json.gpg"
+ shell: bash
+ run: |
+ mkdir -p ".github/secrets" ".github/test"
+
+ aws s3 cp "${CONNECTOR_CREDS_S3_BUCKET_URI}/${S3_SOURCE_FILE_NAME}" ".github/secrets/${DESTINATION_FILE_NAME}"
+ gpg --quiet --batch --yes --decrypt --passphrase="${CONNECTOR_AUTH_PASSPHRASE}" --output ".github/test/creds.json" ".github/secrets/${DESTINATION_FILE_NAME}"
+
+ - name: Set paths in env
+ if: ${{ env.RUN_TESTS == 'true' }}
+ shell: bash
+ run: |
+ echo "CYPRESS_CONNECTOR_AUTH_FILE_PATH=${{ github.workspace }}/.github/test/creds.json" >> $GITHUB_ENV
+ echo "SERVER_LOG_PATH=${{ github.workspace }}/server-logs.txt" >> $GITHUB_ENV
+
+ - name: Fetch keys
+ if: ${{ env.RUN_TESTS == 'true' }}
+ env:
+ TOML_PATH: "./config/development.toml"
+ run: |
+ LOCAL_ADMIN_API_KEY=$(yq '.secrets.admin_api_key' ${TOML_PATH})
+ echo "CYPRESS_ADMINAPIKEY=${LOCAL_ADMIN_API_KEY}" >> $GITHUB_ENV
+
+ - name: Install Diesel CLI
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: baptiste0928/[email protected]
+ with:
+ crate: diesel_cli
+ features: postgres
+ args: --no-default-features
+
+ - name: Install Just
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: taiki-e/install-action@v2
+ with:
+ tool: just
+ checksum: true
+
+ - name: Install Node.js
+ if: ${{ env.RUN_TESTS == 'true' }}
+ uses: actions/setup-node@v4
+ with:
+ node-version: "24"
+
+ - name: Install Cypress and dependencies
+ if: ${{ env.RUN_TESTS == 'true' }}
+ run: |
+ npm ci --prefix ./cypress-tests
+
+ - name: Run database migrations
+ if: ${{ env.RUN_TESTS == 'true' }}
+ shell: bash
+ env:
+ DATABASE_URL: postgres://db_user:db_pass@localhost:5432/hyperswitch_db
+ run: just migrate run --locked-schema
+
+ - name: Insert card info into the database
+ if: ${{ env.RUN_TESTS == 'true' }}
+ run: |
+ 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;"
+
+ - name: Insert GSM info into the database
+ if: ${{ env.RUN_TESTS == 'true' }}
+ run: |
+ PGPASSWORD=db_pass psql --host=localhost --port=5432 --username=db_user --dbname=hyperswitch_db --command "\copy gateway_status_map FROM '.github/data/gateway_status_map.csv' DELIMITER ',' CSV HEADER;"
+
+ - name: Setup Local Server
+ if: ${{ env.RUN_TESTS == 'true' }}
+ env:
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC: ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE }}
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_PPC_KEY: ${{ secrets.APPLE_PAY_PAYMENT_PROCESSING_CERTIFICATE_KEY }}
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT: ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE }}
+ ROUTER__APPLEPAY_DECRYPT_KEYS__APPLE_PAY_MERCHANT_CERT_KEY: ${{ secrets.APPLE_PAY_MERCHANT_CERTIFICATE_KEY }}
+ SERVER_LOG_PATH: ${{ github.workspace }}/server-logs.txt
+ run: |
+ touch "${{ env.SERVER_LOG_PATH }}"
+ # Start the server in the background
+
+ target/debug/router >> "${{ env.SERVER_LOG_PATH }}" 2>&1 &
+ SERVER_PID=$!
+ echo "PID=${SERVER_PID}" >> $GITHUB_ENV
+
+ # Wait for the server to start in port 8080
+ COUNT=0
+ while ! nc -z localhost 8080; do
+ if [ $COUNT -gt 12 ]; then # Wait for up to 2 minutes (12 * 10 seconds)
+ echo "Server did not start within a reasonable time. Exiting."
+ kill ${SERVER_PID}
+ exit 1
+ else
+ COUNT=$((COUNT+1))
+ sleep 10
+ fi
+ done
+
+ - name: Run Cypress tests
+ if: ${{ env.RUN_TESTS == 'true' }}
+ env:
+ CYPRESS_BASEURL: "http://localhost:8080"
+ ROUTER__SERVER__WORKERS: 4
+ shell: bash -leuo pipefail {0}
+ run: |
+ scripts/execute_cypress.sh --parallel 2
+
+ kill "${{ env.PID }}"
+
+ - name: Compress and upload server logs on failure
+ if: env.RUN_TESTS == 'true' && failure()
+ run: |
+ if [[ -f "${{ env.SERVER_LOG_PATH }}" ]]; then
+ gzip -9 "${{ env.SERVER_LOG_PATH }}"
+ fi
+
+ - name: Upload server logs on failure
+ if: env.RUN_TESTS == 'true' && failure()
+ uses: actions/upload-artifact@v4
+ with:
+ name: server-logs
+ path: ${{ env.SERVER_LOG_PATH }}.gz
+ if-no-files-found: ignore
+ retention-days: 1
+
+ - name: Upload Cypress test results
+ if: env.RUN_TESTS == 'true' && failure()
+ uses: actions/upload-artifact@v4
+ with:
+ name: cypress-test-results-mandatory-hyperswitch-runners
+ path: |
+ cypress-tests/cypress/reports/
+ retention-days: 1
+
+ # Optional connectors are paused currently because of shortage of hyperswitch runners for the PRs.
prepare-matrix:
name: Prepare Optional Connectors matrix to run cypress tests
- if: ${{ github.event_name == 'merge_group' }}
+ if: false
runs-on: hyperswitch-runners
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
@@ -420,7 +691,7 @@ jobs:
runner-optional-connectors:
name: Run Optional Connectors Cypress tests
- if: ${{ github.event_name == 'merge_group' }}
+ if: false
needs: [ build-hyperswitch, prepare-matrix ]
runs-on: hyperswitch-runners
strategy:
@@ -636,7 +907,7 @@ jobs:
if: ${{ env.RUN_TESTS == 'true' }}
uses: actions/download-artifact@v4
with:
- name: hyperswitch-server
+ name: hyperswitch-server-hyperswitch-runners
path: target/debug
- name: Make server executable
@@ -799,9 +1070,7 @@ jobs:
runner_v2:
name: Run Cypress tests on v2 and generate coverage report
- if: |
- github.event_name == 'merge_group' ||
- (github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'S-test-ready'))
+ if: github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'S-test-ready')
runs-on: hyperswitch-runners
permissions:
pull-requests: write
diff --git a/cypress-tests/cypress.config.js b/cypress-tests/cypress.config.js
index bc7aab5ad5..1c80ca3f51 100644
--- a/cypress-tests/cypress.config.js
+++ b/cypress-tests/cypress.config.js
@@ -61,6 +61,7 @@ export default defineConfig({
return config;
},
experimentalRunAllSpecs: true,
+ retries: 2,
specPattern: "cypress/e2e/**/*.cy.{js,jsx,ts,tsx}",
supportFile: "cypress/support/e2e.js",
diff --git a/scripts/execute_cypress.sh b/scripts/execute_cypress.sh
index f8099652a4..72544e6546 100755
--- a/scripts/execute_cypress.sh
+++ b/scripts/execute_cypress.sh
@@ -176,6 +176,7 @@ run_tests() {
print_color yellow " Starting Parallel Execution for '$service' (Jobs: $jobs)"
parallel --jobs "$jobs" \
+ --delay 10 \
--group \
--joblog "$job_log" \
execute_test {} "$service" "$tmp_file" {%} \