Skip to content

fix(e2e-tests): fix merod port issue, pass PR number to update PR com… #392

fix(e2e-tests): fix merod port issue, pass PR number to update PR com…

fix(e2e-tests): fix merod port issue, pass PR number to update PR com… #392

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:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: Prepare e2e-tests config
id: prepare_e2e_tests_config
run: |
# Generate 4 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
# Export random numbers to environment variables
SWARM_PORT="${random_numbers[0]}"
SERVER_PORT="${random_numbers[1]}"
ICP_PORT="${random_numbers[2]}"
echo "SWARM_PORT=$SWARM_PORT" >> $GITHUB_OUTPUT
echo "SERVER_PORT=$SERVER_PORT" >> $GITHUB_OUTPUT
echo "ICP_PORT=$ICP_PORT" >> $GITHUB_OUTPUT
# Update JSON file with jq
jq --arg swarmPort "$SWARM_PORT" \
--arg serverPort "$SERVER_PORT" \
--arg icpPort "${random_numbers[2]}" \
'.network.startSwarmPort = ($swarmPort | tonumber) |
.network.startServerPort = ($serverPort | tonumber) |
.protocolSandboxes[1].config.rpcUrl = "http://127.0.0.1:\($icpPort)"
' e2e-tests/config/config.json > updated_config.json
mv updated_config.json e2e-tests/config/config.json
- name: Show ports
env:
SWARM_PORT: ${{ steps.prepare_e2e_tests_config.outputs.SWARM_PORT }}
SERVER_PORT: ${{ steps.prepare_e2e_tests_config.outputs.SERVER_PORT }}
ICP_PORT: ${{ steps.prepare_e2e_tests_config.outputs.ICP_PORT }}
run: |
echo "SWARM_PORT=$SWARM_PORT"
echo "SERVER_PORT=$SERVER_PORT"
echo "ICP_PORT=$ICP_PORT"
- name: Checkout code
uses: actions/checkout@v4
- name: Setup rust toolchain
run: rustup toolchain install stable --profile minimal
- name: Setup rust cache
uses: Swatinem/rust-cache@v2
with:
cache-on-failure: true
cache-all-crates: true # due to candid-extractor
- name: Install dfx
uses: dfinity/setup-dfx@main
- name: Get PR number test
if: success() || failure()
env:
GH_TOKEN: ${{ github.token }}
GH_REF: ${{ github.ref }}
shell: bash
run: |
A="${GH_REF#refs/heads/}"
echo "A=$A"
gh pr list \
--repo ${{ github.repository }} \
--state open \
--head "$A" \
--base master \
--json number \
-q '.[0].number'
echo "PR_NUMBER=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--head "${GH_REF#refs/heads/}" \
--base master \
--json number \
-q '.[0].number')"
- name: Build apps
run: |
./apps/kv-store/build.sh
- name: Build contracts
run: |
./contracts/near/context-config/build.sh
./contracts/near/context-proxy/build.sh
- name: Build binaries
run: |
cargo build -p meroctl -p merod -p e2e-tests
- name: Deploy ICP local devnet
env:
ICP_PORT: ${{ steps.prepare_e2e_tests_config.outputs.ICP_PORT }}
run: |
cargo install candid-extractor
cd ./contracts/icp/context-config
./deploy_devnet.sh
cd ../../..
- name: Run e2e tests
env:
NO_COLOR: '1'
# RUST_LOG: calimero_node=debug,calimero_network=debug
run: |
export SWARM_HOST=$(ifconfig | grep 'inet ' | grep -v '127.0.0.1' | awk '{print $2}' | head -n 1)
echo "Running e2e tests, check job summary for details"
./target/debug/e2e-tests \
--input-dir ./e2e-tests/config \
--output-dir ./e2e-tests/corpus \
--merod-binary ./target/debug/merod \
--meroctl-binary ./target/debug/meroctl
- name: Get PR number
id: pr_number
if: success() || failure()
env:
GH_TOKEN: ${{ github.token }}
GH_REF: ${{ github.ref }}
shell: bash
run: |
A="${GH_REF#refs/heads/}"
echo "A=$A"
gh pr list \
--repo ${{ github.repository }} \
--state open \
--head "$A" \
--base master \
--json number \
-q '.[0].number'
echo "PR_NUMBER=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--head "${GH_REF#refs/heads/}" \
--base master \
--json number \
-q '.[0].number')" >> $GITHUB_OUTPUT
- name: Update pull request comment
if: (success() || failure()) && steps.pr_number.outputs.PR_NUMBER != ''
uses: thollander/actions-comment-pull-request@v3
with:
file-path: ./e2e-tests/corpus/report.md
pr-number: ${{ steps.pr_number.outputs.PR_NUMBER }}
- name: Upload artifacts
if: success() || failure()
uses: actions/upload-artifact@v4
with:
name: e2e-tests-corpus
path: e2e-tests/corpus/
retention-days: 2