From bd639c093ef10f76b3efacac87d7367194d5e293 Mon Sep 17 00:00:00 2001 From: hemz10 Date: Tue, 21 Nov 2023 17:18:25 +0530 Subject: [PATCH 1/3] test: add localnet workflow --- .github/workflows/local.yaml | 36 +++++++++++++++++++++++++++++ local.json | 2 +- testdata/chain_value.csv | 35 ++++++++++++++++++++++++++++ testdata/generate_json.py | 44 ++++++++++++++++++++++++++++++++++++ testdata/updated_config.json | 32 ++++++++++++++++++++++++++ 5 files changed, 148 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/local.yaml create mode 100644 testdata/chain_value.csv create mode 100644 testdata/generate_json.py create mode 100644 testdata/updated_config.json diff --git a/.github/workflows/local.yaml b/.github/workflows/local.yaml new file mode 100644 index 0000000..f11513d --- /dev/null +++ b/.github/workflows/local.yaml @@ -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 + + + + \ No newline at end of file diff --git a/local.json b/local.json index c2020a6..47a8d62 100644 --- a/local.json +++ b/local.json @@ -1,5 +1,5 @@ { - "chain-type": "local", + "chain-type": "testnet", "relaychain": { "name": "polkadot", "nodes": [ diff --git a/testdata/chain_value.csv b/testdata/chain_value.csv new file mode 100644 index 0000000..4229037 --- /dev/null +++ b/testdata/chain_value.csv @@ -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 \ No newline at end of file diff --git a/testdata/generate_json.py b/testdata/generate_json.py new file mode 100644 index 0000000..b0b7010 --- /dev/null +++ b/testdata/generate_json.py @@ -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() \ No newline at end of file diff --git a/testdata/updated_config.json b/testdata/updated_config.json new file mode 100644 index 0000000..86e4f4e --- /dev/null +++ b/testdata/updated_config.json @@ -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" + } + ] + } + } + } \ No newline at end of file From c64ac9f7a1211bfc7f35f5ea5b494848125fd9e6 Mon Sep 17 00:00:00 2001 From: hemz10 Date: Tue, 21 Nov 2023 17:18:39 +0530 Subject: [PATCH 2/3] test: add mainnet workflow --- .github/workflows/mainnet.yaml | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/mainnet.yaml diff --git a/.github/workflows/mainnet.yaml b/.github/workflows/mainnet.yaml new file mode 100644 index 0000000..1e6f9da --- /dev/null +++ b/.github/workflows/mainnet.yaml @@ -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 + + + + \ No newline at end of file From 02233a049615698f1d39c96cd363b862793dd8f1 Mon Sep 17 00:00:00 2001 From: hemz10 Date: Tue, 21 Nov 2023 17:18:51 +0530 Subject: [PATCH 3/3] test: add testnet workflow --- .github/workflows/testnet.yaml | 36 ++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 .github/workflows/testnet.yaml diff --git a/.github/workflows/testnet.yaml b/.github/workflows/testnet.yaml new file mode 100644 index 0000000..4699262 --- /dev/null +++ b/.github/workflows/testnet.yaml @@ -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 + + + + \ No newline at end of file