mirror of
				https://github.com/juspay/hyperswitch.git
				synced 2025-11-01 02:57:02 +08:00 
			
		
		
		
	ci(postman): Run Postman collections against PRs (#1739)
This commit is contained in:
		
							
								
								
									
										162
									
								
								.github/workflows/postman-collection-runner.yml
									
									
									
									
										vendored
									
									
								
							
							
						
						
									
										162
									
								
								.github/workflows/postman-collection-runner.yml
									
									
									
									
										vendored
									
									
								
							| @ -1,68 +1,158 @@ | |||||||
| name: Postman Collection Runner | name: Run postman tests | ||||||
|  |  | ||||||
| on: | on: | ||||||
|   workflow_dispatch: |   workflow_dispatch: | ||||||
|   schedule: |   pull_request: | ||||||
|     - cron: "30 0,12 * * *" # Run workflow at 6 AM and 6 PM IST |   merge_group: | ||||||
|  |     types: [checks_requested] | ||||||
|  |  | ||||||
| concurrency: | concurrency: | ||||||
|   group: ${{ github.workflow }}-${{ github.ref }} |   group: ${{ github.workflow }}-${{ github.ref }} | ||||||
|   cancel-in-progress: true |   cancel-in-progress: true | ||||||
|  |  | ||||||
|  | env: | ||||||
|  |   CARGO_INCREMENTAL: 1 | ||||||
|  |   CARGO_NET_RETRY: 10 | ||||||
|  |   RUSTUP_MAX_RETRIES: 10 | ||||||
|  |   RUST_BACKTRACE: short | ||||||
|  |   CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse | ||||||
|  |  | ||||||
| jobs: | jobs: | ||||||
|   api_tests: |   runner: | ||||||
|     name: Run Postman Collection on integ env |     name: Run postman tests | ||||||
|     runs-on: ubuntu-latest |     runs-on: ubuntu-latest | ||||||
|  |  | ||||||
|     strategy: |     strategy: | ||||||
|       fail-fast: false |       fail-fast: false | ||||||
|       matrix: |       matrix: | ||||||
|         connector: |         connector: | ||||||
|           - aci |           # Grouping connectors based on their time consumption | ||||||
|           # - authorizedotnet |           # This would help in parallelizing the tests | ||||||
|           - bluesnap |           - aci, checkout, stripe | ||||||
|           # - braintree |           - bluesnap, nmi, worldline | ||||||
|           - checkout |  | ||||||
|           # - iatapay |     services: | ||||||
|           # - multisafepay |       redis: | ||||||
|           - nmi |         image: "${{ github.event_name != 'pull_request' && 'redis' || '' }}" | ||||||
|           - stripe |         options: >- | ||||||
|           # - trustpay |           --health-cmd "redis-cli ping" | ||||||
|           - worldline |           --health-interval 10s | ||||||
|  |           --health-timeout 5s | ||||||
|  |           --health-retries 5 | ||||||
|  |         ports: | ||||||
|  |           - 6379:6379 | ||||||
|  |       postgres: | ||||||
|  |         image: "${{ github.event_name != 'pull_request' && 'postgres:14.5' || '' }}" | ||||||
|  |         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: |     steps: | ||||||
|       - name: Checkout repository |       - name: Ignore Tests incase of pull request | ||||||
|  |         if: github.event_name == 'pull_request' | ||||||
|  |         shell: bash | ||||||
|  |         run: | | ||||||
|  |           echo "Skipped tests as the event is pull request"  | ||||||
|  |           exit 0 | ||||||
|  |  | ||||||
|  |       - name: Repository checkout | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|         uses: actions/checkout@v3 |         uses: actions/checkout@v3 | ||||||
|  |  | ||||||
|       - name: Install Rust |  | ||||||
|         uses: dtolnay/rust-toolchain@master |  | ||||||
|         with: |  | ||||||
|           toolchain: stable |  | ||||||
|  |  | ||||||
|       - uses: Swatinem/rust-cache@v2.4.0 |  | ||||||
|  |  | ||||||
|       - name: Decrypt connector auth file |       - name: Decrypt connector auth file | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|         env: |         env: | ||||||
|           CONNECTOR_AUTH_PASSPHRASE: ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }} |           CONNECTOR_AUTH_PASSPHRASE: ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }} | ||||||
|         shell: bash |         shell: bash | ||||||
|         run: ./scripts/decrypt_connector_auth.sh |         run: ./scripts/decrypt_connector_auth.sh | ||||||
|  |  | ||||||
|       - name: Set connector auth file path in env |       - name: Set paths in env | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|  |         id: config_path | ||||||
|         shell: bash |         shell: bash | ||||||
|         run: echo "CONNECTOR_CONFIG_PATH=$HOME/target/test/connector_auth.toml" >> $GITHUB_ENV |         run: | | ||||||
|  |           echo "CONNECTOR_AUTH_FILE_PATH=$HOME/target/test/connector_auth.toml" >> $GITHUB_ENV | ||||||
|  |  | ||||||
|  |       - name: Fetch keys | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|  |         env: | ||||||
|  |           TOML_PATH: "./config/development.toml" | ||||||
|  |         run: | | ||||||
|  |           LOCAL_ADMIN_API_KEY=$(yq '.secrets.admin_api_key' $TOML_PATH) | ||||||
|  |           echo "ADMIN_API_KEY=$LOCAL_ADMIN_API_KEY" >> $GITHUB_ENV | ||||||
|  |  | ||||||
|  |       - name: Install Rust | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|  |         uses: dtolnay/rust-toolchain@master | ||||||
|  |         with: | ||||||
|  |           toolchain: stable | ||||||
|  |  | ||||||
|  |       - name: Build and Cache Rust Dependencies | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|  |         uses: Swatinem/rust-cache@v2.4.0 | ||||||
|  |  | ||||||
|  |       - name: Install Diesel CLI with Postgres Support | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|  |         uses: baptiste0928/cargo-install@v2.1.0 | ||||||
|  |         with: | ||||||
|  |           crate: diesel_cli | ||||||
|  |           features: postgres | ||||||
|  |           args: "--no-default-features" | ||||||
|  |  | ||||||
|  |       - name: Diesel migration run | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|  |         shell: bash | ||||||
|  |         env: | ||||||
|  |           DATABASE_URL: postgres://db_user:db_pass@localhost:5432/hyperswitch_db | ||||||
|  |         run: diesel migration run | ||||||
|  |  | ||||||
|  |       - name: Setup Local Server | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|  |         run: | | ||||||
|  |           cargo run & | ||||||
|  |           COUNT=0 | ||||||
|  |           # Wait for the server to start in port 8080 | ||||||
|  |           while netstat -lnt | awk '$4 ~ /:8080$/ {exit 1}'; do  | ||||||
|  |               # Wait for 15 mins to start otherwise kill the task | ||||||
|  |               if [ $COUNT -gt 90 ]; | ||||||
|  |               then | ||||||
|  |                   exit 1 | ||||||
|  |               else  | ||||||
|  |                   COUNT=$((COUNT+1)) | ||||||
|  |                   sleep 10 | ||||||
|  |               fi | ||||||
|  |           done | ||||||
|  |  | ||||||
|       - name: Run Tests |       - name: Run Tests | ||||||
|  |         if: github.event_name != 'pull_request' | ||||||
|         env: |         env: | ||||||
|           ADMIN_API_KEY: ${{ secrets.INTEG_ADMIN_API_KEY }} |           BASE_URL: "http://localhost:8080" | ||||||
|           BASE_URL: ${{ secrets.INTEG_BASE_URL }} |  | ||||||
|           CONNECTOR_AUTH_FILE_PATH: ${{ env.CONNECTOR_CONFIG_PATH }} |  | ||||||
|           GATEWAY_MERCHANT_ID: ${{ secrets.STRIPE_GATEWAY_MERCHANT_ID }} |           GATEWAY_MERCHANT_ID: ${{ secrets.STRIPE_GATEWAY_MERCHANT_ID }} | ||||||
|           GPAY_CERTIFICATE: ${{ secrets.STRIPE_GPAY_CERTIFICATE }} |           GPAY_CERTIFICATE: ${{ secrets.STRIPE_GPAY_CERTIFICATE }} | ||||||
|           GPAY_CERTIFICATE_KEYS: ${{ secrets.STRIPE_GPAY_CERTIFICATE_KEYS }} |           GPAY_CERTIFICATE_KEYS: ${{ secrets.STRIPE_GPAY_CERTIFICATE_KEYS }} | ||||||
|         uses: nick-fields/retry@v2 |           INPUT: ${{ matrix.connector }} | ||||||
|         with: |         shell: bash | ||||||
|           timeout_minutes: 30 |         run: | | ||||||
|           max_attempts: 3 |           RED='\033[0;31m' | ||||||
|           retry_on: error |           RESET='\033[0m' | ||||||
|           command: | |           failed_connectors=() | ||||||
|             cargo run --package test_utils --bin test_utils -- --connector_name=${{ matrix.connector }} --base_url=$BASE_URL --admin_api_key=$ADMIN_API_KEY |  | ||||||
|  |           for i in $(echo "$INPUT" | tr "," "\n"); do | ||||||
|  |             if ! cargo run --bin test_utils -- --connector_name="$i" --base_url="$BASE_URL" --admin_api_key="$ADMIN_API_KEY"; then | ||||||
|  |               failed_connectors+=("$i") | ||||||
|  |             fi | ||||||
|  |           done | ||||||
|  |  | ||||||
|  |           if [ ${#failed_connectors[@]} -gt 0 ]; then | ||||||
|  |             echo -e "${RED}One or more connectors failed to run:${RESET}" | ||||||
|  |             printf '%s\n' "${failed_connectors[@]}" | ||||||
|  |             exit 1 | ||||||
|  |           fi | ||||||
|  | |||||||
							
								
								
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										1
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @ -1329,7 +1329,6 @@ dependencies = [ | |||||||
|  "anstyle", |  "anstyle", | ||||||
|  "bitflags 1.3.2", |  "bitflags 1.3.2", | ||||||
|  "clap_lex", |  "clap_lex", | ||||||
|  "once_cell", |  | ||||||
| ] | ] | ||||||
|  |  | ||||||
| [[package]] | [[package]] | ||||||
|  | |||||||
| @ -13,7 +13,7 @@ dummy_connector = ["api_models/dummy_connector"] | |||||||
| payouts = [] | payouts = [] | ||||||
|  |  | ||||||
| [dependencies] | [dependencies] | ||||||
| clap = { version = "4.3.2", default-features = false, features = ["std", "derive", "help", "usage", "cargo"] } | clap = { version = "4.3.2", default-features = false, features = ["derive"] } | ||||||
| serde = { version = "1.0.163", features = ["derive"] } | serde = { version = "1.0.163", features = ["derive"] } | ||||||
| serde_json = "1.0.96" | serde_json = "1.0.96" | ||||||
| serde_path_to_error = "0.1.11" | serde_path_to_error = "0.1.11" | ||||||
|  | |||||||
| @ -46,7 +46,6 @@ fn main() { | |||||||
|     // variables set up for certificate, will consider those variables and will fail. |     // variables set up for certificate, will consider those variables and will fail. | ||||||
|  |  | ||||||
|     let mut newman_command = cmd::new("newman"); |     let mut newman_command = cmd::new("newman"); | ||||||
|  |  | ||||||
|     newman_command.args(["run", &collection_path]); |     newman_command.args(["run", &collection_path]); | ||||||
|     newman_command.args(["--env-var", &format!("admin_api_key={admin_api_key}")]); |     newman_command.args(["--env-var", &format!("admin_api_key={admin_api_key}")]); | ||||||
|     newman_command.args(["--env-var", &format!("baseUrl={base_url}")]); |     newman_command.args(["--env-var", &format!("baseUrl={base_url}")]); | ||||||
| @ -125,6 +124,8 @@ fn main() { | |||||||
|  |  | ||||||
|     newman_command.arg("--delay-request").arg("5"); |     newman_command.arg("--delay-request").arg("5"); | ||||||
|  |  | ||||||
|  |     newman_command.arg("--color").arg("on"); | ||||||
|  |  | ||||||
|     // Execute the newman command |     // Execute the newman command | ||||||
|     let output = newman_command.spawn(); |     let output = newman_command.spawn(); | ||||||
|     let mut child = match output { |     let mut child = match output { | ||||||
| @ -147,7 +148,7 @@ fn main() { | |||||||
|             } |             } | ||||||
|         } |         } | ||||||
|         Err(err) => { |         Err(err) => { | ||||||
|             eprintln!("Failed to wait for command execution: {}", err); |             eprintln!("Failed to wait for command execution: {err}"); | ||||||
|             exit(1); |             exit(1); | ||||||
|         } |         } | ||||||
|     }; |     }; | ||||||
|  | |||||||
		Reference in New Issue
	
	Block a user
	 Pa1NarK
					Pa1NarK