Skip to content

feat(network): implement actor model #699

feat(network): implement actor model

feat(network): implement actor model #699

Workflow file for this run

name: End-to-end tests
on:
push:
branches:
- '**'
paths:
- Cargo.toml
- Cargo.lock
- 'contracts/**'
- 'crates/**'
- 'e2e-tests/**'
- '.github/workflows/e2e_tests.yml'
jobs:
build:
name: Build Apps & Binaries
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Rust & Cache
uses: dtolnay/rust-toolchain@stable
- name: Cache Rust dependencies
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
cache-all-crates: true
- name: Build Apps & Binaries
run: |
./apps/kv-store/build.sh
cargo build -p meroctl -p merod -p e2e-tests
- name: Upload Build Artifacts (Binaries)
uses: actions/upload-artifact@v4
with:
name: resources
path: |
target/debug/meroctl
target/debug/merod
target/debug/e2e-tests
apps/kv-store/res/kv_store.wasm
retention-days: 2
test:
needs: build
name: "Test ${{ matrix.protocol }}"
runs-on: ubuntu-latest
strategy:
matrix:
protocol: [near, icp, stellar]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Artifacts
uses: actions/download-artifact@v4
with:
name: resources
path: .
- name: Set Permissions
run: |
chmod +x target/debug/e2e-tests target/debug/merod target/debug/meroctl
- name: Generate ports
id: generate_ports
run: |
# Generate unique random numbers
random_numbers=()
while [ ${#random_numbers[@]} -lt 3 ]; do
num=$((RANDOM%37001 + 3000))
if [[ ! " ${random_numbers[@]} " =~ " ${num} " ]]; then
random_numbers+=($num)
fi
done
echo "Random numbers: ${random_numbers[@]}"
SWARM_PORT="${random_numbers[0]}"
SERVER_PORT="${random_numbers[1]}"
ICP_PORT="${random_numbers[2]}"
SWARM_HOST=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | head -n 1)
echo "SWARM_PORT=$SWARM_PORT" >> $GITHUB_OUTPUT
echo "SERVER_PORT=$SERVER_PORT" >> $GITHUB_OUTPUT
echo "ICP_PORT=$ICP_PORT" >> $GITHUB_OUTPUT
echo "SWARM_HOST=$SWARM_HOST" >> $GITHUB_OUTPUT
# Update config.json
jq --arg swarmPort "$SWARM_PORT" \
--arg serverPort "$SERVER_PORT" \
--arg swarmHost "$SWARM_HOST" \
'.network.swarmHost = ($swarmHost) |
.network.startSwarmPort = ($swarmPort | tonumber) |
.network.startServerPort = ($serverPort | tonumber)' \
e2e-tests/config/config.json > updated_config.json
mv updated_config.json e2e-tests/config/config.json
- name: Build Contracts (if needed)
run: |
if [[ "${{ matrix.protocol }}" == "near" ]]; then
./contracts/near/context-config/build.sh
./contracts/near/context-proxy/build.sh
elif [[ "${{ matrix.protocol }}" == "stellar" ]]; then
./contracts/stellar/context-config/build.sh
./contracts/stellar/context-proxy/build.sh
fi
- name: Install dfx
if: matrix.protocol == 'icp'
uses: dfinity/setup-dfx@main
- name: Deploy Local Devnet (if needed)
env:
ICP_PORT: ${{ steps.generate_ports.outputs.ICP_PORT }}
run: |
if [[ "${{ matrix.protocol }}" == "icp" ]]; then
TMPDIR=$(mktemp -d)
VERSION="0.1.5"
# Download prebuilt binary based on platform
case "$(uname -s)-$(uname -m)" in
"Linux-x86_64")
BINARY="candid-extractor-x86_64-unknown-linux-gnu.tar.gz"
;;
"Darwin-x86_64")
BINARY="candid-extractor-x86_64-apple-darwin.tar.gz"
;;
*)
echo "Unsupported platform"
exit 1
;;
esac
wget -P "$TMPDIR" "https://github.com/dfinity/candid-extractor/releases/download/${VERSION}/${BINARY}"
tar xzf "$TMPDIR/$BINARY" -C "$TMPDIR"
mkdir -p "$HOME/.local/bin"
mv "$TMPDIR/candid-extractor" "$HOME/.local/bin/"
rm -rf "$TMPDIR"
# Add to PATH if not already there
export PATH="$HOME/.local/bin:$PATH"
echo "ICP_PORT=$ICP_PORT"
pushd ./contracts/icp/context-config
./deploy_devnet.sh
popd
jq --arg icpPort "$ICP_PORT" \
'.protocolSandboxes[1].config.rpcUrl = "http://127.0.0.1:\($icpPort)"' \
e2e-tests/config/config.json > tmp.json && mv tmp.json e2e-tests/config/config.json
elif [[ "${{ matrix.protocol }}" == "stellar" ]]; then
echo "Installing stellar CLI..."
# Detect OS and architecture
OS=$(uname -s)
ARCH=$(uname -m)
# Map OS and architecture to release file names
case "$OS-$ARCH" in
"Linux-x86_64")
BINARY_NAME="stellar-cli-22.2.0-x86_64-unknown-linux-gnu.tar.gz"
;;
"Linux-aarch64"|"Linux-arm64")
BINARY_NAME="stellar-cli-22.2.0-aarch64-unknown-linux-gnu.tar.gz"
;;
*)
echo "Unsupported platform: $OS-$ARCH"
exit 1
;;
esac
TMPDIR=$(mktemp -d)
wget -P "$TMPDIR" "https://github.com/stellar/stellar-cli/releases/download/v22.2.0/${BINARY_NAME}"
tar xzf "${TMPDIR}/${BINARY_NAME}" -C "$TMPDIR"
mkdir -p "$HOME/.local/bin"
chmod +x "$TMPDIR/stellar"
mv "$TMPDIR/stellar" "$HOME/.local/bin/"
rm -rf "$TMPDIR"
export PATH="$HOME/.local/bin:$PATH"
chmod +x ./contracts/stellar/context-config/deploy_devnet.sh
./contracts/stellar/context-config/deploy_devnet.sh > env_output.txt
CONTRACT_ID=$(grep "Contract ID:" env_output.txt | awk '{print $3}')
ACCOUNT_ADDRESS=$(grep "Account address:" env_output.txt | awk '{print $3}')
SECRET_KEY=$(grep "Secret key:" env_output.txt | awk '{print $3}')
jq --arg contractId "$CONTRACT_ID" \
--arg publicKey "$ACCOUNT_ADDRESS" \
--arg secretKey "$SECRET_KEY" \
'.protocolSandboxes[2].config.contextConfigContractId = $contractId |
.protocolSandboxes[2].config.publicKey = $publicKey |
.protocolSandboxes[2].config.secretKey = $secretKey' \
e2e-tests/config/config.json > tmp.json && mv tmp.json e2e-tests/config/config.json
fi
- name: Run e2e Tests
id: e2e-tests
env:
NO_COLOR: '1'
continue-on-error: true
run: |
export SWARM_HOST=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | head -n 1)
echo "Running e2e tests for ${{ matrix.protocol }}"
./target/debug/e2e-tests \
--input-dir ./e2e-tests/config \
--output-dir ./e2e-tests/corpus \
--merod-binary ./target/debug/merod \
--meroctl-binary ./target/debug/meroctl \
--protocols ${{ matrix.protocol }}
- name: Upload Test Artifacts
uses: actions/upload-artifact@v4
with:
name: e2e-tests-${{ matrix.protocol }}
path: e2e-tests/corpus/
retention-days: 2
- name: Fail on Test Failures
shell: bash
if: |
steps.e2e-tests.outcome == 'failure'
run: exit 1
- name: Upload test report
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: e2e-test-report-${{ matrix.protocol }}
path: e2e-tests/corpus/report.md
retention-days: 1
comment:
needs: test
runs-on: ubuntu-latest
if: success()
steps:
- name: Download all reports
uses: actions/download-artifact@v4
with:
pattern: e2e-test-report-*
merge-multiple: false
path: reports/
- name: Combine reports
run: |
mkdir -p reports
{
echo "# E2E Test Results"
echo
echo "### Scenario: kv-store"
echo
echo "| Protocol/Step | 0. app install (AllMembers) | 1. ctx create | 2. call (set, Inviter) | 3. call (get, Inviter) | 4. ctx invite-join | 5. call (get, AllMembers) |"
echo "| :--- | :---: | :---: | :---: | :---: | :---: | :---: |"
# Debug: List all report files
echo "Found report files:" >> /dev/stderr
find reports/ -type f -name "report.md" -ls >> /dev/stderr
# Process each protocol's report
for protocol in near icp stellar; do
if [ -f "reports/e2e-test-report-${protocol}/report.md" ]; then
grep "^|" "reports/e2e-test-report-${protocol}/report.md" | \
grep -v "Protocol/Step" | \
grep -v ":---"
fi
done
} > combined_report.md
# Debug: Show final report content
echo "Combined report content:" >> /dev/stderr
cat combined_report.md >> /dev/stderr
- name: Get PR number
id: pr_number
env:
GH_TOKEN: ${{ github.token }}
GH_REF: ${{ github.ref }}
shell: bash
run: |
echo "PR_NUMBER=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--head "${GH_REF#refs/heads/}" \
--json number \
-q '.[0].number')" >> $GITHUB_OUTPUT
- name: Update pull request comment
uses: thollander/actions-comment-pull-request@v3
if: steps.pr_number.outputs.PR_NUMBER != ''
with:
file-path: ./combined_report.md
pr-number: ${{ steps.pr_number.outputs.PR_NUMBER }}
comment-tag: e2e-tests-report
mode: recreate