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
41 features: "--features=unique-runtime"41 features: "--features=unique-runtime"
4242
43 steps:43 steps:
44 # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it44 - name: Skip if pull request is in Draft
45 # `if: github.event.pull_request.draft == true` should be kept here, at
46 # the step level, rather than at the job level. The latter is not
47 # recommended because when the PR is moved from "Draft" to "Ready to
48 # 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 for
50 # the workflow to start. This is also disclosed in:
51 # https://github.community/t/dont-run-actions-on-draft-pull-requests/16817/17
52 # That scenario would open an opportunity for the check to be bypassed:
53 # 1. Get your PR approved
54 # 2. Move it to Draft
55 # 3. Push whatever commits you want
56 # 4. Move it to "Ready for review"; now the workflow is passing (it was
57 # skipped) and "Check reviews" is also passing (it won't be updated
58 # until the workflow is finished)
59 if: github.event.pull_request.draft == true
60 run: exit 1
61
62 # Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
45 - uses: actions/checkout@v363 - uses: actions/checkout@v3
46 with:64 with:
47 ref: ${{ github.event.pull_request.head.sha }} #Checking out head commit65 ref: ${{ github.event.pull_request.head.sha }} #Checking out head commit
64 - name: Build the stack82 - name: Build the stack
65 run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build83 run: docker-compose -f ".docker/docker-compose-dev.yaml" -f ".docker/docker-compose.${{ matrix.network }}.yml" up -d --build
6684
67 - name: Wait85 # - name: Wait
68 run: sleep 420s86 # run: sleep 420s
6987
70 - name: Install node88 - name: Install node
71 uses: actions/setup-node@v189 uses: actions/setup-node@v1
80 yarn --pure-lockfile98 yarn --pure-lockfile
8199
82 - name: Run tests100 - name: Run tests
83 run: |101 run: |
84 cd tests102 chmod u+x .docker/readyness.js && .docker/readyness.js
103 cd tests
85 NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}104 NOW=$(date +%s) && yarn test --reporter mochawesome --reporter-options reportFilename=test-${NOW}
86 env:105 env:
87 RPC_URL: http://127.0.0.1:9933/106 RPC_URL: http://127.0.0.1:9933/
88107