Browse Source

factor out runtime profile features check from bash scripts

Mokhtar Naamani 3 years ago
parent
commit
9cba30c3ae

+ 5 - 14
build-node-docker.sh

@@ -1,25 +1,16 @@
 #!/usr/bin/env bash
-
 set -e
 
 # Looks for a cached joystream/node image matching code shasum.
 # Search order: local repo then dockerhub. If no cached image is found we build it.
 
-CODE_HASH=`scripts/runtime-code-shasum.sh`
-IMAGE=joystream/node:${CODE_HASH}
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
 
-FEATURES=
-if [[ "$RUNTIME_PROFILE" == "TESTING" ]]; then
-  FEATURES="testing_runtime"
-fi
+source scripts/features.sh
 
-if [[ "$RUNTIME_PROFILE" == "STAGING" ]]; then
-  FEATURES="staging_runtime"
-fi
-
-if [[ "$RUNTIME_PROFILE" == "PLAYGROUND" ]]; then
-  FEATURES="playground_runtime"
-fi
+CODE_HASH=`scripts/runtime-code-shasum.sh`
+IMAGE=joystream/node:${CODE_HASH}
 
 # Look for image locally
 if ! docker inspect ${IMAGE} > /dev/null;

+ 3 - 11
devops/git-hooks/pre-push

@@ -1,18 +1,10 @@
 #!/usr/bin/env bash
 set -e
 
-FEATURES=
-if [[ "$RUNTIME_PROFILE" == "TESTING" ]]; then
-  FEATURES="testing_runtime"
-fi
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
 
-if [[ "$RUNTIME_PROFILE" == "STAGING" ]]; then
-  FEATURES="staging_runtime"
-fi
-
-if [[ "$RUNTIME_PROFILE" == "PLAYGROUND" ]]; then
-  FEATURES="playground_runtime"
-fi
+source ../../scripts/features.sh
 
 export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 

+ 5 - 12
scripts/cargo-build.sh

@@ -1,18 +1,11 @@
 #!/usr/bin/env bash
+set -e
 
-export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
-
-FEATURES=
-if [[ "$RUNTIME_PROFILE" == "TESTING" ]]; then
-  FEATURES="testing_runtime"
-fi
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
 
-if [[ "$RUNTIME_PROFILE" == "STAGING" ]]; then
-  FEATURES="staging_runtime"
-fi
+source features.sh
 
-if [[ "$RUNTIME_PROFILE" == "PLAYGROUND" ]]; then
-  FEATURES="playground_runtime"
-fi
+export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 
 cargo +nightly-2021-02-20 build --release --features "${FEATURES}"

+ 7 - 2
scripts/cargo-tests-with-networking.sh

@@ -1,7 +1,12 @@
-#!/bin/sh
+#!/usr/bin/env bash
 set -e
 
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+source features.sh
+
 export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 
 echo 'running all cargo tests'
-cargo +nightly-2021-02-20 test --release --all -- --ignored
+cargo +nightly-2021-02-20 test --release --features "${FEATURES}" --all -- --ignored

+ 12 - 0
scripts/features.sh

@@ -0,0 +1,12 @@
+FEATURES=
+if [[ "$RUNTIME_PROFILE" == "TESTING" ]]; then
+  FEATURES="testing_runtime"
+fi
+
+if [[ "$RUNTIME_PROFILE" == "STAGING" ]]; then
+  FEATURES="staging_runtime"
+fi
+
+if [[ "$RUNTIME_PROFILE" == "PLAYGROUND" ]]; then
+  FEATURES="playground_runtime"
+fi

+ 9 - 3
scripts/run-dev-chain.sh

@@ -1,13 +1,19 @@
 #!/usr/bin/env bash
+set -e
+
+SCRIPT_PATH="$(dirname "${BASH_SOURCE[0]}")"
+cd $SCRIPT_PATH
+
+source features.sh
 
 export WASM_BUILD_TOOLCHAIN=nightly-2021-02-20
 
 # Build release binary
-cargo +nightly-2021-02-20 build --release
+cargo +nightly-2021-02-20 build --release --features "${FEATURES}"
 
 # Purge existing local chain
-yes | cargo +nightly-2021-02-20 run --release -- purge-chain --dev
+yes | cargo +nightly-2021-02-20 run --release --features "${FEATURES}" -- purge-chain --dev
 
 # Run local development chain -
 # No need to specify `-p joystream-node` it is the default bin crate in the cargo workspace
-cargo +nightly-2021-02-20 run --release -- --dev --log runtime
+cargo +nightly-2021-02-20 run --release --features "${FEATURES}" -- --dev --log runtime

+ 0 - 5
scripts/run-proposal-configuration-tests.sh

@@ -1,5 +0,0 @@
-#!/usr/bin/env bash
-
-
-ALL_PROPOSALS_PARAMETERS_JSON=`cat runtime/src/proposals_configuration/sample_proposal_parameters.json` cargo test proposals_configuration::tests -- --ignored
-