Skip to content

Commit

Permalink
feat(ci): per provider integration tests (#465)
Browse files Browse the repository at this point in the history
* feat: adding README.md for the functional tests directory

* feat: converting providers test names and ignoring by default

* feat: adding sub-providers.yml workflow

* feat: changing to use matrix instead of iterating
  • Loading branch information
geekbrother authored Jan 15, 2024
1 parent ded3458 commit 36e3652
Show file tree
Hide file tree
Showing 9 changed files with 126 additions and 7 deletions.
95 changes: 95 additions & 0 deletions .github/workflows/sub-providers.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
name: ❖ Providers

on:
workflow_dispatch:
inputs:
providers:
description: 'Providers list to test (space separated)'
required: false
default: 'coinbase binance'
stage-url:
description: 'RPC URL'
required: false
default: 'https://staging.rpc.walletconnect.org/'
workflow_call:
inputs:
providers_directory:
type: string
required: true
description: 'Directory where providers sources are located'
stage-url:
type: string
required: true
description: 'Stage RPC URL'
default: 'https://staging.rpc.walletconnect.org/'

concurrency: cd

permissions:
contents: write
checks: write
id-token: write

jobs:
providers-list:
name: "Preparing providers list"
runs-on: ubuntu-latest
outputs:
providers: ${{ steps.set-matrix.outputs.providers }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch-depth: 2
- name: Creating list of changed providers
id: set-matrix
run: |
if [[ -n "${{ github.event.inputs.providers }}" ]]; then
PROVIDERS_LIST="${{ github.event.inputs.providers }}"
else
PROVIDERS_DIR="${{ inputs.providers_directory }}"
CHANGED_FILES=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }})
PROVIDERS_LIST=""
for file in $CHANGED_FILES; do
if [[ $file == $PROVIDERS_DIR* ]]; then
PROVIDER_TEST_NAME=$(echo $file | sed "s|^$PROVIDERS_DIR||" | sed 's|/|::|g' | sed 's|\.rs$||')
PROVIDERS_LIST+="$PROVIDER_TEST_NAME "
fi
done
PROVIDERS_LIST="${PROVIDERS_LIST% }"
fi
JSON_FMT=$(printf '[%s]' "$(echo $PROVIDERS_LIST | awk '{for(i=1;i<=NF;i++) printf "\"%s\",", $i}' | sed 's/,$//')")
echo "providers=$JSON_FMT" >> $GITHUB_OUTPUT
- name: Print list of changed providers
run: |
echo "Providers matrix: ${{ steps.set-matrix.outputs.providers }}"
providers-test:
name: "Run provider tests"
needs: providers-list
runs-on: ubuntu-latest
if: needs.providers-list.outputs.providers != '[]'
strategy:
fail-fast: false
matrix:
provider: ${{fromJson(needs.providers-list.outputs.providers)}}
steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: "Install Rust ${{ vars.RUST_VERSION }}"
uses: WalletConnect/actions-rs/[email protected]
with:
toolchain: ${{ vars.RUST_VERSION }}
profile: 'default'
override: true

- name: Run Tests for ${{ matrix.provider }}
env:
PROJECT_ID: ${{ secrets.PROJECT_ID }}
RPC_URL: ${{ inputs.stage-url }}
run: |
cargo test ${{ matrix.provider }}_provider -- --ignored
18 changes: 18 additions & 0 deletions tests/functional/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Functional integration tests

The following functional integration tests are presented:

* Database tests
* Providers tests
* Providers functional tests should be `#[ignore]` by default, because they will run by
the CI workflow specifically when the providers code is changed in the `src/provider`
directory.
* Providers test names should be in the format `{provider_name}_provider` and
`{provider_name}_provider_*` aligning with the provider name file in the
`src/providers` directory.
* Example for the `coinbase` provider:
* Implementation source file: `src/provider/coinbase.rs`
Tests for the `coinbase` provider will run only if this file is changed.
* Tests implementation for the `coinbase` provider can be in any files but should be
`#[ignore]` by default and the test names must starts with the
`coinbase_provider`.
3 changes: 2 additions & 1 deletion tests/functional/http/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use {

#[test_context(ServerContext)]
#[tokio::test]
async fn eip155_8453_base(ctx: &mut ServerContext) {
#[ignore]
async fn base_provider_eip155_8453_and_84531(ctx: &mut ServerContext) {
// Base mainnet
check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:8453", "0x2105").await;

Expand Down
3 changes: 2 additions & 1 deletion tests/functional/http/binance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use {

#[test_context(ServerContext)]
#[tokio::test]
async fn binance_provider(ctx: &mut ServerContext) {
#[ignore]
async fn binance_provider_eip155_56_and_97(ctx: &mut ServerContext) {
// Binance mainnet
check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:56", "0x38").await;

Expand Down
3 changes: 2 additions & 1 deletion tests/functional/http/pokt.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ use {

#[test_context(ServerContext)]
#[tokio::test]
async fn pokt_provider(ctx: &mut ServerContext) {
#[ignore]
async fn pokt_provider_eip155_43114_and_56_and_100(ctx: &mut ServerContext) {
// Avax
check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:43114", "0xa86a").await;

Expand Down
3 changes: 2 additions & 1 deletion tests/functional/http/zksync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use {

#[test_context(ServerContext)]
#[tokio::test]
async fn eip155_324_zksync_mainnet(ctx: &mut ServerContext) {
#[ignore]
async fn zksync_provider_eip155_324_and_280(ctx: &mut ServerContext) {
// ZkSync mainnet
check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:324", "0x144").await;

Expand Down
3 changes: 2 additions & 1 deletion tests/functional/http/zora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use {

#[test_context(ServerContext)]
#[tokio::test]
async fn eip155_7777777_zora(ctx: &mut ServerContext) {
#[ignore]
async fn zora_provider_eip155_7777777_and_999(ctx: &mut ServerContext) {
// Zora mainnet
check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:7777777", "0x76adf1")
.await;
Expand Down
2 changes: 1 addition & 1 deletion tests/functional/websocket/infura.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ use {
#[test_context(ServerContext)]
#[tokio::test]
#[ignore]
async fn infura_websocket_provider(ctx: &mut ServerContext) {
async fn infura_provider_websocket(ctx: &mut ServerContext) {
// Ethereum mainnet
check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:1", "0x1").await;

Expand Down
3 changes: 2 additions & 1 deletion tests/functional/websocket/zora.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ use {

#[test_context(ServerContext)]
#[tokio::test]
async fn zora_websocket_provider(ctx: &mut ServerContext) {
#[ignore]
async fn zora_provider_websocket(ctx: &mut ServerContext) {
// Zora mainnet
check_if_rpc_is_responding_correctly_for_supported_chain(ctx, "eip155:7777777", "0x76adf1")
.await;
Expand Down

0 comments on commit 36e3652

Please sign in to comment.