Skip to content

Commit

Permalink
Add SDK E2E Tests
Browse files Browse the repository at this point in the history
- Create shell script to generate .env file for workflow
- Add new workflow definition for tests
  • Loading branch information
ce0la committed Jun 14, 2024
1 parent c6700aa commit 56f1187
Show file tree
Hide file tree
Showing 2 changed files with 125 additions and 0 deletions.
73 changes: 73 additions & 0 deletions .github/workflows/test-deploy-e2e.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
name: Deployed Environments - SDK E2E Tests

on:
workflow_dispatch:
inputs:
environment:
description: 'Environment to run e2e tests against'
type: choice
required: true
default: 'dev-preprod'
options:
- dev-mainnet
- dev-preprod
- dev-preview
- staging-preprod
pull_request:
push:
branches: ['master']
tags: ['*.*.*']

env:
TL_DEPTH: ${{ github.event.pull_request.head.repo.fork && '0' || fromJson(vars.TL_DEPTH) }}
TL_LEVEL: ${{ github.event.pull_request.head.repo.fork && 'info' || vars.TL_LEVEL }}
# -----------------------------------------------------------------------------------------

jobs:
build_and_test:
strategy:
matrix:
os: [ubuntu-20.04]
runs-on: ${{ matrix.os }}
steps:
- name: 📥 Checkout repository
uses: actions/checkout@v3

- name: Generate .env file
working-directory: ./packages/e2e/
run: |
networkMagic=$(jq --arg environment "${{ inputs.environment }}" <<< '{"dev-preprod":1, "dev-preview":2, "dev-mainnet":764824073, "staging-preprod":1}' '.[$environment]')
./src/scripts/generate-dotenv.sh ${{ inputs.environment }}
echo "KEY_MANAGEMENT_PARAMS='$(jq --argjson networkMagic $networkMagic --arg mnemonic "${{ secrets.MNEMONIC }}" <<< '{"bip32Ed25519": "Sodium", "accountIndex": 0, "chainId":{"networkId": 0, "networkMagic": 0}, "passphrase":"some_passphrase","mnemonic":"mnemonics"}' '.mnemonic=$mnemonic | .chainId.networkMagic=$networkMagic')'" >> .env
- name: 🧰 Setup Node.js
uses: actions/setup-node@v3
with:
node-version: 18.12.0

- name: 🔨 Build
run: |
yarn install --immutable --inline-builds --mode=skip-build
yarn build:cjs
docker build --no-cache .
env:
NODE_OPTIONS: '--max_old_space_size=8192'

- name: 🌐 Setup local test network
working-directory: packages/e2e
run: |
yarn local-network:up -d
env:
CARDANO_NODE_CHAINDB_LOG_LEVEL: 'Warning'
CARDANO_NODE_LOG_LEVEL: 'Warning'
OGMIOS_PORT: '1340'
OGMIOS_URL: 'ws://ogmios:1340'
POSTGRES_PORT: '5435'

- name: Wait for network init
run: |
yarn workspace @cardano-sdk/e2e wait-for-network-init
- name: 🔬 Test - e2e - wallet at epoch 0
run: |
yarn workspace @cardano-sdk/e2e test:wallet
52 changes: 52 additions & 0 deletions packages/e2e/src/scripts/generate-dotenv.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
#!/bin/bash
set -x
set -o

environment="$1"

case "$environment" in
"dev-mainnet")
url="https://dev-mainnet.lw.iog.io"
;;
"dev-preprod")
url="https://dev-preprod.lw.iog.io"
;;
"dev-preview")
url="https://dev-preview.lw.iog.io"
;;
"staging-preprod")
url="https://staging-preprod.lw.iog.io"
;;
*)
echo "Invalid environment: $environment. Valid options are: dev-mainnet, dev-preprod, dev-preview, and staging-preprod"
exit 1
;;
esac

# Construct the environment file content
envFileContent="
# Logger
LOGGER_MIN_SEVERITY=info
# Key management setup - required by getWallet
KEY_MANAGEMENT_PROVIDER=inMemory
# Providers setup - required by getWallet
ASSET_PROVIDER=http
ASSET_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
HANDLE_PROVIDER=http
HANDLE_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4011/\"}'
NETWORK_INFO_PROVIDER=http
NETWORK_INFO_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
REWARDS_PROVIDER=http
REWARDS_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
TX_SUBMIT_PROVIDER=http
TX_SUBMIT_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
UTXO_PROVIDER=http
UTXO_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
STAKE_POOL_PROVIDER=http
STAKE_POOL_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
"

# Write the environment file content to the specified file
echo "$envFileContent" > .env

0 comments on commit 56f1187

Please sign in to comment.