Skip to content

Commit

Permalink
Add environment setup and builds caching
Browse files Browse the repository at this point in the history
  • Loading branch information
kisialiou committed Jan 30, 2025
1 parent 888c707 commit a6b3499
Show file tree
Hide file tree
Showing 6 changed files with 102 additions and 21 deletions.
78 changes: 76 additions & 2 deletions .github/e2e-setup/action.yml
Original file line number Diff line number Diff line change
@@ -1,39 +1,113 @@
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/<ETH_PRIVATE_KEY>/${{ inputs.evm_private_key }}/" bridge-sdk-config.json
sed -i "s|<ETH_RPC>|${{ inputs.eth_rpc_url }}/${{ inputs.infura_api_key }}|" 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

- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
shared-key: "e2e-setup-cache"
cache-on-failure: true
cache-all-crates: true
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 b7c5acf 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
run: |
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)"
Expand Down
16 changes: 13 additions & 3 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -70,20 +74,26 @@ 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

- 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/*
4 changes: 3 additions & 1 deletion e2e-testing/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,6 @@ tools/node_modules/
tools/.env
tools/typechain-types/
tools/dist/
tools/node_modules/
tools/node_modules/

bridge-sdk-config.json
16 changes: 5 additions & 11 deletions e2e-testing/makefiles/common.mk
Original file line number Diff line number Diff line change
Expand Up @@ -12,18 +12,11 @@ endef

# Progress bar for waiting operations
define progress_wait
@tput civis; \
for i in $$(seq 1 $(1)); do \
printf "\033[2K\rWaiting: ["; \
p=$$((i * 100 / $(1))); \
for j in $$(seq 1 $$p); do printf "="; done; \
if [ $$p -lt 100 ]; then printf ">"; fi; \
for j in $$(seq $$(($$p + 1)) 100); do printf " "; done; \
printf "] $$p%% ($$i/$(1) seconds)"; \
@for i in $$(seq 1 $(1)); do \
echo -en "\r[$$i/$(1)] Waiting..."; \
sleep 1; \
done; \
printf "\n"; \
tput cnorm
echo
endef

# Common directories
Expand All @@ -35,12 +28,13 @@ 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
COMMON_SEPOLIA_CHAIN_ID := 0
COMMON_SEPOLIA_CHAIN_STR := Eth
COMMON_NEAR_CHAIN_STR := Near

# Create required directories
$(common_generated_dir) $(common_near_deploy_results_dir) $(common_evm_deploy_results_dir) $(common_solana_deploy_results_dir):
Expand Down
5 changes: 3 additions & 2 deletions e2e-testing/makefiles/pipelines/bridge_token_near_to_evm.mk
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ $(pipeline1_evm_deploy_token_file): $(pipeline1_log_metadata_file) $(sepolia_bri
$(call description,Bridge NEAR Token to Ethereum. Step 2: Deploying token on Ethereum)
TX_HASH=$$(jq -r .tx_hash $(pipeline1_log_metadata_file)) && \
ETH_BRIDGE_TOKEN_FACTORY_ADDRESS=$$(jq -r .bridgeAddress $(sepolia_bridge_contract_address_file)) && \
bridge-cli testnet omni-connector evm-deploy-token \
bridge-cli testnet omni-connector deploy-token \
--chain $(COMMON_SEPOLIA_CHAIN_STR) \
--source-chain $(COMMON_NEAR_CHAIN_STR) \
--tx-hash $$TX_HASH \
--eth-bridge-token-factory-address $$ETH_BRIDGE_TOKEN_FACTORY_ADDRESS \
--config-file $(common_bridge_sdk_config_file) > $@ && \
Expand All @@ -121,7 +122,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)) && \
Expand Down
4 changes: 2 additions & 2 deletions e2e-testing/tools/src/scripts/deploy-near-contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down

0 comments on commit a6b3499

Please sign in to comment.