From 587c12521303563fa8050d365b5b5670522dd8cc Mon Sep 17 00:00:00 2001 From: Alexander Aksenov Date: Thu, 04 Aug 2022 11:03:45 +0000 Subject: [PATCH] Added script for readyness check. --- --- /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); +}); --- a/.github/workflows/node_build_test.yml +++ b/.github/workflows/node_build_test.yml @@ -41,6 +41,24 @@ features: "--features=unique-runtime" steps: + - name: Skip if pull request is in Draft + # `if: github.event.pull_request.draft == true` should be kept here, at + # the step level, rather than at the job level. The latter is not + # recommended because when the PR is moved from "Draft" to "Ready to + # review" the workflow will immediately be passing (since it was skipped), + # even though it hasn't actually ran, since it takes a few seconds for + # the workflow to start. This is also disclosed in: + # https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/17 + # That scenario would open an opportunity for the check to be bypassed: + # 1. Get your PR approved + # 2. Move it to Draft + # 3. Push whatever commits you want + # 4. Move it to "Ready for review"; now the workflow is passing (it was + # skipped) and "Check reviews" is also passing (it won't be updated + # until the workflow is finished) + if: github.event.pull_request.draft == true + run: exit 1 + # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it - uses: actions/checkout@v3 with: @@ -64,8 +82,8 @@ - name: Build the stack run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build - - name: Wait - run: sleep 420s + # - name: Wait + # run: sleep 420s - name: Install node uses: actions/setup-node@v1 @@ -81,6 +99,7 @@ - name: Run tests run: | + chmod u+x .docker/readyness.js && .docker/readyness.js cd tests NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW} env: -- gitstuff