diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 5591da15d1..b28d0d20b1 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -223,7 +223,7 @@ jobs: run: | SKIP_WASM_BUILD=1 cargo check --features=runtime-benchmarks --release - test: + unit-test-creditcoin: runs-on: macos-12 steps: - uses: actions/checkout@v3 @@ -277,6 +277,32 @@ jobs: fail_ci_if_error: true verbose: true + unit-test-cli: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm install -g yarn + + - name: Execute tests + run: | + pushd creditcoin-js/ && yarn install && yarn pack && popd + pushd scripts/cc-cli + + yarn upgrade 'creditcoin-js' + yarn test:unit + popd + + - uses: codecov/codecov-action@v3 + with: + files: scripts/cc-cli/coverage/lcov.info + fail_ci_if_error: true + verbose: true + build-creditcoin-node: runs-on: ubuntu-22.04 steps: @@ -319,6 +345,80 @@ jobs: name: creditcoin_node_runtime.compact.compressed.wasm path: target/release/wbuild/creditcoin-node-runtime/creditcoin_node_runtime.compact.compressed.wasm + integration-test-cli: + needs: + - build-creditcoin-node + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v3 + + - name: Download creditcoin-node binary + uses: actions/download-artifact@v3 + with: + name: creditcoin-node + path: target/release + + - name: Download runtime + uses: actions/download-artifact@v3 + with: + name: creditcoin_node_runtime.compact.compressed.wasm + path: target/release + + - name: Install Node.js + uses: actions/setup-node@v3 + with: + node-version: 16 + - run: npm install -g yarn && npm install -g jest + + - name: Install Creditcoin CLI + run: | + pushd creditcoin-js/ && yarn install && yarn pack && popd + pushd scripts/cc-cli && yarn upgrade 'creditcoin-js' && yarn build && npm install -g . && popd + + - name: Start Node 1 + run: | + chmod a+x ./target/release/creditcoin-node + ./target/release/creditcoin-node \ + --chain local \ + --validator --alice --pruning archive \ + --node-key d182d503b7dd97e7c055f33438c7717145840fd66b2a055284ee8d768241a463 \ + --base-path ./alice-data & + + - name: Start Node 2 + run: | + ./target/release/creditcoin-node \ + --chain local \ + --validator --bob --pruning archive \ + --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWKEKymnBDKfa8MkMWiLE6DYbC4aAUciqmYucm7xFKK3Au \ + --port 30335 --ws-port 9945 --rpc-port 9935 & + + - name: Wait for nodes to start + run: | + ./integration-tests/wait-for-creditcoin.sh 'http://127.0.0.1:9933' + ./integration-tests/wait-for-creditcoin.sh 'http://127.0.0.1:9935' + + - name: Run integration tests + run: | + pushd scripts/cc-cli + yarn test:integration + popd + + - name: Upload code coverage + uses: codecov/codecov-action@v3 + with: + files: scripts/cc-cli/coverage/lcov.info + fail_ci_if_error: true + verbose: true + + - name: Kill nodes + if: always() + continue-on-error: true + run: | + # if all went well kill the node. Otherwise GitHub Actions would exit on the + # previous step killing everything and we don't have to worry about + # dangling processes + killall -9 creditcoin-node + integration-test-loan-cycle: needs: - build-creditcoin-node diff --git a/.github/workflows/cli-ci.yml b/.github/workflows/cli-ci.yml deleted file mode 100644 index 02bb22e706..0000000000 --- a/.github/workflows/cli-ci.yml +++ /dev/null @@ -1,160 +0,0 @@ ---- -name: Creditcoin-CLI CI - -# Controls when the action will run. -on: - # Triggers the workflow on push or pull request events but only for the master branch - push: - branches: [main, testnet, dev] - pull_request: - - # Allows you to run this workflow manually from the Actions tab - workflow_dispatch: - -permissions: read-all - -# A workflow run is made up of one or more jobs that can run sequentially or in parallel -jobs: - unit-tests: - runs-on: ubuntu-22.04 - name: unit-tests - - steps: - - uses: actions/checkout@v3 - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm install -g yarn - - - name: Execute tests - run: | - pushd creditcoin-js/ && yarn install && yarn pack && popd - pushd scripts/cc-cli - - yarn upgrade 'creditcoin-js' - yarn test:unit - popd - - - uses: codecov/codecov-action@v3 - with: - files: scripts/cc-cli/coverage/lcov.info - fail_ci_if_error: true - verbose: true - - build-creditcoin-node: - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - - name: Set-Up - run: | - sudo apt-get update - sudo apt install -y cmake pkg-config libssl-dev git build-essential clang libclang-dev curl protobuf-compiler - - - name: Configure rustc version - run: | - source ci/env - echo "RUSTC_VERSION=$RUSTC_VERSION" >> "$GITHUB_ENV" - - - name: Install Rust toolchain - uses: actions-rs/toolchain@v1 - with: - toolchain: ${{ env.RUSTC_VERSION }} - target: wasm32-unknown-unknown - profile: minimal - override: true - - uses: Swatinem/rust-cache@v2 - - - name: Build creditcoin-node - uses: actions-rs/cargo@v1 - with: - command: build - args: --release --features fast-runtime - - - name: Upload creditcoin-node binary - uses: actions/upload-artifact@v3 - with: - name: creditcoin-node - path: target/release/creditcoin-node - - - name: Upload WASM runtime - uses: actions/upload-artifact@v3 - with: - name: creditcoin_node_runtime.compact.compressed.wasm - path: target/release/wbuild/creditcoin-node-runtime/creditcoin_node_runtime.compact.compressed.wasm - - cli-integration-test: - needs: - - build-creditcoin-node - runs-on: ubuntu-22.04 - steps: - - uses: actions/checkout@v3 - - - name: Download creditcoin-node binary - uses: actions/download-artifact@v3 - with: - name: creditcoin-node - path: target/release - - - name: Download runtime - uses: actions/download-artifact@v3 - with: - name: creditcoin_node_runtime.compact.compressed.wasm - path: target/release - - - name: Install Node.js - uses: actions/setup-node@v3 - with: - node-version: 16 - - run: npm install -g yarn && npm install -g jest - - - name: Install Creditcoin CLI - run: | - pushd creditcoin-js/ && yarn install && yarn pack && popd - pushd scripts/cc-cli && yarn upgrade 'creditcoin-js' && yarn build && npm install -g . && popd - - - name: Start Node 1 - run: | - chmod a+x ./target/release/creditcoin-node - ./target/release/creditcoin-node \ - --chain local \ - --validator --alice --pruning archive \ - --node-key d182d503b7dd97e7c055f33438c7717145840fd66b2a055284ee8d768241a463 \ - --base-path ./alice-data & - - - name: Start Node 2 - run: | - ./target/release/creditcoin-node \ - --chain local \ - --validator --bob --pruning archive \ - --bootnodes /ip4/127.0.0.1/tcp/30333/p2p/12D3KooWKEKymnBDKfa8MkMWiLE6DYbC4aAUciqmYucm7xFKK3Au \ - --port 30335 --ws-port 9945 --rpc-port 9935 & - - - name: Wait for nodes to start - run: | - ./integration-tests/wait-for-creditcoin.sh 'http://127.0.0.1:9933' - ./integration-tests/wait-for-creditcoin.sh 'http://127.0.0.1:9935' - - - name: Run integration tests - run: | - pushd scripts/cc-cli - yarn test:integration - popd - - - name: Upload code coverage - uses: codecov/codecov-action@v3 - with: - files: scripts/cc-cli/coverage/lcov.info - fail_ci_if_error: true - verbose: true - - - name: Kill nodes - if: always() - continue-on-error: true - run: | - # if all went well kill the node. Otherwise GitHub Actions would exit on the - # previous step killing everything and we don't have to worry about - # dangling processes - killall -9 creditcoin-node