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): Increase the number of connectors that cypress tests are being run on while merging and run them in parallel (#10662)

CHALLA NISHANTH BABU2066639deccf
diff --git a/.github/workflows/cypress-tests-runner.yml b/.github/workflows/cypress-tests-runner.yml
index 8d68288d5c..a63dfbbc7e 100644
--- a/.github/workflows/cypress-tests-runner.yml
+++ b/.github/workflows/cypress-tests-runner.yml
@@ -6,6 +6,9 @@ on:
- checks_requested
pull_request:
+permissions:
+ contents: read
+
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
@@ -14,6 +17,14 @@ env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
PAYMENTS_CONNECTORS: "cybersource stripe"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_1: "noon payload nmi"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_2: "trustpay braintree adyen"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_3: "nexixpay cryptopay finix"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_4: "iatapay cashtocode peachpayments"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_5: "worldpayxml checkout mollie"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_6: "fiuu worldpay zift"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_7: "aiwallex novalnet redsys"
+ OPTIONAL_PAYMENTS_CONNECTORS_BATCH_8: "paypal nuvei"
ALPHA_PAYMENTS_CONNECTORS: "celero silverflow"
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
@@ -37,7 +48,7 @@ jobs:
- name: Checkout repository with token
if: ${{ github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name }}
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
with:
fetch-depth: 0
ref: ${{ github.event.pull_request.head.ref }}
@@ -45,7 +56,7 @@ jobs:
- name: Checkout repository for fork
if: ${{ github.event.pull_request.head.repo.full_name != github.event.pull_request.base.repo.full_name }}
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
- name: Install Node.js
uses: actions/setup-node@v4
@@ -83,7 +94,10 @@ jobs:
build-hyperswitch:
name: Build hyperswitch server
- runs-on: ubuntu-latest
+ runs-on: hyperswitch-runners
+ env:
+ # Use `sccache` for caching compilation artifacts
+ RUSTC_WRAPPER: sccache
steps:
- name: Skip tests for PRs from forks
shell: bash
@@ -92,7 +106,7 @@ jobs:
- name: Checkout repository
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
- name: Install mold linker
if: ${{ env.RUN_TESTS == 'true' }}
@@ -136,7 +150,10 @@ jobs:
runner:
name: Run mandatory Cypress tests
needs: build-hyperswitch
- runs-on: ubuntu-latest
+ runs-on: hyperswitch-runners
+ env:
+ # Use `sccache` for caching compilation artifacts
+ RUSTC_WRAPPER: sccache
services:
redis:
@@ -170,7 +187,21 @@ jobs:
- name: Checkout repository
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/checkout@v4
+ 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' }}
@@ -291,7 +322,7 @@ jobs:
ROUTER__SERVER__WORKERS: 4
shell: bash -leuo pipefail {0}
run: |
- scripts/execute_cypress.sh
+ scripts/execute_cypress.sh --parallel 2
kill "${{ env.PID }}"
@@ -299,7 +330,246 @@ jobs:
if: env.RUN_TESTS == 'true' && failure()
uses: actions/upload-artifact@v4
with:
- name: cypress-test-results
+ name: cypress-test-results-mandatory
+ path: |
+ cypress-tests/cypress/reports/
+ retention-days: 1
+
+ prepare-matrix:
+ name: Prepare Optional Connectors matrix to run cypress tests
+ if: ${{ github.event_name == 'merge_group' }}
+ runs-on: hyperswitch-runners
+ outputs:
+ matrix: ${{ steps.set-matrix.outputs.matrix }}
+ steps:
+ - name : Set matrix for optional connectors batches
+ id: set-matrix
+ shell: bash
+ run: |
+ {
+ echo "matrix<<EOF"
+ echo '{
+ "batch": [
+ {
+ "name": "batch-1",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_1}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-1"
+ },
+ {
+ "name": "batch-2",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_2}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-2"
+ },
+ {
+ "name": "batch-3",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_3}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-3"
+ },
+ {
+ "name": "batch-4",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_4}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-4"
+ },
+ {
+ "name": "batch-5",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_5}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-5"
+ },
+ {
+ "name": "batch-6",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_6}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-6"
+ },
+ {
+ "name": "batch-7",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_7}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-7"
+ },
+ {
+ "name": "batch-8",
+ "connectors": "'"${OPTIONAL_PAYMENTS_CONNECTORS_BATCH_8}"'",
+ "parallel": 3,
+ "report_artifact_name": "cypress-test-results-batch-8"
+ }
+ ]
+ }'
+ echo "EOF"
+ } >> "$GITHUB_OUTPUT"
+
+ runner-optional-connectors:
+ name: Run Optional Connectors Cypress tests
+ if: ${{ github.event_name == 'merge_group' }}
+ needs: [ build-hyperswitch, prepare-matrix ]
+ runs-on: hyperswitch-runners
+ strategy:
+ fail-fast: false
+ matrix: ${{ fromJson(needs.prepare-matrix.outputs.matrix) }}
+ 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: Checkout repository
+ uses: actions/checkout@v5
+
+ - name: Install Rust
+ uses: dtolnay/rust-toolchain@master
+ with:
+ toolchain: stable 2 weeks ago
+ components: rustfmt
+
+ - name: Install sccache
+ uses: taiki-e/install-action@v2
+ with:
+ tool: sccache
+ checksum: true
+
+ - name: Download hyperswitch server artifact
+ uses: actions/download-artifact@v4
+ with:
+ name: hyperswitch-server
+ path: target/debug
+
+ - name: Make server executable
+ run: chmod +x target/debug/router
+
+ - name: Download Encrypted TOML from S3 and Decrypt
+ 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: "1b5c7aa1-8a73-4137-aa55-766cc50849f6.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
+ shell: bash
+ run: |
+ echo "CYPRESS_CONNECTOR_AUTH_FILE_PATH=${{ github.workspace }}/.github/test/creds.json" >> $GITHUB_ENV
+
+ - name: Fetch keys
+ 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
+ uses: baptiste0928/[email protected]
+ with:
+ crate: diesel_cli
+ features: postgres
+ args: --no-default-features
+
+ - name: Install Just
+ uses: taiki-e/install-action@v2
+ with:
+ tool: just
+ checksum: true
+
+ - name: Install Node.js
+ uses: actions/setup-node@v4
+ with:
+ node-version: "24"
+
+ - name: Install Cypress and dependencies
+ run: |
+ npm ci --prefix ./cypress-tests
+
+ - name: Run database migrations
+ 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
+ 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
+ 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
+ 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 }}
+ run: |
+ # Start the server in the background
+ target/debug/router &
+
+ 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
+ env:
+ CYPRESS_BASEURL: "http://localhost:8080"
+ ROUTER__SERVER__WORKERS: 4
+ PAYMENTS_CONNECTORS: "${{ matrix.batch.connectors }}"
+ shell: bash -leuo pipefail {0}
+ run: |
+ scripts/execute_cypress.sh --parallel ${{ matrix.batch.parallel }}
+
+ kill "${{ env.PID }}"
+
+ - name: Upload Cypress test results
+ if: failure()
+ uses: actions/upload-artifact@v4
+ with:
+ name: ${{ matrix.batch.report_artifact_name }}
path: |
cypress-tests/cypress/reports/
retention-days: 1
@@ -307,8 +577,10 @@ jobs:
runner_alpha:
name: Run optional Cypress tests for alpha connectors
needs: build-hyperswitch
- runs-on: ubuntu-latest
-
+ runs-on: hyperswitch-runners
+ env:
+ # Use `sccache` for caching compilation artifacts
+ RUSTC_WRAPPER: sccache
services:
redis:
image: "public.ecr.aws/docker/library/redis:alpine"
@@ -341,7 +613,7 @@ jobs:
- name: Checkout repository
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
- name: Download hyperswitch server artifact
if: ${{ env.RUN_TESTS == 'true' }}
@@ -367,6 +639,20 @@ jobs:
run: |
LOCAL_ADMIN_API_KEY=$(yq '.secrets.admin_api_key' ${TOML_PATH})
echo "CYPRESS_ADMINAPIKEY=${LOCAL_ADMIN_API_KEY}" >> $GITHUB_ENV
+
+ - 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: Install Diesel CLI
if: ${{ env.RUN_TESTS == 'true' }}
@@ -497,6 +783,8 @@ jobs:
runner_v2:
name: Run Cypress tests on v2 and generate coverage report
runs-on: hyperswitch-runners
+ permissions:
+ contents: read
env:
CODECOV_FILE: "lcov.info"
# Use `sccache` for caching compilation artifacts
@@ -534,7 +822,7 @@ jobs:
- name: Checkout repository
if: ${{ env.RUN_TESTS == 'true' }}
- uses: actions/checkout@v4
+ uses: actions/checkout@v5
- name: Download Encrypted TOML from S3 and Decrypt
if: ${{ env.RUN_TESTS == 'true' }}
@@ -578,7 +866,7 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable 2 weeks ago
- components: llvm-tools-preview, rustfmt
+ components: rustfmt
- name: Install Protoc
if: ${{ env.RUN_TESTS == 'true' }}
diff --git a/scripts/execute_cypress.sh b/scripts/execute_cypress.sh
index 8d93519b46..f8099652a4 100755
--- a/scripts/execute_cypress.sh
+++ b/scripts/execute_cypress.sh
@@ -1,189 +1,247 @@
-#! /usr/bin/env bash
-
+#!/usr/bin/env bash
set -euo pipefail
-# Initialize tmp_file globally
-tmp_file=""
-
-# Define arrays for services, etc.
-# Read service arrays from environment variables
-read -r -a payments <<< "${PAYMENTS_CONNECTORS[@]:-}"
-read -r -a payouts <<< "${PAYOUTS_CONNECTORS[@]:-}"
-read -r -a payment_method_list <<< "${PAYMENT_METHOD_LIST[@]:-}"
-read -r -a routing <<< "${ROUTING[@]:-}"
-
-# Define arrays
-connector_map=()
-failed_connectors=()
-
-# Define an associative array to map environment variables to service names
-declare -A services=(
- ["PAYMENTS_CONNECTORS"]="payments"
- ["PAYOUTS_CONNECTORS"]="payouts"
- ["PAYMENT_METHOD_LIST"]="payment_method_list"
- ["ROUTING"]="routing"
-)
-
-# Function to print messages in color
-function print_color() {
- # Input params
- local color="$1"
- local message="$2"
+# -----------------------------
+# Global Variables & Cleanup
+# -----------------------------
+tmp_file=$(mktemp) # failure-only (legacy)
+job_log=$(mktemp) # GNU parallel job log
+results_log=$(mktemp) # unified results: service:connector:status:duration
+
+cleanup() {
+ local exit_code=$?
+ [[ -f "$tmp_file" ]] && rm -f "$tmp_file"
+ [[ -f "$job_log" ]] && rm -f "$job_log"
+ [[ -f "$results_log" ]] && rm -f "$results_log"
+
+ # Kill any stray Xvfb processes owned by this script
+ pkill -P $$ Xvfb 2>/dev/null || true
+ exit "$exit_code"
+}
+trap cleanup EXIT
- # Define colors
+# -----------------------------
+# Helper Functions
+# -----------------------------
+print_color() {
+ local color_name="$1"
+ local message="$2"
local reset='\033[0m'
local red='\033[0;31m'
local green='\033[0;32m'
local yellow='\033[0;33m'
-
- # Use indirect reference to get the color value
- echo -e "${!color}${message}${reset}"
+ local blue='\033[0;34m'
+
+ case "$color_name" in
+ red) echo -e "${red}${message}${reset}" ;;
+ green) echo -e "${green}${message}${reset}" ;;
+ yellow) echo -e "${yellow}${message}${reset}" ;;
+ blue) echo -e "${blue}${message}${reset}" ;;
+ *) echo -e "${message}" ;;
+ esac
}
export -f print_color
-# Function to check if a command exists
-function command_exists() {
- command -v "$1" > /dev/null 2>&1
+command_exists() {
+ command -v "$1" >/dev/null 2>&1
}
-# Function to read service arrays from environment variables
-function read_service_arrays() {
- # Loop through the associative array and check if each service is exported
- for var in "${!services[@]}"; do
- if [[ -n "${!var+x}" ]]; then
- connector_map+=("${services[$var]}")
- else
- print_color "yellow" "Environment variable ${var} is not set. Skipping..."
+# -----------------------------
+# Dependency Check
+# -----------------------------
+check_dependencies() {
+ local dependencies=("parallel" "npm")
+ for cmd in "${dependencies[@]}"; do
+ if ! command_exists "$cmd"; then
+ print_color red "ERROR: ${cmd} is not installed!"
+ exit 1
fi
done
-}
-# Function to execute Cypress tests
-function execute_test() {
- if [[ $# -lt 3 ]]; then
- print_color "red" "ERROR: Insufficient arguments provided to execute_test."
- exit 1
+ if [[ ! -d "node_modules" ]]; then
+ print_color yellow "Installing NPM dependencies..."
+ npm ci
fi
+ print_color blue "Verifying Cypress binary..."
+ if command_exists "xvfb-run"; then
+ xvfb-run --auto-servernum npm exec cypress verify
+ else
+ export DISPLAY=:99
+ Xvfb :99 &
+ local xvfb_pid=$!
+ npm exec cypress verify
+ kill "$xvfb_pid" 2>/dev/null || true
+ fi
+ print_color green "Cypress verified."
+}
+
+# -----------------------------
+# Test Execution Logic
+# -----------------------------
+execute_test() {
local connector="$1"
local service="$2"
- local tmp_file="$3"
+ local failure_log="$3"
+ local job_slot="${4:-1}"
+
+ local start_ts=$(date +%s)
+ local start_fmt=$(date '+%H:%M:%S')
- print_color "yellow" "Executing tests for ${service} with connector ${connector}..."
+ echo "----------------------------------------------------"
+ print_color blue "[START] $service:$connector (Slot: $job_slot) at $start_fmt"
+ echo "----------------------------------------------------"
export REPORT_NAME="${service}_${connector}_report"
- if ! CYPRESS_CONNECTOR="$connector" npm run "cypress:$service"; then
- echo "${service}-${connector}" >> "${tmp_file}"
+ # -----------------------------
+ # XVFB
+ # -----------------------------
+ local unique_display=$((100 + job_slot))
+ export DISPLAY=":${unique_display}"
+
+ Xvfb "$DISPLAY" &
+ local xvfb_pid=$!
+ trap "kill $xvfb_pid 2>/dev/null || true" RETURN
+ sleep 1
+
+ # -----------------------------
+ # EXECUTE TEST
+ # -----------------------------
+ local exit_code=0
+ if ! bash -c '
+ export CYPRESS_CONNECTOR="'"$connector"'"
+ npm run "cypress:'"$service"'"
+ '
+ then
+ exit_code=1
fi
-}
-export -f execute_test
-# Function to run tests
-function run_tests() {
- local jobs="${1:-1}"
- tmp_file=$(mktemp)
+ local end_ts=$(date +%s)
+ local duration=$((end_ts - start_ts))
+
+ local status
+ if [[ $exit_code -eq 0 ]]; then
+ status="PASS"
+ print_color green "[PASS] $service:$connector | ${duration}s"
+ else
+ status="FAIL"
+ print_color red "[FAIL] $service:$connector | ${duration}s"
+ fi
- # Ensure temporary file is removed on script exit
- trap 'cleanup' EXIT
+ # Always record result
+ echo "${service}:${connector}:${status}:${duration}" >> "$results_log"
- for service in "${connector_map[@]}"; do
- declare -n connectors="$service"
+ # Keep legacy failure list (used for exit code)
+ if [[ "$status" == "FAIL" ]]; then
+ echo "${service}:${connector}" >> "$failure_log"
+ return 1
+ fi
- if [[ ${#connectors[@]} -eq 0 ]]; then
- # Service-level test (e.g., payment-method-list or routing)
- [[ $service == "payment_method_list" ]] && service="payment-method-list"
+ return 0
+}
- echo "Running ${service} tests without connectors..."
- export REPORT_NAME="${service}_report"
+export -f execute_test
+export -f command_exists
+export -f print_color
+export results_log
- if ! npm run "cypress:${service}"; then
- echo "${service}" >> "${tmp_file}"
- fi
- else
- # Connector-specific tests (e.g., payments or payouts)
- print_color "yellow" "Running tests for service: '${service}' with connectors: [${connectors[*]}] in batches of ${jobs}..."
+# -----------------------------
+# Runner
+# -----------------------------
+run_tests() {
+ local jobs="${1:-1}"
- # Execute tests in parallel
- printf '%s\n' "${connectors[@]}" | parallel --jobs "${jobs}" execute_test {} "${service}" "${tmp_file}"
- fi
+ read -r -a payments <<< "${PAYMENTS_CONNECTORS:-}"
+ read -r -a payouts <<< "${PAYOUTS_CONNECTORS:-}"
+ read -r -a payment_method_list <<< "${PAYMENT_METHOD_LIST:-}"
+ read -r -a routing <<< "${ROUTING:-}"
+
+ declare -A env_to_service=(
+ ["PAYMENTS_CONNECTORS"]="payments"
+ ["PAYOUTS_CONNECTORS"]="payouts"
+ ["PAYMENT_METHOD_LIST"]="payment_method_list"
+ ["ROUTING"]="routing"
+ )
+
+ local active_services=()
+ for env_var in "${!env_to_service[@]}"; do
+ [[ -n "${!env_var:-}" ]] && active_services+=("${env_to_service[$env_var]}")
done
- # Collect failed connectors
- if [[ -s "${tmp_file}" ]]; then
- failed_connectors=($(< "${tmp_file}"))
- print_color "red" "One or more connectors failed to run:"
- printf '%s\n' "${failed_connectors[@]}"
- exit 1
- else
- print_color "green" "Cypress tests execution successful!"
- fi
-}
+ for service in "${active_services[@]}"; do
+ declare -n connectors="$service"
-# Function to check and install dependencies
-function check_dependencies() {
- # parallel and npm are mandatory dependencies. exit the script if not found.
- local dependencies=("parallel" "npm")
+ if [[ ${#connectors[@]} -gt 0 ]]; then
+ print_color yellow " Starting Parallel Execution for '$service' (Jobs: $jobs)"
- for cmd in "${dependencies[@]}"; do
- if ! command_exists "$cmd"; then
- print_color "red" "ERROR: ${cmd^} is not installed!"
- exit 1
- else
- print_color "green" "${cmd^} is installed already!"
-
- if [[ ${cmd} == "npm" ]]; then
- npm ci || {
- print_color "red" "Command \`npm ci\` failed!"
- exit 1
- }
- fi
+ parallel --jobs "$jobs" \
+ --group \
+ --joblog "$job_log" \
+ execute_test {} "$service" "$tmp_file" {%} \
+ ::: "${connectors[@]}" || true
fi
done
-}
-# Cleanup function to handle exit
-function cleanup() {
- print_color "yellow" "Cleaning up..."
- if [[ -d "cypress-tests" ]]; then
- cd -
+ # -----------------------------
+ # Final Summary
+ # -----------------------------
+ if [[ -s "$results_log" ]]; then
+
+ print_color green "\n========================================"
+ print_color green " SUCCESSFUL CONNECTORS"
+ print_color green "========================================"
+ awk -F: '$3=="PASS" {
+ printf " • %-30s | %5ss\n", $1 ":" $2, $4
+ }' "$results_log"
+ print_color green "\n========================================"
+
+ print_color red "\n========================================"
+ print_color red " FAILED CONNECTORS"
+ print_color red "========================================"
+ awk -F: '$3=="FAIL" {
+ printf " • %-30s | %5ss\n", $1 ":" $2, $4
+ }' "$results_log"
+ print_color red "\n========================================"
+
+ print_color blue "\n========================================"
+ print_color blue " EXECUTION STATS"
+ print_color blue "========================================"
+ awk -F: '
+ {
+ total += $4
+ count++
+ if ($3=="PASS") pass++
+ if ($3=="FAIL") fail++
+ }
+ END {
+ printf " ➜ Total connectors run: %d\n", count
+ printf " ➜ Successful: %d\n", pass
+ printf " ➜ Failed: %d\n", fail
+ }' "$results_log"
fi
- if [[ -n "${tmp_file}" && -f "${tmp_file}" ]]; then
- rm -f "${tmp_file}"
- fi
+ [[ -s "$tmp_file" ]] && return 1 || return 0
}
-# Main function
-function main() {
+# -----------------------------
+# Main
+# -----------------------------
+main() {
local command="${1:-}"
- local jobs="${2:-5}"
+ local jobs="${2:-3}"
local test_dir="${3:-cypress-tests}"
- # Ensure script runs from the specified test directory (default: cypress-tests)
- if [[ "$(basename "$PWD")" != "$(basename "$test_dir")" ]]; then
- print_color "yellow" "Changing directory to '${test_dir}'..."
- cd "${test_dir}" || {
- print_color "red" "ERROR: Directory '${test_dir}' not found!"
- exit 1
- }
+ if [[ "$(basename "$PWD")" != "$(basename "$test_dir")" && -d "$test_dir" ]]; then
+ cd "$test_dir"
fi
check_dependencies
- read_service_arrays
case "$command" in
- --parallel | -p)
- print_color "yellow" "WARNING: Running Cypress tests in parallel is more resource-intensive!"
- # At present, parallel execution is restricted to not run out of memory
- # But can be scaled up by passing the value as an argument
- run_tests "$jobs"
- ;;
- *)
- run_tests 1
- ;;
+ --parallel|-p) run_tests "$jobs" ;;
+ *) run_tests 1 ;;
esac
}
-# Execute the main function with passed arguments
main "$@"