-
Notifications
You must be signed in to change notification settings - Fork 48
92 lines (77 loc) · 2.73 KB
/
Copy pathtest-localnet.yml
File metadata and controls
92 lines (77 loc) · 2.73 KB
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
name: MultiversX Integration Tests
on:
push:
branches:
- main
pull_request:
permissions:
contents: read
jobs:
integration_tests:
runs-on: ubuntu-latest
steps:
# Install system dependencies
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libusb-1.0-0-dev libudev-dev pkg-config
# Step 1: Checkout the repository
- name: Checkout code
uses: actions/checkout@v3
# Step 2: Set up Python environment
- name: Set up Python 3.11
uses: actions/setup-python@v4
with:
python-version: '3.11'
# Step 3: Install pipx (to manage Python tools)
- name: Install pipx
run: |
python3 -m pip install --user pipx
python3 -m pipx ensurepath
# Add the pipx binary location to PATH
echo "$HOME/.local/bin" >> $GITHUB_PATH
shell: bash
# Step 4: Install mxpy (MultiversX Python SDK)
- name: Install mxpy (MultiversX SDK)
run: |
pipx install multiversx-sdk-cli --force
# Step 5: Set up MultiversX localnet using mxpy
- name: Set up MultiversX localnet
run: |
# Start the local testnet with mxpy
mkdir -p ~/localnet && cd ~/localnet
mxpy localnet setup --configfile=${GITHUB_WORKSPACE}/localnet.toml
echo "Localnet setup completed."
echo "Starting localnet..."
nohup mxpy localnet start --configfile=${GITHUB_WORKSPACE}/localnet.toml > localnet.log 2>&1 & echo $! > localnet.pid
echo "Localnet started, waiting for it to be fully operational..."
# Allow time for the testnet to fully start
timeout=300
elapsed=0
while ! curl -s http://127.0.0.1:7950/network/config > /dev/null; do
if [ $elapsed -ge $timeout ]; then
echo "Timeout waiting for localnet to start"
cat ~/localnet/localnet.log
exit 1
fi
echo "Waiting for localnet... ($elapsed/$timeout seconds)"
sleep 10
elapsed=$((elapsed + 10))
done
echo "Localnet is ready!"
# Step 6: Install Node.js and dependencies
- name: Set up Node.js environment
uses: actions/setup-node@v3
with:
node-version: '16.x'
- name: Install Node.js dependencies
run: npm install
# Step 7: Run integration tests
- name: Run integration tests
run: |
npm run tests-localnet
# Step 8: Stop the testnet using the stored PID
- name: Stop MultiversX local testnet
if: success() || failure()
run: |
kill $(cat localnet.pid) || echo "Testnet already stopped"