Browse Source

build script and github workflow cleanup - drop use of ansible

Mokhtar Naamani 4 years ago
parent
commit
abd09e073e

+ 10 - 7
.github/workflows/run-network-tests.yml

@@ -5,9 +5,8 @@ on:
   workflow_dispatch:
 
 jobs:
-  run_ansible_tests:
+  run_network_tests:
     if: github.event.label.name == 'run-network-tests' || github.event.action == null
-    name: run network tests using ansible
     runs-on: ubuntu-latest
     strategy:
       matrix:
@@ -17,9 +16,13 @@ jobs:
       - uses: actions/setup-node@v1
         with:
           node-version: ${{ matrix.node-version }}
-      - name: install toolchain
-        run: curl https://getsubstrate.io -sSf | bash -s -- --fast
-      - name: ansible build and tests
+      - name: build npm packages
         run: |
-          cd ./devops/ansible
-          ansible-playbook -i hosts build-and-run-tests-single-node-playbook.yml --become -v
+          yarn install --frozen-lockfile
+          yarn workspace joystream-testing install
+      - name: set block production to 2000ms for faster tests
+        run: ./scripts/alter-block-creation-time.sh
+      - name: start network
+        run: docker-compose -f devops/dockerfiles/node-and-runtime/build-and-run-single-node-dev.yml up -d
+      - name: execute tests
+        run: yarn workspace joystream-testing test

+ 2 - 0
devops/dockerfiles/node-and-runtime/Dockerfile

@@ -4,6 +4,8 @@ WORKDIR /joystream
 COPY . /joystream
 
 # Build all cargo crates
+# Ensure our tests pass before we build release
+RUN WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo test --release --all
 RUN WASM_BUILD_TOOLCHAIN=nightly-2020-05-23 cargo build --release
 
 FROM debian:stretch

+ 14 - 0
devops/dockerfiles/node-and-runtime/build-and-run-single-node-dev.yml

@@ -0,0 +1,14 @@
+version: "3"
+services:
+  node_alice:
+    image: joystream/node
+    build:
+      context: ../../../
+      dockerfile: devops/dockerfiles/node-and-runtime/Dockerfile
+    container_name: alice
+    entrypoint: ./node --dev --alice --validator --unsafe-ws-external --rpc-cors=all
+    ports:
+      - "30333:30333"
+      - "9933:9933"
+      - "9944:9944"
+  

+ 11 - 0
devops/dockerfiles/node-and-runtime/run-single-node-dev.yml

@@ -0,0 +1,11 @@
+version: "3"
+services:
+  node_alice:
+    image: joystream/node
+    container_name: alice
+    entrypoint: ./node --dev --alice --validator --unsafe-ws-external --rpc-cors=all
+    ports:
+      - "30333:30333"
+      - "9933:9933"
+      - "9944:9944"
+  

+ 1 - 1
devops/git-hooks/pre-commit

@@ -1,5 +1,5 @@
 #!/bin/sh
 set -e
 
-echo 'cargo fmt --all -- --check'
+echo 'running rust-fmt'
 cargo fmt --all -- --check

+ 5 - 2
devops/git-hooks/pre-push

@@ -3,8 +3,11 @@ set -e
 
 export WASM_BUILD_TOOLCHAIN=nightly-2020-05-23
 
-echo '+cargo clippy --all -- -D warnings'
+echo 'running clippy (rust linter)'
+# When custom build.rs triggers wasm-build-runner-impl to build we get error:
+# "Rust WASM toolchain not installed, please install it!"
+# So we skip building the WASM binary by setting BUILD_DUMMY_WASM_BINARY=1
 BUILD_DUMMY_WASM_BINARY=1 cargo clippy --release --all -- -D warnings
 
-echo '+cargo test --all'
+echo 'running cargo unit tests'
 cargo test --release --all

+ 1 - 1
scripts/alter-block-creation-time.sh

@@ -1,4 +1,4 @@
-#!/bin/bash
+#!/usr/bin/env bash
 
 perl -i -pe's/pub const MILLISECS_PER_BLOCK: Moment = 6000;/pub const MILLISECS_PER_BLOCK: Moment = 2000;/' runtime/src/constants.rs
 perl -i -pe's/pub const SLOT_DURATION: Moment = 6000;/pub const SLOT_DURATION: Moment = 2000;/' runtime/src/constants.rs

+ 1 - 1
scripts/cargo-build.sh

@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/usr/bin/env bash
 
 export WASM_BUILD_TOOLCHAIN=nightly-2020-05-23
 

+ 0 - 16
scripts/create-test-chainspec.sh

@@ -1,16 +0,0 @@
-#!/bin/bash
-
-export WASM_BUILD_TOOLCHAIN=nightly-2020-05-23
-
-mkdir -p .tmp
-cargo run --release -p joystream-node build-spec --chain dev > .tmp/chainspec.json
-perl -i -pe's/"setValidatorCountProposalGracePeriod":.*/"setValidatorCountProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"runtimeUpgradeProposalGracePeriod":.*/"runtimeUpgradeProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"setElectionParametersProposalGracePeriod":.*/"setElectionParametersProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"textProposalGracePeriod":.*/"textProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"setContentWorkingGroupMintCapacityProposalGracePeriod":.*/"setContentWorkingGroupMintCapacityProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"setLeadProposalGracePeriod":.*/"setLeadProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"spendingProposalGracePeriod":.*/"spendingProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"evictStorageProviderProposalGracePeriod":.*/"evictStorageProviderProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"beginReviewWorkingGroupLeaderApplicationsProposalGracePeriod":.*/"beginReviewWorkingGroupLeaderApplicationsProposalGracePeriod": 0,/' .tmp/chainspec.json
-perl -i -pe's/"setStorageRoleParametersProposalGracePeriod":.*/"setStorageRoleParametersProposalGracePeriod": 0,/' .tmp/chainspec.json

+ 5 - 4
scripts/run-dev-chain.sh

@@ -3,10 +3,11 @@
 export WASM_BUILD_TOOLCHAIN=nightly-2020-05-23
 
 # Build release binary
-cargo build --release -p joystream-node
+cargo build --release
 
 # Purge existing local chain
-yes | cargo run --release -p joystream-node -- purge-chain --dev
+yes | cargo run --release -- purge-chain --dev
 
-# Run local development chain
-cargo run --release -p joystream-node -- --dev
+# Run local development chain -
+# No need to specify `-p joystream-node` it is the default bin crate in the cargo workspace
+cargo run --release -- --dev

+ 0 - 7
scripts/run-test-chain.sh

@@ -1,7 +0,0 @@
-#!/bin/bash
-
-export WASM_BUILD_TOOLCHAIN=nightly-2020-05-23
-
-sh ./scripts/create-test-chainspec.sh
-yes | cargo run --release -p joystream-node -- purge-chain --dev
-cargo run --release -p joystream-node -- --chain=.tmp/chainspec.json --alice --validator

+ 10 - 0
tests/network-tests/src/iznik/utils/apiWrapper.ts

@@ -40,6 +40,16 @@ export class ApiWrapper {
 
   public static async create(provider: WsProvider): Promise<ApiWrapper> {
     const api = await ApiPromise.create({ provider, types })
+
+    // Wait for api to be connected and ready
+    await api.isReady
+
+    // If a node was just started up it might take a few seconds to start producing blocks
+    // Give it a few seconds to be ready.
+    await new Promise((resolve) => {
+      setTimeout(resolve, 5000)
+    })
+
     return new ApiWrapper(api)
   }