Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(connector): add support for session update flow for klarna #5933

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ Cargo.lock @juspay/hyperswitch-framework

postman/ @juspay/hyperswitch-qa
cypress-tests/ @juspay/hyperswitch-qa
cypress-tests-v2/ @juspay/hyperswitch-qa

crates/api_models/src/events/ @juspay/hyperswitch-analytics
crates/api_models/src/events.rs @juspay/hyperswitch-analytics
Expand Down
26 changes: 20 additions & 6 deletions .github/workflows/CI-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,11 @@ jobs:
with:
toolchain: "${{ env.rust_version }}"

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install sccache
uses: taiki-e/install-action@v2.33.28
with:
Expand Down Expand Up @@ -219,6 +224,11 @@ jobs:
toolchain: stable 2 weeks ago
components: clippy

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install sccache
uses: taiki-e/install-action@v2.33.28
with:
Expand Down Expand Up @@ -297,6 +307,12 @@ jobs:
uses: dtolnay/rust-toolchain@master
with:
toolchain: stable 2 weeks ago
components: clippy

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install rust cache
uses: Swatinem/rust-cache@v2.7.0
Expand All @@ -307,14 +323,12 @@ jobs:
tool: just
checksum: true

- name: Run cargo check with v2 features enabled
- name: Run cargo clippy with v2 features enabled
shell: bash
# env:
# # Not denying warnings for now.
# # We only want to ensure successful compilation for now.
# RUSTFLAGS: "-D warnings -A clippy::todo"
run: just check_v2
run: just clippy_v2 -- -D warnings -Aunused -Aclippy::todo -Aclippy::diverging_sub_expression

- name: Run cargo check enabling only the release and v2 features
shell: bash
env:
RUSTFLAGS: "-A warnings"
run: cargo check --no-default-features --features "release,v2"
15 changes: 15 additions & 0 deletions .github/workflows/CI-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,11 @@ jobs:
with:
toolchain: "${{ env.rust_version }}"

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: Swatinem/rust-cache@v2.7.0
with:
save-if: ${{ github.event_name == 'push' }}
Expand Down Expand Up @@ -150,6 +155,11 @@ jobs:
toolchain: stable 2 weeks ago
components: clippy

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install cargo-hack
uses: baptiste0928/cargo-install@v2.2.0
with:
Expand Down Expand Up @@ -217,6 +227,11 @@ jobs:
with:
toolchain: stable 2 weeks ago

- name: Install Protoc
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install rust cache
uses: Swatinem/rust-cache@v2.7.0

Expand Down
218 changes: 218 additions & 0 deletions .github/workflows/cypress-tests-runner.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,218 @@
name: Run Cypress tests

on:
merge_group:
types:
- checks_requested
pull_request:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true

env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
CONNECTORS: stripe
RUST_BACKTRACE: short
RUSTUP_MAX_RETRIES: 10
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')}}
DEBUG: cypress:cli
RUST_MIN_STACK: 10485760

jobs:
runner:
name: Run Cypress tests
runs-on: hyperswitch-runners

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
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@v4

- 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: "f64157fe-a8f7-43a8-a268-b17e9a8c305f.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

- 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 mold linker
if: ${{ runner.os == 'Linux' && 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 sccache
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/install-action@v2.41.10
with:
tool: sccache
checksum: true

- name: Install cargo-nextest
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/install-action@v2.41.10
with:
tool: cargo-nextest
checksum: true

- name: Install Diesel CLI
if: ${{ env.RUN_TESTS == 'true' }}
uses: baptiste0928/cargo-install@v3.1.1
with:
crate: diesel_cli
features: postgres
args: --no-default-features

- name: Install Just
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/install-action@v2.41.10
with:
tool: just
checksum: true

- name: Install Node.js
if: ${{ env.RUN_TESTS == 'true' }}
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'

- 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: Build project
if: ${{ env.RUN_TESTS == 'true' }}
run: cargo build --package router --bin router --jobs 4

- name: Setup Local Server
if: ${{ env.RUN_TESTS == 'true' }}
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
if: ${{ env.RUN_TESTS == 'true' }}
env:
CYPRESS_BASEURL: "http://localhost:8080"
shell: bash -leuo pipefail {0}
run: |
cd cypress-tests

RED='\033[0;31m'
RESET='\033[0m'

failed_connectors=()

for connector in $(echo "${CONNECTORS}" | tr "," "\n"); do
echo "${connector}"
for service in "payments" "payouts"; do
if ! ROUTER__SERVER__WORKERS=4 CYPRESS_CONNECTOR="${connector}" npm run cypress:"${service}"; then
failed_connectors+=("${connector}-${service}")
fi
done
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

kill "${{ env.PID }}"

- name: Upload Cypress test results
if: env.RUN_TESTS == 'true' && failure()
uses: actions/upload-artifact@v4
with:
name: cypress-test-results
path: |
cypress-tests/cypress/reports/*.json
cypress-tests/cypress/reports/*.html
retention-days: 1
17 changes: 17 additions & 0 deletions .github/workflows/nix.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
name: "CI Nix"
on:
push:
branches:
- main
pull_request:
jobs:
nix-ci:
runs-on: ${{ matrix.system }}
permissions:
contents: read
strategy:
matrix:
system: [x86_64-linux, aarch64-darwin]
steps:
- uses: actions/checkout@v4
- run: om ci --extra-access-tokens ${{ secrets.GITHUB_TOKEN }} run --systems "${{ matrix.system }}"
6 changes: 6 additions & 0 deletions .github/workflows/postman-collection-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ jobs:
if: ${{ ((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')}}
uses: Swatinem/rust-cache@v2.7.0

- name: Install Protoc
if: ${{ ((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')}}
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install Diesel CLI with Postgres Support
if: ${{ ((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')}}
uses: baptiste0928/cargo-install@v2.2.0
Expand Down
Loading
Loading