Skip to content

Commit

Permalink
fix(e2e-tests): fix port allocations, cleanup report format
Browse files Browse the repository at this point in the history
  • Loading branch information
fbozic committed Jan 14, 2025
1 parent 7d5010d commit 5c7ab8a
Show file tree
Hide file tree
Showing 16 changed files with 273 additions and 195 deletions.
86 changes: 62 additions & 24 deletions .github/workflows/e2e_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ jobs:
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
Expand All @@ -45,8 +46,43 @@ jobs:
run: |
cargo build -p meroctl -p merod -p e2e-tests
- 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: Deploy ICP local devnet
env:
ICP_PORT: ${{ steps.prepare_e2e_tests_config.outputs.ICP_PORT }}
run: |
echo "ICP_PORT=$ICP_PORT"
cargo install candid-extractor
cd ./contracts/icp/context-config
./deploy_devnet.sh
Expand All @@ -60,39 +96,41 @@ jobs:
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"
echo "# E2E tests 🏗️" >> $GITHUB_STEP_SUMMARY
./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: Update pull request comment
- name: Get PR number
id: pr_number
if: success() || failure()
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/}" \
--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 }}
comment-tag: e2e-tests-report
mode: recreate

- name: Show node logs
- name: Upload artifacts
if: success() || failure()
run: |
LOGS_DIR=./e2e-tests/corpus/logs
if [ ! -d "$LOGS_DIR" ]; then
echo "Directory $LOGS_DIR does not exist."
exit 1
fi
echo "# Node logs 📋" >> $GITHUB_STEP_SUMMARY
for FOLDER in "$LOGS_DIR"/*; do
if [ -d "$FOLDER" ]; then
RUN_LOG="$FOLDER/run.log"
if [ -f "$RUN_LOG" ]; then
echo "## Node logs: $(basename $FOLDER) 📋" >> $GITHUB_STEP_SUMMARY
cat "$RUN_LOG" >> $GITHUB_STEP_SUMMARY
else
echo "## No run.log found in $FOLDER ⚠️" >> $GITHUB_STEP_SUMMARY
fi
fi
done
uses: actions/upload-artifact@v4
with:
name: e2e-tests-corpus
path: e2e-tests/corpus/
retention-days: 2
2 changes: 1 addition & 1 deletion contracts/icp/context-config/deploy_devnet.sh
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ RECIPIENT_PRINCIPAL=$(dfx identity get-principal)
dfx identity use default

# Start dfx with clean state
dfx start --clean --background
dfx start --clean --background --host 127.0.0.1:"${ICP_PORT:-4943}"

# Create initial identity if needed
dfx identity new --storage-mode=plaintext minting || true
Expand Down
6 changes: 3 additions & 3 deletions e2e-tests/config/scenarios/kv-store/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,15 @@
"contextCreate": null
},
{
"jsonRpcCall": {
"call": {
"methodName": "set",
"argsJson": { "key": "foo", "value": "bar" },
"expectedResultJson": null,
"target": "inviter"
}
},
{
"jsonRpcCall": {
"call": {
"methodName": "get",
"argsJson": { "key": "foo" },
"expectedResultJson": "bar",
Expand All @@ -29,7 +29,7 @@
"contextInviteJoin": null
},
{
"jsonRpcCall": {
"call": {
"methodName": "get",
"argsJson": { "key": "foo" },
"expectedResultJson": "bar",
Expand Down
Loading

0 comments on commit 5c7ab8a

Please sign in to comment.