From 31bacdd7f08afac3e35ec6dbe7ca1bc437555412 Mon Sep 17 00:00:00 2001 From: Ola <32410436+ce0la@users.noreply.github.com> Date: Wed, 19 Jun 2024 11:20:11 +0100 Subject: [PATCH] Lw 10449 sdk e2e tests ci (#1332) Add SDK E2E Tests - Create shell script to generate .env file for workflow - Add new workflow definition for tests --- .github/workflows/test-deploy-e2e.yaml | 55 ++++++++++++++++++--- packages/e2e/src/scripts/generate-dotenv.sh | 35 +++++++++++++ 2 files changed, 82 insertions(+), 8 deletions(-) create mode 100755 packages/e2e/src/scripts/generate-dotenv.sh diff --git a/.github/workflows/test-deploy-e2e.yaml b/.github/workflows/test-deploy-e2e.yaml index ef401561602..f5cbdb3ded0 100644 --- a/.github/workflows/test-deploy-e2e.yaml +++ b/.github/workflows/test-deploy-e2e.yaml @@ -1,15 +1,54 @@ -name: CI/CD +name: Deployed Environments - SDK E2E Tests on: - push: workflow_dispatch: + inputs: + environment: + description: 'Environment to run e2e tests against' + type: choice + required: true + default: 'dev-preprod' + options: + - live-preprod + - live-preview + - dev-preprod + - dev-preview + - staging-preprod -jobs: - hello-world-placeholder: - name: Hello World Placeholder - runs-on: ubuntu-22.04 +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: Hello World + - name: 📥 Checkout repository + uses: actions/checkout@v3 + + - name: Generate .env file + working-directory: ./packages/e2e/ + run: | + if [[ "${{ inputs.environment }}" == *"preprod"* ]]; then networkMagic=1; else networkMagic=2; fi + ./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: 🔬 Test - e2e - wallet at epoch 0 run: | - echo 'Hello, World!' + yarn workspace @cardano-sdk/e2e test:wallet diff --git a/packages/e2e/src/scripts/generate-dotenv.sh b/packages/e2e/src/scripts/generate-dotenv.sh new file mode 100755 index 00000000000..0c6a1248647 --- /dev/null +++ b/packages/e2e/src/scripts/generate-dotenv.sh @@ -0,0 +1,35 @@ +#!/bin/bash +set -x +set -o + +environment="$1" + +url="https://${environment}.lw.iog.io" + +# 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