-
Notifications
You must be signed in to change notification settings - Fork 8
143 lines (122 loc) · 4.3 KB
/
e2e_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
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: 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 }}
run: |
echo "PR_NUMBER=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--head ${{ github.ref#refs/head/ }} \
--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: 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
echo "SWARM_PORT=${random_numbers[0]}"
echo "SERVER_PORT=${random_numbers[1]}"
echo "ICP_PORT=${random_numbers[2]}"
# Update JSON file with jq
jq --arg swarmPort "${random_numbers[0]}" \
--arg serverPort "${random_numbers[1]}" \
--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
echo "ICP_PORT=$ICP_PORT" >> $GITHUB_OUTPUT
- 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 }}
run: |
echo "PR_NUMBER=$(gh pr list \
--repo ${{ github.repository }} \
--state open \
--head ${GH_REF#refs/head/} \
--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