diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 9103399..88df914 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -4,6 +4,9 @@ on: push: branches: - main + pull_request: + branches: + - main jobs: build-and-test: @@ -13,33 +16,64 @@ jobs: - name: Checkout Code uses: actions/checkout@v3 - - name: Set up Node.js - uses: actions/setup-node@v3 - with: - node-version: '14' - - - name: Install ResContract CLI - run: npm install -g rescontract-cli + - name: Set up Node.js and NVM + run: | + # Install and set up Node.js and NVM + sudo apt update + sudo apt install -y nodejs npm + curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash + export NVM_DIR="$HOME/.nvm" + [ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # Loads nvm + [ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # Loads nvm bash completion + nvm install node + sudo npm install -g n + sudo n latest + hash -r + node --version - - name: Install and Test ResilientDB with ResContract CLI - env: - ResDB_Home: ~/incubator-resilientdb # Use full path expansion + - name: Install ResilientDB run: | - # Install ResilientDB - echo "Cloning and installing ResilientDB..." - git clone https://github.com/apache/incubator-resilientdb.git ~/incubator-resilientdb - cd ~/incubator-resilientdb + cd $HOME + git clone https://github.com/apache/incubator-resilientdb.git + cd incubator-resilientdb ./INSTALL.sh ./service/tools/contract/service_tools/start_contract_service.sh bazel build service/tools/contract/api_tools/contract_tools + bazel build service/tools/kv/api_tools/kv_service_tools + env: + ResDB_Home: ${{ github.workspace }}/incubator-resilientdb - # Confirm build output location - echo "Listing build output files to confirm contract_tools location..." - ls -R ~/incubator-resilientdb/bazel-bin/service/tools/contract/api_tools/ + - name: Set ResDB_Home and Locate Config Path + run: | + export ResDB_Home="$HOME/incubator-resilientdb" + echo "ResDB_Home=$ResDB_Home" >> $GITHUB_ENV - # Set environment variable for ResDB_Home - echo "ResDB_Home=$HOME/incubator-resilientdb" >> $GITHUB_ENV + # Locate the actual path of service.config + CONFIG_PATH=$(find "$ResDB_Home" -name "service.config" | head -n 1) + if [ -z "$CONFIG_PATH" ]; then + echo "Error: service.config not found" + exit 1 + fi + echo "CONFIG_PATH=$CONFIG_PATH" >> $GITHUB_ENV - # Run CLI Tests + - name: Install ResContract CLI + run: | + cd $HOME + git clone https://github.com/ResilientEcosystem/ResContract.git + cd ResContract + sudo npm install -g + npm install commander + + - name: Install Solidity Compiler (solc) + run: | + sudo add-apt-repository -y ppa:ethereum/ethereum + sudo apt-get update + sudo apt-get install -y solc + + - name: Run CLI Tests + env: + ResDB_Home: ${{ env.ResDB_Home }} + CONFIG_PATH: ${{ env.CONFIG_PATH }} + run: | echo "Testing create command" - rescontract create --config ~/incubator-resilientdb/service/tools/config/interface/service.config + rescontract create --config "$CONFIG_PATH" diff --git a/package.json b/package.json index 891fab8..3bb8497 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "rescontract-cli", - "version": "1.2.2", + "version": "1.2.3", "description": "A CLI tool for managing smart contracts in the ResilientDB ecosystem.", "main": "index.js", "bin": {