Skip to content

Commit 75d7c4e

Browse files
committed
Add SDK E2E Tests
- Create shell script to generate .env file for workflow - Add new workflow definition for tests
1 parent c6700aa commit 75d7c4e

File tree

2 files changed

+125
-0
lines changed

2 files changed

+125
-0
lines changed
+73
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,73 @@
1+
name: Continuous Integration - SDK E2E
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
environment:
7+
description: 'Environment to run e2e tests against'
8+
type: choice
9+
required: true
10+
default: 'dev-preprod'
11+
options:
12+
- dev-mainnet
13+
- dev-preprod
14+
- dev-preview
15+
- staging-preprod
16+
pull_request:
17+
push:
18+
branches: ['master']
19+
tags: ['*.*.*']
20+
21+
env:
22+
TL_DEPTH: ${{ github.event.pull_request.head.repo.fork && '0' || fromJson(vars.TL_DEPTH) }}
23+
TL_LEVEL: ${{ github.event.pull_request.head.repo.fork && 'info' || vars.TL_LEVEL }}
24+
# -----------------------------------------------------------------------------------------
25+
26+
jobs:
27+
build_and_test:
28+
strategy:
29+
matrix:
30+
os: [ubuntu-20.04]
31+
runs-on: ${{ matrix.os }}
32+
steps:
33+
- name: 📥 Checkout repository
34+
uses: actions/checkout@v3
35+
36+
- name: Generate .env file
37+
working-directory: ./packages/e2e/
38+
run: |
39+
networkMagic=$(jq --arg environment "${{ inputs.environment }}" <<< '{"dev-preprod":1, "dev-preview":2, "dev-mainnet":764824073, "staging-preprod":1}' '.[$environment]')
40+
./src/scripts/generate-dotenv.sh ${{ inputs.environment }}
41+
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
42+
43+
- name: 🧰 Setup Node.js
44+
uses: actions/setup-node@v3
45+
with:
46+
node-version: 18.12.0
47+
48+
- name: 🔨 Build
49+
run: |
50+
yarn install --immutable --inline-builds --mode=skip-build
51+
yarn build:cjs
52+
docker build --no-cache .
53+
env:
54+
NODE_OPTIONS: '--max_old_space_size=8192'
55+
56+
- name: 🌐 Setup local test network
57+
working-directory: packages/e2e
58+
run: |
59+
yarn local-network:up -d
60+
env:
61+
CARDANO_NODE_CHAINDB_LOG_LEVEL: 'Warning'
62+
CARDANO_NODE_LOG_LEVEL: 'Warning'
63+
OGMIOS_PORT: '1340'
64+
OGMIOS_URL: 'ws://ogmios:1340'
65+
POSTGRES_PORT: '5435'
66+
67+
- name: Wait for network init
68+
run: |
69+
yarn workspace @cardano-sdk/e2e wait-for-network-init
70+
71+
- name: 🔬 Test - e2e - wallet at epoch 0
72+
run: |
73+
yarn workspace @cardano-sdk/e2e test:wallet
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/bin/bash
2+
set -x
3+
set -o
4+
5+
environment="$1"
6+
7+
case "$environment" in
8+
"dev-mainnet")
9+
url="https://dev-mainnet.lw.iog.io"
10+
;;
11+
"dev-preprod")
12+
url="https://dev-preprod.lw.iog.io"
13+
;;
14+
"dev-preview")
15+
url="https://dev-preview.lw.iog.io"
16+
;;
17+
"staging-preprod")
18+
url="https://staging-preprod.lw.iog.io"
19+
;;
20+
*)
21+
echo "Invalid environment: $environment. Valid options are: dev-mainnet, dev-preprod, dev-preview, and staging-preprod"
22+
exit 1
23+
;;
24+
esac
25+
26+
# Construct the environment file content
27+
envFileContent="
28+
# Logger
29+
LOGGER_MIN_SEVERITY=info
30+
31+
# Key management setup - required by getWallet
32+
KEY_MANAGEMENT_PROVIDER=inMemory
33+
34+
# Providers setup - required by getWallet
35+
ASSET_PROVIDER=http
36+
ASSET_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
37+
HANDLE_PROVIDER=http
38+
HANDLE_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4011/\"}'
39+
NETWORK_INFO_PROVIDER=http
40+
NETWORK_INFO_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
41+
REWARDS_PROVIDER=http
42+
REWARDS_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
43+
TX_SUBMIT_PROVIDER=http
44+
TX_SUBMIT_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
45+
UTXO_PROVIDER=http
46+
UTXO_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
47+
STAKE_POOL_PROVIDER=http
48+
STAKE_POOL_PROVIDER_PARAMS='{\"baseUrl\":\"$url:4000/\"}'
49+
"
50+
51+
# Write the environment file content to the specified file
52+
echo "$envFileContent" > .env

0 commit comments

Comments
 (0)