Skip to content

Commit 324df4d

Browse files
jarnuraArjunKarthikSanchithHegde
authored
Connector Sanity tests in CI/CD (#732)
Co-authored-by: Arjun Karthik <[email protected]> Co-authored-by: Sanchith Hegde <[email protected]>
1 parent a05059b commit 324df4d

File tree

6 files changed

+120
-10
lines changed

6 files changed

+120
-10
lines changed
1.23 KB
Binary file not shown.

.github/workflows/CI.yml

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -356,11 +356,7 @@ jobs:
356356
- name: Cargo hack storage_models
357357
if: env.storage_models_changes_exist == 'true'
358358
run: cargo hack check --each-feature --no-dev-deps -p storage_models
359-
360-
# - name: Run tests
361-
# shell: bash
362-
# run: cargo nextest run --all-features
363-
359+
364360
typos:
365361
name: Spell check
366362
runs-on: ubuntu-latest
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Connector Sanity Tests
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
8+
pull_request:
9+
10+
schedule:
11+
- cron: '5 0 * * *'
12+
13+
concurrency:
14+
group: ${{ github.workflow }}-${{ github.ref }}
15+
cancel-in-progress: true
16+
17+
env:
18+
# Disable incremental compilation.
19+
#
20+
# Incremental compilation is useful as part of an edit-build-test-edit cycle,
21+
# as it lets the compiler avoid recompiling code that hasn't changed. However,
22+
# on CI, we're not making small edits; we're almost always building the entire
23+
# project from scratch. Thus, incremental compilation on CI actually
24+
# introduces *additional* overhead to support making future builds
25+
# faster...but no future builds will ever occur in any given CI environment.
26+
#
27+
# See https://matklad.github.io/2021/09/04/fast-rust-builds.html#ci-workflow
28+
# for details.
29+
CARGO_INCREMENTAL: 0
30+
# Allow more retries for network requests in cargo (downloading crates) and
31+
# rustup (installing toolchains). This should help to reduce flaky CI failures
32+
# from transient network timeouts or other issues.
33+
CARGO_NET_RETRY: 10
34+
RUSTUP_MAX_RETRIES: 10
35+
# Don't emit giant backtraces in the CI logs.
36+
RUST_BACKTRACE: short
37+
# Use cargo's sparse index protocol
38+
CARGO_REGISTRIES_CRATES_IO_PROTOCOL: sparse
39+
40+
jobs:
41+
test_connectors:
42+
name: Run tests on stable toolchain for connectors
43+
runs-on: ubuntu-latest
44+
45+
services:
46+
redis:
47+
image: redis
48+
options: >-
49+
--health-cmd "redis-cli ping"
50+
--health-interval 10s
51+
--health-timeout 5s
52+
--health-retries 5
53+
ports:
54+
- 6379:6379
55+
56+
strategy:
57+
fail-fast: false
58+
matrix:
59+
connector:
60+
- stripe
61+
- aci
62+
- adyen
63+
#- authorizedotnet
64+
#- checkout
65+
#- cybersource
66+
- shift4
67+
#- worldpay
68+
#- payu
69+
#- globalpay
70+
#- rapyd
71+
#- fiserv
72+
- worldline
73+
#- multisafepay
74+
- dlocal
75+
#- bambora
76+
#- nuvei
77+
78+
steps:
79+
- name: Checkout repository
80+
uses: actions/[email protected]
81+
82+
- name: Install Rust
83+
uses: dtolnay/rust-toolchain@master
84+
with:
85+
toolchain: stable
86+
87+
- uses: Swatinem/[email protected]
88+
89+
- name: Decrypt connector auth file
90+
run: ./scripts/decrypt_connector_auth.sh
91+
env:
92+
CONNECTOR_AUTH_PASSPHRASE: ${{ secrets.CONNECTOR_AUTH_PASSPHRASE }}
93+
94+
- name: Set connector auth file path in env
95+
run: echo "CONNECTOR_AUTH_FILE_PATH=$HOME/target/test/connector_auth.toml" >> $GITHUB_ENV
96+
97+
- name: Run connector tests
98+
uses: actions-rs/cargo@v1
99+
with:
100+
command: test
101+
args: --package router --test connectors -- ${{ matrix.connector }} --test-threads=1

crates/router/tests/connectors/connector_auth.rs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
use std::env;
2+
13
use router::types::ConnectorAuthType;
24
use serde::Deserialize;
35

@@ -27,11 +29,12 @@ pub(crate) struct ConnectorAuthentication {
2729
}
2830

2931
impl ConnectorAuthentication {
32+
#[allow(clippy::expect_used)]
3033
pub(crate) fn new() -> Self {
31-
#[allow(clippy::expect_used)]
34+
let path = env::var("CONNECTOR_AUTH_FILE_PATH")
35+
.expect("connector authentication file path not set");
3236
toml::from_str(
33-
&std::fs::read_to_string("tests/connectors/auth.toml")
34-
.expect("connector authentication config file not found"),
37+
&std::fs::read_to_string(path).expect("connector authentication config file not found"),
3538
)
3639
.expect("Failed to read connector authentication config file")
3740
}

crates/router/tests/connectors/worldline.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,9 @@ async fn should_throw_not_implemented_for_unsupported_issuer() {
138138
assert_eq!(
139139
*response.unwrap_err().current_context(),
140140
errors::ConnectorError::NotSupported {
141-
payment_method: "Maestro".to_string(),
141+
payment_method: "card".to_string(),
142142
connector: "worldline",
143-
payment_experience: "redirect_to_url".to_string(),
143+
payment_experience: "RedirectToUrl".to_string(),
144144
}
145145
)
146146
}

scripts/decrypt_connector_auth.sh

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
#! /usr/bin/env bash
2+
3+
mkdir -p $HOME/target/test
4+
5+
6+
# Decrypt the file
7+
# --batch to prevent interactive command
8+
# --yes to assume "yes" for questions
9+
gpg --quiet --batch --yes --decrypt --passphrase="$CONNECTOR_AUTH_PASSPHRASE" \
10+
--output $HOME/target/test/connector_auth.toml .github/secrets/connector_auth.toml.gpg

0 commit comments

Comments
 (0)