Skip to content

Commit

Permalink
Merge branch 'fix-wasm-jenkins-build' of github.com:juspay/hyperswitc…
Browse files Browse the repository at this point in the history
…h into fix-wasm-jenkins-build
  • Loading branch information
JeevaRamu0104 committed Jan 24, 2025
2 parents d858b9b + 83bc590 commit 1d9b850
Show file tree
Hide file tree
Showing 286 changed files with 13,367 additions and 6,275 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/CI-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ jobs:

- name: Run clippy
shell: bash
run: just clippy
run: just clippy --jobs 2

- name: Check Cargo.lock changed
if: ${{ (github.event.pull_request.head.repo.full_name == github.event.pull_request.base.repo.full_name) }}
Expand Down
30 changes: 23 additions & 7 deletions .github/workflows/CI-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ jobs:
runs-on: ${{ matrix.runner }}

env:
# Use `sccache` for caching compilation artifacts
RUSTC_WRAPPER: sccache
RUSTFLAGS: "-D warnings"

strategy:
Expand Down Expand Up @@ -75,10 +77,16 @@ jobs:
uses: arduino/setup-protoc@v3
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: Swatinem/[email protected]

- name: Install sccache
uses: taiki-e/[email protected]
with:
save-if: ${{ github.event_name == 'push' }}
tool: sccache
checksum: true

# - uses: Swatinem/[email protected]
# with:
# save-if: ${{ github.event_name == 'push' }}

- name: Install cargo-hack
uses: baptiste0928/[email protected]
Expand Down Expand Up @@ -131,6 +139,8 @@ jobs:
runs-on: ${{ matrix.runner }}

env:
# Use `sccache` for caching compilation artifacts
RUSTC_WRAPPER: sccache
RUSTFLAGS: "-D warnings"

strategy:
Expand Down Expand Up @@ -160,6 +170,12 @@ jobs:
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- name: Install sccache
uses: taiki-e/[email protected]
with:
tool: sccache
checksum: true

- name: Install cargo-hack
uses: baptiste0928/[email protected]
with:
Expand All @@ -180,13 +196,13 @@ jobs:
# with:
# crate: cargo-nextest

- uses: Swatinem/[email protected]
with:
save-if: ${{ github.event_name == 'push' }}
# - uses: Swatinem/[email protected]
# with:
# save-if: ${{ github.event_name == 'push' }}

- name: Run clippy
shell: bash
run: just clippy
run: just clippy --jobs 2

- name: Cargo hack
if: ${{ github.event_name == 'push' }}
Expand Down
226 changes: 216 additions & 10 deletions .github/workflows/cypress-tests-runner.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ env:
CARGO_INCREMENTAL: 0
CARGO_NET_RETRY: 10
PAYMENTS_CONNECTORS: "cybersource stripe"
PAYOUTS_CONNECTORS: "adyenplatform wise"
PAYOUTS_CONNECTORS: "wise"
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')}}
Expand Down Expand Up @@ -128,7 +128,7 @@ jobs:
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: "aa328308-b34e-41b7-a590-4fe45cfe7991.json.gpg"
S3_SOURCE_FILE_NAME: "5b3ebdad-1067-421b-83e5-3ceb73c3eeeb.json.gpg"
shell: bash
run: |
mkdir -p ".github/secrets" ".github/test"
Expand All @@ -149,7 +149,7 @@ jobs:
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
Expand All @@ -170,13 +170,6 @@ jobs:
tool: sccache
checksum: true

- name: Install cargo-nextest
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/[email protected]
with:
tool: cargo-nextest
checksum: true

- name: Install Diesel CLI
if: ${{ env.RUN_TESTS == 'true' }}
uses: baptiste0928/[email protected]
Expand Down Expand Up @@ -222,6 +215,11 @@ jobs:

- 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 }}
run: |
# Start the server in the background
target/debug/router &
Expand Down Expand Up @@ -261,3 +259,211 @@ jobs:
path: |
cypress-tests/cypress/reports/
retention-days: 1

runner_v2:
name: Run Cypress tests on v2 and generate coverage report
runs-on: hyperswitch-runners
env:
CODECOV_FILE: "lcov.info"

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: "aa328308-b34e-41b7-a590-4fe45cfe7991.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: llvm-tools-preview

- name: Install sccache
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/[email protected]
with:
tool: sccache
checksum: true

- 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 grcov
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/[email protected]
with:
tool: grcov
checksum: true

- name: Install Just
if: ${{ env.RUN_TESTS == 'true' }}
uses: taiki-e/[email protected]
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-v2
- 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_v2 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: Build project
if: ${{ env.RUN_TESTS == 'true' }}
env:
RUSTFLAGS: "-Cinstrument-coverage"
run: just build_v2 --jobs 3

- name: Setup Local Server
if: ${{ env.RUN_TESTS == 'true' }}
env:
LLVM_PROFILE_FILE: "coverage.profraw"
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"
ROUTER__SERVER__WORKERS: 4
shell: bash -leuo pipefail {0}
continue-on-error: true
# We aren't specifying `command` and `jobs` arguments currently
run: scripts/execute_cypress.sh "" "" "cypress-tests-v2"

- name: Stop running server
if: ${{ env.RUN_TESTS == 'true' }} && always()
run: |
kill "${{ env.PID }}"
- name: Upload Cypress test results
if: env.RUN_TESTS == 'true' && failure()
uses: actions/upload-artifact@v4
with:
name: cypress-v2-test-results
path: |
cypress-tests-v2/cypress/reports/
retention-days: 1

# Notes:
# - The `router` process must be killed (using SIGINT/SIGTERM) to generate the `coverage.profraw` file, otherwise the coverage will only be generated for the buildscripts
# - Trying to generate branch coverage using "-Z coverage-options=branch" currently fails. Both grcov and cargo-llvm-cov crash when trying
# to process the generated `.profraw` files.
# - --keep-only argument is used to exclude external crates in generated lcov.info file (~500MiB -> ~70MiB)
- name: Process coverage report
if: ${{ env.RUN_TESTS == 'true' && github.event_name != 'merge_group' }}
run: grcov . --source-dir . --output-types lcov --output-path ${{ env.CODECOV_FILE }} --binary-path ./target/debug --keep-only "crates/*"

- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
if: ${{ env.RUN_TESTS == 'true' && github.event_name != 'merge_group'}}
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: ${{ env.CODECOV_FILE }}
disable_search: true
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -241,6 +241,7 @@ $RECYCLE.BIN/
# hyperswitch Project specific excludes
# code coverage report
*.profraw
lcov.info
html/
coverage.json
# other
Expand Down
Loading

0 comments on commit 1d9b850

Please sign in to comment.