Skip to content

Commit c0005af

Browse files
authored
Merge pull request #454 from multiversx/validators_pytest
Added cli validators test in pytest and CI for localnet dependent tests.
2 parents b080e02 + 8d2ee9a commit c0005af

12 files changed

Lines changed: 279 additions & 234 deletions

.github/workflows/build-windows.yml

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -47,13 +47,4 @@ jobs:
4747
shell: bash
4848
run: |
4949
export PYTHONPATH=.
50-
pytest -m "not skip_on_windows" .
51-
- name: Run CLI tests
52-
shell: bash
53-
run: |
54-
export PROXY=https://testnet-gateway.multiversx.com
55-
export CHAIN_ID=T
56-
cd ./multiversx_sdk_cli/tests
57-
source ./test_cli_tx.sh && testAll || return 1
58-
source ./test_cli_dns.sh && testOffline || return 1
59-
source ./test_cli_validators.sh && testAll || return 1
50+
pytest -m "not skip_on_windows and not require_localnet" .

.github/workflows/build.yml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,3 @@ jobs:
4444
run: |
4545
export PYTHONPATH=.
4646
pytest .
47-
- name: Run CLI tests
48-
run: |
49-
cd ./multiversx_sdk_cli/tests
50-
source ./test_cli_contracts.sh && testAll || return 1
51-
source ./test_cli_dns.sh && testOffline || return 1
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Test localnet-dependent tests
2+
3+
on:
4+
pull_request:
5+
branches: [main, feat/*]
6+
workflow_dispatch:
7+
8+
env:
9+
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
10+
11+
jobs:
12+
localnet:
13+
runs-on: ${{ matrix.os }}
14+
strategy:
15+
matrix:
16+
os: [ubuntu-latest, macos-latest]
17+
python-version: [3.11]
18+
19+
steps:
20+
- name: Set up Python ${{ matrix.python-version }}
21+
uses: actions/setup-python@v2
22+
with:
23+
python-version: ${{ matrix.python-version }}
24+
25+
- uses: actions/checkout@v2
26+
- name: Set up Python ${{ matrix.python-version }}
27+
uses: actions/setup-python@v2
28+
with:
29+
python-version: ${{ matrix.python-version }}
30+
31+
- name: Install dependencies
32+
run: |
33+
python3 -m pip install --upgrade pip
34+
pip3 install -r requirements.txt
35+
pip3 install -r ./requirements-dev.txt --upgrade
36+
37+
- name: Set up MultiversX localnet
38+
run: |
39+
mkdir -p ~/multiversx-sdk
40+
export PYTHONPATH=.
41+
python3 -m multiversx_sdk_cli.cli localnet prerequisites --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
42+
python3 -m multiversx_sdk_cli.cli localnet build --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
43+
44+
# "Go" and artifacts from "GOPATH/pkg/mod" are not needed anymore.
45+
sudo rm -rf ~/multiversx-sdk/golang
46+
47+
python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
48+
python3 -m multiversx_sdk_cli.cli localnet config --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
49+
nohup python3 -m multiversx_sdk_cli.cli localnet start --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml > localnet.log 2>&1 & echo $! > localnet.pid
50+
sleep 120
51+
52+
- name: Test localnet dependent tests
53+
run: |
54+
pytest -m require_localnet .
55+
python3 -m multiversx_sdk_cli.cli localnet clean --configfile=./multiversx_sdk_cli/tests/testdata/localnet_with_resolution_remote.toml
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import pytest
2+
3+
4+
# function executed right after test items collected but before test run
5+
def pytest_collection_modifyitems(config, items):
6+
if not config.getoption('-m'):
7+
skip_me = pytest.mark.skip(reason="require_localnet will only run if explicitly set to with -m")
8+
for item in items:
9+
if "require_localnet" in item.keywords:
10+
item.add_marker(skip_me)

multiversx_sdk_cli/tests/test_cli_all.sh

Lines changed: 0 additions & 18 deletions
This file was deleted.

multiversx_sdk_cli/tests/test_cli_config.sh

Lines changed: 0 additions & 14 deletions
This file was deleted.

multiversx_sdk_cli/tests/test_cli_dns.sh

Lines changed: 0 additions & 113 deletions
This file was deleted.

multiversx_sdk_cli/tests/test_cli_tx.sh

Lines changed: 0 additions & 29 deletions
This file was deleted.

0 commit comments

Comments
 (0)