Skip to content

Commit

Permalink
Add GA pipeline for E2E tests (without secrets)
Browse files Browse the repository at this point in the history
  • Loading branch information
kisialiou committed Jan 28, 2025
1 parent a7e585b commit 888c707
Show file tree
Hide file tree
Showing 4 changed files with 150 additions and 3 deletions.
44 changes: 44 additions & 0 deletions .github/e2e-setup/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: E2E Setup
description: Setup environment for E2E tests

runs:
using: composite
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
with:
node-version: '16'

- name: Install Yarn
shell: bash
run: sudo npm install -g yarn

- name: Setup Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
toolchain: 1.81.0
target: wasm32-unknown-unknown

- name: Install NEAR CLI
shell: bash
run: |
cargo install --git https://github.com/Near-One/bridge-sdk-rs/ --rev 543a46a bridge-cli
- name: Install optional additional packages
shell: bash
run: |
sudo apt-get update
sudo apt-get install -y jq
- name: Install Solana CLI and Anchor
shell: bash
run: |
sh -c "$(curl -sSfL https://release.anza.xyz/stable/install)"
export PATH="/home/runner/.local/share/solana/install/active_release/bin:$PATH"
cargo install --git https://github.com/coral-xyz/anchor --tag v0.30.1 anchor-cli
- name: Set up Docker
uses: docker/setup-buildx-action@v2
89 changes: 89 additions & 0 deletions .github/workflows/e2e-test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: E2E Tests

on:
workflow_dispatch:
inputs:
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"

jobs:
get-pipelines-matrix:
name: Get Pipelines Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Parse input pipelines and create matrix
id: set-matrix
run: |
# Convert space-separated input into JSON array for matrix
PIPELINES="${{ github.event.inputs.selected_pipelines }}"
JSON_ARRAY=$(echo "$PIPELINES" | jq -R -c 'split(" ")')
echo "matrix={\"pipeline\":$JSON_ARRAY}" >> $GITHUB_OUTPUT
analyze-dependencies:
name: Analyze Dependencies
if: ${{ contains(github.event.inputs.selected_pipelines, ' ') }}
runs-on: ubuntu-latest
outputs:
common_deps: ${{ steps.get_deps.outputs.common_deps }}
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Setup E2E environment
uses: ./.github/e2e-setup

- name: Get dependencies for each pipeline
id: get_deps
run: |
COMMON_DEPS=$(./e2e-testing/tools/src/scripts/get_common_dependencies.sh ./e2e-testing/Makefile ${{ github.event.inputs.selected_pipelines }})
echo "common_deps=$COMMON_DEPS" >> $GITHUB_OUTPUT
- name: Build common dependencies
run: |
echo "Building common dependencies"
if [ -n "${{ steps.get_deps.outputs.common_deps }}" ]; then
make ${{ steps.get_deps.outputs.common_deps }}
fi
- name: Upload common dependencies
uses: actions/upload-artifact@v3
with:
name: common-dependencies
path: |
e2e-testing/generated/*
run-tests:
needs: [get-pipelines-matrix, analyze-dependencies]
if: ${{ always() && needs.analyze-dependencies.result != 'failure' }}
name: Run ${{ matrix.pipeline }}
runs-on: ubuntu-latest
strategy:
matrix: ${{fromJson(needs.get-pipelines-matrix.outputs.matrix)}}
fail-fast: false
steps:
- name: Check out repository
uses: actions/checkout@v3

- name: Setup E2E environment
uses: ./.github/e2e-setup

- name: Download common dependencies
uses: actions/download-artifact@v3
with:
name: common-dependencies

- name: Run pipeline
run: |
echo "Running pipeline: ${{ matrix.pipeline }}"
make ${{ matrix.pipeline }}
- name: Upload test artifacts
uses: actions/upload-artifact@v3
with:
name: e2e-test-results-${{ matrix.pipeline }}
path: |
e2e-testing/generated/*.json
3 changes: 0 additions & 3 deletions e2e-testing/tools/src/lib/near.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@ import { connect, providers } from 'near-api-js';
import type { TokenMetadata } from './types';
import { VerificationError } from './types';

// TODO: define config globally or through some class.
// TODO: try avoiding using KeyStore as the calls are view only.

class NearClient {
private provider: providers.JsonRpcProvider;

Expand Down
17 changes: 17 additions & 0 deletions e2e-testing/tools/src/scripts/get_common_dependencies.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
#!/usr/bin/env bash

makefile="$1"
shift
selected_pipelines="$@"

if [ $(echo "$selected_pipelines" | wc -w) -eq 1 ]; then
exit 0
fi

for pipeline in $selected_pipelines; do
make -f "$makefile" -nd "$pipeline" 2> /dev/null | \
grep -E 'Must remake target|File .* was considered already' | \
sed -E \
-e "s/.*Must remake target '([^']+)'.*/\1/" \
-e "s/.*File '([^']+)' was considered already.*/\1/" | uniq
done | sort | uniq -c | awk -v count="$(echo "$selected_pipelines" | wc -w)" '$1 == count {print $2}' | paste -sd " "

0 comments on commit 888c707

Please sign in to comment.