diff --git a/.github/e2e-setup/action.yml b/.github/e2e-setup/action.yml index 43a994c5..e6bbb567 100644 --- a/.github/e2e-setup/action.yml +++ b/.github/e2e-setup/action.yml @@ -1,31 +1,95 @@ name: E2E Setup description: Setup environment for E2E tests +inputs: + infura_api_key: + description: 'Infura API Key for EVM interactions' + required: true + evm_private_key: + description: 'EVM Private Key for transactions' + required: true + eth_rpc_url: + description: 'Ethereum RPC URL' + required: true + runs: using: composite steps: - name: Check out repository uses: actions/checkout@v3 + - name: Setup EVM environment file + shell: bash + run: | + cd evm + cp .env.example .env + sed -i "s/INFURA_API_KEY=/INFURA_API_KEY=${{ inputs.infura_api_key }}/" .env + sed -i "s/EVM_PRIVATE_KEY=/EVM_PRIVATE_KEY=${{ inputs.evm_private_key }}/" .env + + - name: Setup E2E testing tools environment file + shell: bash + run: | + cd e2e-testing/tools + cp .env.example .env + sed -i "s/INFURA_API_KEY=/INFURA_API_KEY=${{ inputs.infura_api_key }}/" .env + sed -i "s/EVM_PRIVATE_KEY=/EVM_PRIVATE_KEY=${{ inputs.evm_private_key }}/" .env + sed -i "s|ETH_RPC_URL=|ETH_RPC_URL=${{ inputs.eth_rpc_url }}|" .env + + - name: Setup Bridge SDK config + shell: bash + run: | + cd e2e-testing + cp bridge-sdk-config.example.json bridge-sdk-config.json + sed -i "s//${{ inputs.evm_private_key }}/" bridge-sdk-config.json + sed -i "s||${{ inputs.eth_rpc_url }}|" bridge-sdk-config.json + - name: Set up Node.js uses: actions/setup-node@v3 with: - node-version: '16' + node-version: '18' - name: Install Yarn shell: bash run: sudo npm install -g yarn + - name: Install Node.js dependencies + shell: bash + run: | + cd evm && yarn install + cd ../e2e-testing/tools && yarn install + - name: Setup Rust toolchain uses: dtolnay/rust-toolchain@stable with: toolchain: 1.81.0 target: wasm32-unknown-unknown + # Temporary + cache-on-failure: true + + - name: Cache Rust dependencies + uses: Swatinem/rust-cache@v2 + with: + shared-key: "e2e-setup-cache" + cache-directories: | + ~/.cargo/bin/ + ~/.cargo/registry/index/ + ~/.cargo/registry/cache/ + ~/.cargo/git/db/ + target/ + + - name: Install Bridge SDK + shell: bash + run: | + if ! command -v bridge-cli &> /dev/null; then + cargo install --git https://github.com/Near-One/bridge-sdk-rs/ --rev f31a394 bridge-cli + fi - name: Install NEAR CLI shell: bash run: | - cargo install --git https://github.com/Near-One/bridge-sdk-rs/ --rev 543a46a bridge-cli + if ! command -v near &> /dev/null; then + curl --proto '=https' --tlsv1.2 -LsSf https://github.com/near/near-cli-rs/releases/download/v0.18.0/near-cli-rs-installer.sh | sh + fi - name: Install optional additional packages shell: bash @@ -33,7 +97,17 @@ runs: sudo apt-get update sudo apt-get install -y jq + - name: Cache Solana CLI and Anchor + uses: actions/cache@v3 + id: solana-cache + with: + path: | + ~/.local/share/solana + ~/.cargo/bin/anchor + key: ${{ runner.os }}-solana-anchor-v0.30.1 + - name: Install Solana CLI and Anchor + if: steps.solana-cache.outputs.cache-hit != 'true' shell: bash run: | sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)" diff --git a/.github/workflows/e2e-test.yml b/.github/workflows/e2e-test.yml index 74fa3d14..6baafc96 100644 --- a/.github/workflows/e2e-test.yml +++ b/.github/workflows/e2e-test.yml @@ -6,7 +6,7 @@ on: selected_pipelines: description: "Space-separated list of pipelines to run (e.g. 'bridge_token_near_to_evm another_pipeline')" required: false - default: "bridge_token_near_to_evm" + default: "bridge-token-near-to-evm" jobs: get-pipelines-matrix: @@ -35,6 +35,10 @@ jobs: - name: Setup E2E environment uses: ./.github/e2e-setup + with: + infura_api_key: ${{ secrets.E2E_INFURA_API_KEY }} + evm_private_key: ${{ secrets.E2E_EVM_PRIVATE_KEY }} + eth_rpc_url: ${{ secrets.E2E_ETH_RPC_URL }} - name: Get dependencies for each pipeline id: get_deps @@ -70,8 +74,13 @@ jobs: - name: Setup E2E environment uses: ./.github/e2e-setup + with: + infura_api_key: ${{ secrets.E2E_INFURA_API_KEY }} + evm_private_key: ${{ secrets.E2E_EVM_PRIVATE_KEY }} + eth_rpc_url: ${{ secrets.E2E_ETH_RPC_URL }} - name: Download common dependencies + if: ${{ needs.analyze-dependencies.result == 'success' }} uses: actions/download-artifact@v3 with: name: common-dependencies @@ -79,11 +88,12 @@ jobs: - name: Run pipeline run: | echo "Running pipeline: ${{ matrix.pipeline }}" - make ${{ matrix.pipeline }} + cd e2e-testing && make ${{ matrix.pipeline }} - name: Upload test artifacts + if: always() uses: actions/upload-artifact@v3 with: name: e2e-test-results-${{ matrix.pipeline }} path: | - e2e-testing/generated/*.json + e2e-testing/generated/* diff --git a/e2e-testing/.gitignore b/e2e-testing/.gitignore index f4592971..bf6e3953 100644 --- a/e2e-testing/.gitignore +++ b/e2e-testing/.gitignore @@ -11,4 +11,6 @@ tools/node_modules/ tools/.env tools/typechain-types/ tools/dist/ -tools/node_modules/ \ No newline at end of file +tools/node_modules/ + +bridge-sdk-config.json \ No newline at end of file diff --git a/e2e-testing/makefiles/common.mk b/e2e-testing/makefiles/common.mk index 351f6389..3b9d971a 100644 --- a/e2e-testing/makefiles/common.mk +++ b/e2e-testing/makefiles/common.mk @@ -35,7 +35,7 @@ common_scripts_dir := $(common_tools_dir)/src/scripts # Common files common_near_bridge_id_file := $(common_near_deploy_results_dir)/omni_bridge.json -common_bridge_sdk_config_file := $(common_generated_dir)/bridge-sdk-config.json +common_bridge_sdk_config_file := $(common_testing_root)/bridge-sdk-config.json common_tools_compile_stamp := $(common_generated_dir)/.tools-compile.stamp # Chain identifiers diff --git a/e2e-testing/makefiles/pipelines/bridge_token_near_to_evm.mk b/e2e-testing/makefiles/pipelines/bridge_token_near_to_evm.mk index 0f4492d6..b4bc4fc4 100644 --- a/e2e-testing/makefiles/pipelines/bridge_token_near_to_evm.mk +++ b/e2e-testing/makefiles/pipelines/bridge_token_near_to_evm.mk @@ -121,7 +121,7 @@ $(pipeline1_evm_deploy_token_file): $(pipeline1_log_metadata_file) $(sepolia_bri near-bind-token: $(pipeline1_near_bind_token_file) $(pipeline1_near_bind_token_file): $(pipeline1_evm_deploy_token_file) $(pipeline1_relayer_account_file) | $(pipeline1_call_dir) $(call description,Waiting for Ethereum transaction being captured by relayer) - # $(call progress_wait,1300) + $(call progress_wait,1300) $(call description,Bridge NEAR Token to Ethereum. Step 3: Binding token on NEAR) TX_HASH=$$(jq -r .tx_hash $(pipeline1_evm_deploy_token_file)) && \ RELAYER_ACCOUNT_ID=$$(jq -r .account_id $(pipeline1_relayer_account_file)) && \ diff --git a/e2e-testing/tools/src/scripts/deploy-near-contract.sh b/e2e-testing/tools/src/scripts/deploy-near-contract.sh index 6b307c57..376c219c 100755 --- a/e2e-testing/tools/src/scripts/deploy-near-contract.sh +++ b/e2e-testing/tools/src/scripts/deploy-near-contract.sh @@ -46,7 +46,7 @@ INIT_ARGS=$(echo "$STATIC_INIT_ARGS $DYN_INIT_ARGS" | jq -s add) echo "Creating the contract account" # Create the contract account if ! near account create-account sponsor-by-faucet-service "$CONTRACT_ID" \ - autogenerate-new-keypair save-to-keychain network-config testnet create; then + autogenerate-new-keypair save-to-legacy-keychain network-config testnet create; then echo "Failed to create account for ${CONTRACT_NAME}" exit 1 fi @@ -57,7 +57,7 @@ sleep 3 # Deploy the contract echo "Deploying the contract" if ! near contract deploy "$CONTRACT_ID" use-file "$WASM_PATH" \ - without-init-call network-config testnet sign-with-keychain send; then + without-init-call network-config testnet sign-with-legacy-keychain send; then echo "Failed to deploy ${CONTRACT_NAME}" exit 1 fi