Browse Source

update build, setup and start scripts

Mokhtar Naamani 4 years ago
parent
commit
4e40d88376
7 changed files with 93 additions and 32 deletions
  1. 1 3
      README.md
  2. 68 0
      build.sh
  3. 4 0
      package.json
  4. 7 8
      scripts/runtime-code-shasum.sh
  5. 10 9
      setup.sh
  6. 2 12
      start.sh
  7. 1 0
      storage-node/README.md

+ 1 - 3
README.md

@@ -108,9 +108,7 @@ A step by step guide to setup a full node and validator on the Joystream testnet
 ### Integration tests
 
 ```bash
-docker-compose up -d
-DEBUG=* yarn workspace network-tests test-run src/scenarios/full.ts
-docker-compose down
+tests/network-tests/run-tests.sh
 ```
 
 ### Contributing

+ 68 - 0
build.sh

@@ -0,0 +1,68 @@
+#!/usr/bin/env bash
+
+set -e
+
+yarn
+yarn workspace @joystream/types build
+yarn workspace cd-schemas generate:all
+yarn workspace cd-schemas build
+yarn workspace @joystream/cli build
+yarn workspace query-node-root build
+yarn workspace storage-node build
+# Not strictly needed during development, we run "yarn workspace pioneer start" to start
+# a dev instance, but will show highlight build issues
+yarn workspace pioneer build 
+
+# Build cargo crates: native binaries joystream/node, wasm runtime, and chainspec builder.
+while true
+do
+  read -p "Compile joystream node native binary? (y/N): " answer1
+
+  case $answer1 in
+   [yY]* ) yarn cargo-checks
+           yarn cargo-build
+           break;;
+
+   [nN]* ) break;;
+
+   * )     break;;
+  esac
+done
+
+if ! command -v docker-compose &> /dev/null
+then
+    echo "docker-compose not found, skipping docker images build"
+    exit
+fi
+
+# Optionally build joystream/node docker image
+# TODO: Try to fetch a cached joystream/node image
+# if one is found matching code shasum instead of building
+while true
+do
+  read -p "Rebuild joystream/node docker image? (y/N): " answer2
+
+  case $answer2 in
+   [yY]* ) docker-compose build joystream-node
+           break;;
+
+   [nN]* ) break;;
+
+   * )     break;;
+  esac
+done
+
+# Optionlly Build joystream/apps docker image
+while true
+do
+  read -p "Rebuild joystream/apps docker image? (y/N): " answer3
+
+  case $answer3 in
+   [yY]* ) docker-compose build pioneer
+           break;;
+
+   [nN]* ) break;;
+
+   * )     break;;
+  esac
+done

+ 4 - 0
package.json

@@ -52,5 +52,9 @@
   "engines": {
     "node": ">=12.18.0",
     "yarn": "^1.22.0"
+  },
+  "volta": {
+    "node": "12.18.2",
+    "yarn": "1.22.4"
   }
 }

+ 7 - 8
scripts/runtime-code-shasum.sh

@@ -7,17 +7,16 @@ export WORKSPACE_ROOT=`cargo metadata --offline --no-deps --format-version 1 | j
 
 cd ${WORKSPACE_ROOT}
 
-# srot/owner/group/mtime arguments only work with gnu version of tar.
-# So if you run this on Mac the default version of tar is `bsdtar`
-# and you will not get an idempotent result.
-# Install gnu-tar with brew
-#   brew install gnu-tar
-#   export PATH="/usr/local/opt/gnu-tar/libexec/gnubin:$PATH"
-tar -c --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2020-01-01' \
+TAR=tar
+if [[ "$OSTYPE" == "darwin"* ]]; then
+	TAR=gtar
+fi
+
+# sort/owner/group/mtime arguments only work with gnu version of tar!
+${TAR} -c --sort=name --owner=root:0 --group=root:0 --mtime='UTC 2020-01-01' \
     Cargo.lock \
     Cargo.toml \
     runtime \
     runtime-modules \
     utils/chain-spec-builder \
     joystream-node.Dockerfile | shasum | cut -d " " -f 1
-

+ 10 - 9
setup.sh

@@ -2,11 +2,8 @@
 
 set -e
 
-# If OS is supported will install:
-#  - build tools and any other dependencies required for rust and substrate
-#  - rustup - rust insaller
-#  - rust compiler and toolchains
-#  - skips installing substrate and subkey
+# If OS is supported will install build tools for rust and substrate.
+# Skips installing substrate itself and subkey
 curl https://getsubstrate.io -sSf | bash -s -- --fast
 
 source ~/.cargo/env
@@ -23,8 +20,12 @@ rustup target add wasm32-unknown-unknown --toolchain nightly-2020-05-23
 rustup install 1.46.0
 rustup default 1.46.0
 
-# Install additional tools...
+if [[ "$OSTYPE" == "linux-gnu" ]]; then
+    apt-get install coreutils
+elif [[ "$OSTYPE" == "darwin"* ]]; then
+	brew install b2sum gnu-tar
+fi
+
+# Volta nodejs, npm, yarn tools manager
+curl https://get.volta.sh | bash
 
-# - docker engine, docker, docker-compose,
-# - nodejs, npm, yarn (classic), npx
-# - b2sum,

+ 2 - 12
start.sh

@@ -2,17 +2,7 @@
 set -e
 
 # Run a complete joystream development network on your machine using docker.
-
-# TODO
-# - Check if docker is installed and prompt to install.
-# - Prompt user if they wish to rebuild before starting . default no, timeout if not prompted.
-# - Try to fetch a cached joystream/node image if one is found matching code shasum.
-
-# if ! docker inspect joystream/node:latest > /dev/null 2>&1;
-# then
-#   echo "Didn't find a joystream/node:latest docker image."
-#   exit 1
-# fi
+# Make sure to run build.sh prior to running this script.
 
 # Clean start!
 docker-compose down -v
@@ -25,7 +15,7 @@ function down()
 
 trap down EXIT
 
-# Run a development joystream-node chain
+# Run a local development chain
 docker-compose up -d joystream-node
 
 ## Storage Infrastructure

+ 1 - 0
storage-node/README.md

@@ -35,6 +35,7 @@ _Building_
 
 ```bash
 $ yarn install
+$ yarn build
 ```
 
 The command will install dependencies, and make a `colossus` executable available: