Skip to content

Commit

Permalink
Github actions implementation_dev (#47)
Browse files Browse the repository at this point in the history
* push actual test_sdk_client.py version to the dev branch

* yml

* Rename main.yml to master.yml

* Update reset_environment.sh

* Update run_all_functional.sh

* Update reset_environment.sh

* Update dev.yml

* Update dev.yml

* Update master.yml

* Update reset_environment.sh

* test

* Update master.yml

* Update dev.yml

---------

Co-authored-by: Pavel Yagunov <[email protected]>
Co-authored-by: Valery Geraskin <[email protected]>
Co-authored-by: PAY2109 <[email protected]>
  • Loading branch information
4 people authored Jun 20, 2024
1 parent 29788fe commit 3f4b03f
Show file tree
Hide file tree
Showing 5 changed files with 185 additions and 33 deletions.
76 changes: 76 additions & 0 deletions .github/workflows/dev.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
name: tests_development
on:
# push:
# branches: [ "development" ]
pull_request:
branches: [ "development" ]
workflow_dispatch:

jobs:
run_tests_development:
runs-on: ubuntu-latest
container: node:20-bookworm
steps:

- name: install packs
run: |
apt update
apt install -y libudev-dev libusb-1.0-0-dev curl jq
apt install -y python3-pip python3.11-venv
echo DEV
- name: install ipfs
run: |
wget https://dist.ipfs.io/go-ipfs/v0.9.0/go-ipfs_v0.9.0_linux-amd64.tar.gz
tar -xvzf go-ipfs_v0.9.0_linux-amd64.tar.gz
bash go-ipfs/install.sh
ipfs --version
node --version
- name: clone repo
uses: actions/checkout@v3

# - name: install platform-contracts
# run: |
# cd ..
# git clone https://github.com/singnet/platform-contracts.git
# cd platform-contracts
# npm install
# npm install ganache-cli
# npm run-script compile

# - name: build example service
# run: |
# git clone https://github.com/singnet/example-service.git
# cd example-service
# pip3 install -r requirements.txt --break-system-packages
# sh buildproto.sh

- name: Set up for snet daemon
run: |
cd ..
mkdir snet-daemon
cd snet-daemon
wget https://github.com/singnet/snet-daemon/releases/download/v5.0.1/snet-daemon-v5.0.1-linux-amd64.tar.gz
tar -xvf snet-daemon-v5.0.1-linux-amd64.tar.gz
cd snet-daemon-v5.0.1-linux-amd64
cp ../../snet-sdk-python/testcases/functional_tests/snetd.config.json .
- name: install pip packages
run: |
pip3 install -r requirements.txt --break-system-packages
# mkdir ~/.snet
# cp ./testcases/utils/config ~/.snet/
# cat ~/.snet/config
- name: install snet-sdk
run: pip3 install -e . --break-system-packages

- name: functional tests for sdk
run: |
export SNET_TEST_WALLET_PRIVATE_KEY=${{ secrets.PRIV_KEY }}
export SNET_TEST_INFURA_KEY=${{ secrets.INF_KEY }}
export FORMER_SNET_TEST_INFURA_KEY=${{ secrets.FORM_INF_KEY }}
export PIP_BREAK_SYSTEM_PACKAGES=1
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
sh -ex ./testcases/utils/run_all_functional.sh
77 changes: 77 additions & 0 deletions .github/workflows/master.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: tests_master
on:
# push:
# branches: [ "master" ]
pull_request:
branches: [ "master" ]
workflow_dispatch:

jobs:
run_tests_master:
runs-on: ubuntu-latest
container: node:20-bookworm
steps:

- name: install packs
run: |
apt update
apt install -y libudev-dev libusb-1.0-0-dev curl jq
apt install -y python3-pip python3.11-venv
echo MASTER
- name: install ipfs
run: |
wget https://dist.ipfs.io/go-ipfs/v0.9.0/go-ipfs_v0.9.0_linux-amd64.tar.gz
tar -xvzf go-ipfs_v0.9.0_linux-amd64.tar.gz
bash go-ipfs/install.sh
ipfs --version
node --version
- name: clone repo
uses: actions/checkout@v3

# - name: install platform-contracts
# run: |
# cd ..
# git clone https://github.com/singnet/platform-contracts.git
# cd platform-contracts
# npm install
# npm install ganache-cli
# npm run-script compile

# - name: build example service
# run: |
# git clone https://github.com/singnet/example-service.git
# cd example-service
# pip3 install -r requirements.txt --break-system-packages
# sh buildproto.sh


- name: Set up for snet daemon
run: |
cd ..
mkdir snet-daemon
cd snet-daemon
wget https://github.com/singnet/snet-daemon/releases/download/v5.0.1/snet-daemon-v5.0.1-linux-amd64.tar.gz
tar -xvf snet-daemon-v5.0.1-linux-amd64.tar.gz
cd snet-daemon-v5.0.1-linux-amd64
cp ../../snet-sdk-python/testcases/functional_tests/snetd.config.json .
- name: install pip packages
run: |
pip3 install -r requirements.txt --break-system-packages
# mkdir ~/.snet
# cp ./testcases/utils/config ~/.snet/
# cat ~/.snet/config
- name: install snet-sdk
run: pip3 install -e . --break-system-packages

- name: functional tests for sdk
run: |
export SNET_TEST_WALLET_PRIVATE_KEY=${{ secrets.PRIV_KEY }}
export SNET_TEST_INFURA_KEY=${{ secrets.INF_KEY }}
export FORMER_SNET_TEST_INFURA_KEY=${{ secrets.FORM_INF_KEY }}
export PIP_BREAK_SYSTEM_PACKAGES=1
export PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION=python
sh -ex ./testcases/utils/run_all_functional.sh
3 changes: 2 additions & 1 deletion testcases/functional_tests/test_sdk_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,6 @@ def get_test_service_data():
org_id = "26072b8b6a0e448180f8c0e702ab6d2f"
service_id = "Exampleservice"
group_name = "default_group"

config = {
"private_key": os.environ['SNET_TEST_WALLET_PRIVATE_KEY'],
"eth_rpc_endpoint": f"https://sepolia.infura.io/v3/{os.environ['SNET_TEST_INFURA_KEY']}",
Expand All @@ -105,6 +104,8 @@ def get_test_service_data():
"service_id": service_id,
"identity_name": "test",
"identity_type": "key",
"network": "sepolia",
"force_update": False
}

snet_sdk = sdk.SnetSDK(config)
Expand Down
54 changes: 26 additions & 28 deletions testcases/utils/reset_environment.sh
Original file line number Diff line number Diff line change
Expand Up @@ -25,42 +25,43 @@ nohup ipfs daemon >ipfs.log 2>&1 &

# II. restart ganache and remigrate platform-contracts
killall node || echo "supress an error"

cd ../platform-contracts
nohup ./node_modules/.bin/ganache-cli --mnemonic 'gauge enact biology destroy normal tunnel slight slide wide sauce ladder produce' --networkId 829257324 >/dev/null &
./node_modules/.bin/truffle migrate --network local

######################
# III. remove old snet-cli configuration
rm -rf ~/.snet

# IV. Configure SNET-CLI.
# # IV. Configure SNET-CLI.

# set correct ipfs endpoint
# (the new new configuration file with default values will be created automatically)
snet set default_ipfs_endpoint http://localhost:5002
# # set correct ipfs endpoint
# # (the new new configuration file with default values will be created automatically)
# snet set default_ipfs_endpoint http://localhost:5002

# Add local network and switch to it
snet network create local http://localhost:8545
# # Add local network and switch to it
# snet network create local http://localhost:8545

# swith to local network
snet network local
# # swith to local network
# snet network local

# Configure contract addresses for local network (it will not be necessary for goerli or mainnet! )
snet set current_singularitynettoken_at 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14
snet set current_registry_at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2
snet set current_multipartyescrow_at 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e
# # Configure contract addresses for local network (it will not be necessary for goerli or mainnet! )
# snet set current_singularitynettoken_at 0x6e5f20669177f5bdf3703ec5ea9c4d4fe3aabd14
# snet set current_registry_at 0x4e74fefa82e83e0964f0d9f53c68e03f7298a8b2
# snet set current_multipartyescrow_at 0x5c7a4290f6f8ff64c69eeffdfafc8644a4ec3a4e

# Create First identity (snet-user = first ganache).
# (snet will automatically swith to this new identity)
snet identity create snet-user rpc --network local
# # Create First identity (snet-user = first ganache).
# # (snet will automatically swith to this new identity)
# snet identity create snet-user rpc --network local
snet identity create --private-key "$SNET_TEST_WALLET_PRIVATE_KEY" test key --network sepolia
sed -i "s/$FORMER_SNET_TEST_INFURA_KEY/$SNET_TEST_INFURA_KEY/g" ~/.snet/config
export PYTHONPATH=$cwd
python $cwd"/packages/snet_cli/test/functional_tests/mint/mint.py"
python3 $cwd"/packages/snet_cli/test/functional_tests/mint/mint.py"
snet account deposit 10000000 -y -q
snet account balance

# snet account balance
############
# service provider has --wallet-index==9 (0x52653A9091b5d5021bed06c5118D24b23620c529)
# make two endpoints (both are actually valid)
cd ../snet-cli/packages/sdk/testcases/
cd ../snet-sdk-python/testcases


snet organization metadata-init test_org test_org organization
Expand All @@ -78,20 +79,17 @@ snet service publish test_org test_service -y -q
snet organization print-metadata test_org test_org
snet service print-metadata test_org test_service


cd ~/singnet/example-service
pwd
cd ../example-service
pip3 install -r requirements.txt
sh buildproto.sh
nohup python3 run_example_service.py --no-daemon &


cd ~/singnet/snet-daemon/snet-daemon-v5.0.1-linux-amd64
cd ../../snet-daemon/snet-daemon-v5.0.1-linux-amd64
nohup ./snetd &

#wait for daemon to come up
sleep 20

cd ~/singnet/snet-cli
#cd ~/singnet/snet-cli



8 changes: 4 additions & 4 deletions testcases/utils/run_all_functional.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
./packages/sdk/testcases/utils/reset_environment.sh
./testcases/utils/reset_environment.sh

cd packages/sdk/testcases/functional_tests
python test_sdk_client.py
cd testcases/functional_tests
python3 test_sdk_client.py

python test_prepaid_payment.py
#python3 test_prepaid_payment.py

0 comments on commit 3f4b03f

Please sign in to comment.