git.delta.rocks / unique-network / refs/commits / 587c12521303

difftreelog

Added script for readyness check.

Alexander Aksenov2022-08-04parent: #b9780a1.patch.diff
in: master

2 files changed

added.docker/readyness.jsdiffbeforeafterboth
--- /dev/null
+++ b/.docker/readyness.js
@@ -0,0 +1,19 @@
+#!/usr/bin/env node
+
+const { ApiPromise, WsProvider } = require('@polkadot/api');
+
+const main = async () => {
+  const wsEndpoint = 'ws://127.0.0.1:9944'
+  const api = new ApiPromise({provider: new WsProvider(wsEndpoint)});
+  await api.isReady;
+
+  const head = (await api.rpc.chain.getHeader()).number.toNumber();
+  if(head < 1) throw Error('No block #1');
+
+  await api.disconnect();
+}
+
+main().then(() => process.exit(0)).catch(e => {
+  console.error(e);
+  process.exit(1);
+});
modified.github/workflows/node_build_test.ymldiffbeforeafterboth
before · .github/workflows/node_build_test.yml
1name: Develop - Build & test23# Controls when the action will run.4on:5 # Triggers the workflow on push or pull request events but only for the master branch6  pull_request:7    branches:8      - develop9    types:10      - opened11      - reopened12      - synchronize   #commit(s) pushed to the pull request1314  # Allows you to run this workflow manually from the Actions tab15  workflow_dispatch:1617#Define Workflow variables18env:19  RUST_TOOLCHAIN: nightly-2022-05-1120  REPO_URL: ${{ github.server_url }}/${{ github.repository }}21  POLKA_VERSION: release-v0.9.242223# A workflow run is made up of one or more jobs that can run sequentially or in parallel24jobs:25  build:26    # The type of runner that the job will run on27    runs-on: self-hosted-ci2829    name: Build Container, Spin it Up an test3031    continue-on-error: false         #Do not stop testing of matrix runs failed.  As it decided during PR review - it required 50/50& Let's check it with false.3233    strategy:34      matrix:35        include:36          - network: "Opal"37            features: "--features=opal-runtime"38          - network: "Quartz"39            features: "--features=quartz-runtime"40          - network: "Unique"41            features: "--features=unique-runtime"4243    steps:44      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it45      - uses: actions/checkout@v346        with:47          ref: ${{ github.event.pull_request.head.sha }}  #Checking out head commit4849      - name: Generate ENV related extend file for docker-compose50        uses: cuchi/jinja2-action@v1.2.051        with:52          template: .docker/docker-compose.tmp.j253          output_file: .docker/docker-compose.${{ matrix.network }}.yml54          variables: |55            REPO_URL=${{ github.server_url }}/${{ github.repository }}.git56            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}57            POLKA_VERSION=${{ env.POLKA_VERSION }}58            FEATURE=${{ matrix.features }}59            BRANCH=${{ github.head_ref }}6061      - name: Show build configuration62        run: cat .docker/docker-compose.${{ matrix.network }}.yml6364      - name: Build the stack65        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build6667      - name: Wait68        run: sleep 420s6970      - name: Install node71        uses: actions/setup-node@v172        with:73          node-version: 16.x7475      - name: Install dependencies76        run: |77          cd tests78          yarn install79          yarn add mochawesome80          yarn --pure-lockfile8182      - name: Run tests83        run: |84          cd tests85          NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}86        env:87          RPC_URL: http://127.0.0.1:9933/8889      - name: Test Report90        uses: phoenix-actions/test-reporting@v891        id: test-report               # Set ID reference for step92        if: success() || failure()    # run this step even if previous step failed93        with:94          name: Tests ${{ matrix.network }}            # Name of the check run which will be created95          path: tests/mochawesome-report/test-*.json    # Path to test results96          reporter: mochawesome-json97          fail-on-error: 'false'9899      - name: Stop running containers100        if: always()                   # run this step always101        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" down
after · .github/workflows/node_build_test.yml
1name: Develop - Build & test23# Controls when the action will run.4on:5 # Triggers the workflow on push or pull request events but only for the master branch6  pull_request:7    branches:8      - develop9    types:10      - opened11      - reopened12      - synchronize   #commit(s) pushed to the pull request1314  # Allows you to run this workflow manually from the Actions tab15  workflow_dispatch:1617#Define Workflow variables18env:19  RUST_TOOLCHAIN: nightly-2022-05-1120  REPO_URL: ${{ github.server_url }}/${{ github.repository }}21  POLKA_VERSION: release-v0.9.242223# A workflow run is made up of one or more jobs that can run sequentially or in parallel24jobs:25  build:26    # The type of runner that the job will run on27    runs-on: self-hosted-ci2829    name: Build Container, Spin it Up an test3031    continue-on-error: false         #Do not stop testing of matrix runs failed.  As it decided during PR review - it required 50/50& Let's check it with false.3233    strategy:34      matrix:35        include:36          - network: "Opal"37            features: "--features=opal-runtime"38          - network: "Quartz"39            features: "--features=quartz-runtime"40          - network: "Unique"41            features: "--features=unique-runtime"4243    steps:44      - name: Skip if pull request is in Draft45        # `if: github.event.pull_request.draft == true` should be kept here, at46        # the step level, rather than at the job level. The latter is not47        # recommended because when the PR is moved from "Draft" to "Ready to48        # review" the workflow will immediately be passing (since it was skipped),49        # even though it hasn't actually ran, since it takes a few seconds for50        # the workflow to start. This is also disclosed in:51        # https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/1752        # That scenario would open an opportunity for the check to be bypassed:53        # 1. Get your PR approved54        # 2. Move it to Draft55        # 3. Push whatever commits you want56        # 4. Move it to "Ready for review"; now the workflow is passing (it was57        #    skipped) and "Check reviews" is also passing (it won't be updated58        #    until the workflow is finished)59        if: github.event.pull_request.draft == true60        run: exit 16162      # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it63      - uses: actions/checkout@v364        with:65          ref: ${{ github.event.pull_request.head.sha }}  #Checking out head commit6667      - name: Generate ENV related extend file for docker-compose68        uses: cuchi/jinja2-action@v1.2.069        with:70          template: .docker/docker-compose.tmp.j271          output_file: .docker/docker-compose.${{ matrix.network }}.yml72          variables: |73            REPO_URL=${{ github.server_url }}/${{ github.repository }}.git74            RUST_TOOLCHAIN=${{ env.RUST_TOOLCHAIN }}75            POLKA_VERSION=${{ env.POLKA_VERSION }}76            FEATURE=${{ matrix.features }}77            BRANCH=${{ github.head_ref }}7879      - name: Show build configuration80        run: cat .docker/docker-compose.${{ matrix.network }}.yml8182      - name: Build the stack83        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build8485    #  - name: Wait86    #    run: sleep 420s8788      - name: Install node89        uses: actions/setup-node@v190        with:91          node-version: 16.x9293      - name: Install dependencies94        run: |95          cd tests96          yarn install97          yarn add mochawesome98          yarn --pure-lockfile99100      - name: Run tests101        run: |102          chmod u+x .docker/readyness.js &&  .docker/readyness.js103          cd tests104          NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}105        env:106          RPC_URL: http://127.0.0.1:9933/107108      - name: Test Report109        uses: phoenix-actions/test-reporting@v8110        id: test-report               # Set ID reference for step111        if: success() || failure()    # run this step even if previous step failed112        with:113          name: Tests ${{ matrix.network }}            # Name of the check run which will be created114          path: tests/mochawesome-report/test-*.json    # Path to test results115          reporter: mochawesome-json116          fail-on-error: 'false'117118      - name: Stop running containers119        if: always()                   # run this step always120        run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" down