Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: add workflow local test and main #118

Merged
merged 4 commits into from
Nov 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions .github/workflows/local.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: localnet
on:
workflow_dispatch:

jobs:
localnet:
name: test all parachains run on localnet
runs-on: "ubuntu-latest"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Installing Kurtosis CLI if not found in cache
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli

- name: Starting the Kurtosis engine
run: kurtosis engine start

- name: Read CSV and loop over items
run: |
# Read CSV file and extract values
while IFS=',' read -r para_chain relay_chain; do
kurtosis clean -a
echo "Processing para chain: $para_chain, relay chain: $relay_chain"
# Call Python script with para_chain and relay_chain as arguments
python ./testdata/generate_json.py --relay "$relay_chain" --para "$para_chain" --network "local"
kurtosis run . --args-file ./testdata/updated_config.json --enclave polkadot
done < ./testdata/chain_value.csv




36 changes: 36 additions & 0 deletions .github/workflows/mainnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: mainnet
on:
workflow_dispatch:

jobs:
mainnet:
name: test all parachains run on mainnet
runs-on: "ubuntu-latest"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Installing Kurtosis CLI if not found in cache
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli

- name: Starting the Kurtosis engine
run: kurtosis engine start

- name: Read CSV and loop over items
run: |
# Read CSV file and extract values
while IFS=',' read -r para_chain relay_chain; do
kurtosis clean -a
echo "Processing para chain: $para_chain, relay chain: $relay_chain"
# Call Python script with para_chain and relay_chain as arguments
python ./testdata/generate_json.py --relay "$relay_chain" --para "$para_chain" --network "mainnet"
kurtosis run . --args-file ./testdata/updated_config.json --enclave polkadot
done < ./testdata/chain_value.csv




36 changes: 36 additions & 0 deletions .github/workflows/testnet.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: testnet
on:
workflow_dispatch:

jobs:
testnet:
name: test all parachains run on testnet
runs-on: "ubuntu-latest"

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Installing Kurtosis CLI if not found in cache
run: |
echo "deb [trusted=yes] https://apt.fury.io/kurtosis-tech/ /" | sudo tee /etc/apt/sources.list.d/kurtosis.list
sudo apt update
sudo apt install kurtosis-cli

- name: Starting the Kurtosis engine
run: kurtosis engine start

- name: Read CSV and loop over items
run: |
# Read CSV file and extract values
while IFS=',' read -r para_chain relay_chain; do
kurtosis clean -a
echo "Processing para chain: $para_chain, relay chain: $relay_chain"
# Call Python script with para_chain and relay_chain as arguments
python ./testdata/generate_json.py --relay "$relay_chain" --para "$para_chain" --network "testnet"
kurtosis run . --args-file ./testdata/updated_config.json --enclave polkadot
done < ./testdata/chain_value.csv




2 changes: 1 addition & 1 deletion local.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"chain-type": "mainnet",
"chain-type": "testnet",
"relaychain": {
"name": "kusama",
"nodes": [
Expand Down
35 changes: 35 additions & 0 deletions testdata/chain_value.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
acala,Polkadot
bifrost,Polkadot
clover,Polkadot
integritee,Polkadot
kilt-spiritnet,Polkadot
litentry,Polkadot
moonbeam,Polkadot
nodle,Polkadot
pendulum,Polkadot
polkadex,Polkadot
zeitgeist,Polkadot
altair,Kusama
bifrost,Kusama
karura,Kusama
kintsugi-btc,Kusama
mangata,Kusama
robonomics,Kusama
turing,Kusama
ajuna,Polkadot
centrifuge,Polkadot
frequency,Polkadot
interlay,Polkadot
kylin,Polkadot
manta,Polkadot
moonsama,Polkadot
parallel,Polkadot
subsocial,Polkadot
encointer-network,Kusama
bajun,Kusama
khala network,Kusama
subzero,Kusama
litmus,Kusama
moonriver,Kusama
calamari,Kusama
phala-network,Polkadot
44 changes: 44 additions & 0 deletions testdata/generate_json.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import argparse
import json


def update_config(original_config, relay_chain, para_chain, network):
# Read the original JSON file
with open(original_config, 'r') as file:
config_data = json.load(file)

if network == "testnet":
config_data["chain-type"] = "testnet"
config_data["relaychain"]["name"] = "rococo"
elif network == "mainnet":
config_data["chain-type"] = "mainnet"
config_data["relaychain"]["name"] = relay_chain.lower()
else:
# Update the original JSON data
config_data["chain-type"] = "local"
config_data["relaychain"]["name"] = relay_chain

name = next(iter(config_data["para"].keys()))

config_data["para"][para_chain] = config_data["para"].pop(name)
updated_config = json.dumps(config_data, indent=2)

# Optionally, save the updated config to a new file
with open('./testdata/updated_config.json', 'w') as file:
file.write(updated_config)

print(updated_config)



def main():
parser = argparse.ArgumentParser(description='Your script description')
parser.add_argument('--relay', type=str, help='Relay chain argument')
parser.add_argument('--para', type=str, help='Para chain argument')
parser.add_argument('--network', type=str, help='test environment')

args = parser.parse_args()
update_config("./local.json", args.relay, args.para, args.network)

if __name__ == "__main__":
main()
32 changes: 32 additions & 0 deletions testdata/updated_config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{
"chain-type": "mainnet",
"relaychain": {
"name": "rococo",
"nodes": [
{
"name": "alice",
"node-type": "validator",
"port": 9944
},
{
"name": "bob",
"node-type": "full",
"port": 9945
}
]
},
"para": {
"clover": {
"nodes": [
{
"name": "alice",
"node-type": "collator"
},
{
"name": "bob",
"node-type": "full"
}
]
}
}
}