diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 896323f..3ee8e87 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -25,17 +25,22 @@ jobs: - name: Install yarn run: npm i -g yarn - - name: Deploy local contract & setup data + - name: Setup project run: | - cd contracts - yarn - yarn hardhat compile - yarn hardhat node > /dev/null 2>&1 & - yarn deploy:local - yarn cand - - - name: Build website - run: | - cd frontend - yarn - yarn build + chmod +x ./install.sh + ./install.sh + + # - name: Deploy local contract & setup data + # run: | + # cd contracts + # yarn + # yarn hardhat compile + # yarn hardhat node > /dev/null 2>&1 & + # yarn deploy:local + # yarn cand + + # - name: Build website + # run: | + # cd frontend + # yarn + # yarn build diff --git a/install.sh b/install.sh new file mode 100755 index 0000000..fadc85a --- /dev/null +++ b/install.sh @@ -0,0 +1,43 @@ +#!/bin/bash + +# Script for setting up the project +# This script assumes a unix environment +# Last modified: 07/08/2024 + +cmd_exists() { + command -v "$1" &> /dev/null +} + +if ! cmd_exists yarn; then + echo "Error: yarn is not installed or not in PATH"; exit 1 +fi + +if ! cmd_exists forge; then + echo "Error: forge (Foundry) is not installed or not in PATH"; exit 1 +fi + +require_ok() { + if [ $? -ne 0 ]; then + echo "Error: $1 failed" + exit 1 + fi +} + +cd contracts +yarn --dev +require_ok "yarn install in contracts" +npx hardhat compile +require_ok "hardhat compile" +yarn cand +require_ok "generate candidates" +yarn types +require_ok "generate web types" +yarn local-node & +HH_NODE_PID=$! +yarn deploy:local +require_ok "hardhat localhost deploy" + +cd ../frontend +yarn --dev +echo "Setup complete. Run web locally with: 'cd frontend && yarn dev:test'" +kill $HH_NODE_PID \ No newline at end of file