From 532300d61251f1d1250b1ba5c861782c3199dcef Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 5 Oct 2023 11:46:44 +0300 Subject: [PATCH 1/6] Use omit util from lib-js-util-base --- package.json | 1 + .../prepare-response/helpers/omit-private-model-fields.js | 2 +- workers/loc.api/queue/processor.js | 6 +++--- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 3e0baef5..3e503cd0 100644 --- a/package.json +++ b/package.json @@ -25,6 +25,7 @@ "csv": "5.5.3", "inversify": "6.0.1", "js-yaml": "4.1.0", + "lib-js-util-base": "git+https://github.com/bitfinexcom/lib-js-util-base.git", "lodash": "4.17.21", "lru": "3.1.0", "moment": "2.29.4", diff --git a/workers/loc.api/helpers/prepare-response/helpers/omit-private-model-fields.js b/workers/loc.api/helpers/prepare-response/helpers/omit-private-model-fields.js index eac7c01a..38c0b9df 100644 --- a/workers/loc.api/helpers/prepare-response/helpers/omit-private-model-fields.js +++ b/workers/loc.api/helpers/prepare-response/helpers/omit-private-model-fields.js @@ -1,6 +1,6 @@ 'use strict' -const { omit } = require('lodash') +const { omit } = require('lib-js-util-base') const OMITTING_FIELDS = [ '_events', diff --git a/workers/loc.api/queue/processor.js b/workers/loc.api/queue/processor.js index 7b336132..3dd15300 100644 --- a/workers/loc.api/queue/processor.js +++ b/workers/loc.api/queue/processor.js @@ -1,9 +1,9 @@ 'use strict' const { - omit, - cloneDeep -} = require('lodash') + omit +} = require('lib-js-util-base') +const { cloneDeep } = require('lodash') const { promisify } = require('util') const { pipeline } = require('stream') const fs = require('fs') From 235bd8c3c00192979c6930c997f85537b5ec2a43 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 5 Oct 2023 12:02:33 +0300 Subject: [PATCH 2/6] Use cloneDeep util from lib-js-util-base --- workers/loc.api/helpers/check-params.js | 2 +- workers/loc.api/helpers/get-data-from-api.js | 2 +- workers/loc.api/helpers/normalize-filter-params.js | 2 +- .../loc.api/helpers/prepare-response/helpers/get-params.js | 2 +- workers/loc.api/helpers/schema.js | 2 +- workers/loc.api/queue/processor.js | 4 ++-- workers/loc.api/queue/write-data-to-stream/data-normalizer.js | 2 +- workers/loc.api/queue/write-data-to-stream/helpers.js | 2 +- workers/loc.api/queue/write-data-to-stream/index.js | 2 +- 9 files changed, 10 insertions(+), 10 deletions(-) diff --git a/workers/loc.api/helpers/check-params.js b/workers/loc.api/helpers/check-params.js index 756da4c1..31503916 100644 --- a/workers/loc.api/helpers/check-params.js +++ b/workers/loc.api/helpers/check-params.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const Ajv = require('ajv') const schema = require('./schema') diff --git a/workers/loc.api/helpers/get-data-from-api.js b/workers/loc.api/helpers/get-data-from-api.js index 836e95ee..d7502e79 100644 --- a/workers/loc.api/helpers/get-data-from-api.js +++ b/workers/loc.api/helpers/get-data-from-api.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const Interrupter = require('../interrupter') const AbstractWSEventEmitter = require('../abstract.ws.event.emitter') diff --git a/workers/loc.api/helpers/normalize-filter-params.js b/workers/loc.api/helpers/normalize-filter-params.js index d7498fcb..1a7fb9f1 100644 --- a/workers/loc.api/helpers/normalize-filter-params.js +++ b/workers/loc.api/helpers/normalize-filter-params.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const FILTER_MODELS_NAMES = require('./filter.models.names') const FILTER_CONDITIONS = require('./filter.conditions') diff --git a/workers/loc.api/helpers/prepare-response/helpers/get-params.js b/workers/loc.api/helpers/prepare-response/helpers/get-params.js index fae4a49b..9965cec8 100644 --- a/workers/loc.api/helpers/prepare-response/helpers/get-params.js +++ b/workers/loc.api/helpers/prepare-response/helpers/get-params.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const { getDateNotMoreNow, diff --git a/workers/loc.api/helpers/schema.js b/workers/loc.api/helpers/schema.js index 8fb41304..f2123115 100644 --- a/workers/loc.api/helpers/schema.js +++ b/workers/loc.api/helpers/schema.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const _publicTradesSymbol = { type: ['string', 'array'], diff --git a/workers/loc.api/queue/processor.js b/workers/loc.api/queue/processor.js index 3dd15300..7e8fdbb1 100644 --- a/workers/loc.api/queue/processor.js +++ b/workers/loc.api/queue/processor.js @@ -1,9 +1,9 @@ 'use strict' const { - omit + omit, + cloneDeep } = require('lib-js-util-base') -const { cloneDeep } = require('lodash') const { promisify } = require('util') const { pipeline } = require('stream') const fs = require('fs') diff --git a/workers/loc.api/queue/write-data-to-stream/data-normalizer.js b/workers/loc.api/queue/write-data-to-stream/data-normalizer.js index e8e2855b..3c5eb16d 100644 --- a/workers/loc.api/queue/write-data-to-stream/data-normalizer.js +++ b/workers/loc.api/queue/write-data-to-stream/data-normalizer.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const { splitSymbolPairs } = require('../../helpers') diff --git a/workers/loc.api/queue/write-data-to-stream/helpers.js b/workers/loc.api/queue/write-data-to-stream/helpers.js index e2a5537c..d30d4749 100644 --- a/workers/loc.api/queue/write-data-to-stream/helpers.js +++ b/workers/loc.api/queue/write-data-to-stream/helpers.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const moment = require('moment-timezone') const dataNormalizer = require('./data-normalizer') diff --git a/workers/loc.api/queue/write-data-to-stream/index.js b/workers/loc.api/queue/write-data-to-stream/index.js index 38baae6c..098cdc4c 100644 --- a/workers/loc.api/queue/write-data-to-stream/index.js +++ b/workers/loc.api/queue/write-data-to-stream/index.js @@ -1,6 +1,6 @@ 'use strict' -const { cloneDeep } = require('lodash') +const { cloneDeep } = require('lib-js-util-base') const { writeMessageToStream, From 575c3ef3a74e6c0d574625e7c116ec7bce964d68 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Thu, 5 Oct 2023 12:38:48 +0300 Subject: [PATCH 3/6] Remove lodash min/max utils usage --- workers/loc.api/helpers/date-param.helpers.js | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/workers/loc.api/helpers/date-param.helpers.js b/workers/loc.api/helpers/date-param.helpers.js index 16e651ee..1c1b17bb 100644 --- a/workers/loc.api/helpers/date-param.helpers.js +++ b/workers/loc.api/helpers/date-param.helpers.js @@ -1,6 +1,5 @@ 'use strict' -const { min, max } = require('lodash') const moment = require('moment-timezone') const { TimeframeError } = require('../errors') @@ -8,11 +7,19 @@ const { TimeframeError } = require('../errors') const MIN_START_MTS = Date.UTC(2013) const getDateNotMoreNow = (mts, now = Date.now()) => { - return min([mts, now]) + if (!Number.isFinite(mts)) { + return now + } + + return Math.min(mts, now) } const getDateNotLessMinStart = (mts, minStart = MIN_START_MTS) => { - return max([mts, minStart]) + if (!Number.isFinite(mts)) { + return minStart + } + + return Math.max(mts, minStart) } const _setDefaultTimeIfNotExist = (args) => { From 4422f70ad9512d6aa3eed397e99ec0801a4ba7e1 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Mon, 9 Oct 2023 12:59:55 +0300 Subject: [PATCH 4/6] Add github actions workflow for test-runner --- .github/workflows/ci.yml | 38 +++++++++++++++++++++++++++++++ .github/workflows/test-report.yml | 23 +++++++++++++++++++ 2 files changed, 61 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .github/workflows/test-report.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 00000000..61a748a0 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,38 @@ +name: CI +run-name: 'Run tests: Commit ${{ github.sha }}' + +on: + pull_request: + types: [opened, reopened, edited] + branches: + - master + workflow_dispatch: + +jobs: + linux-test-runner: + name: Linux Test Runner + timeout-minutes: 30 + runs-on: ubuntu-22.04 + steps: + - name: Checkout + uses: actions/checkout@v4 + with: + submodules: recursive + - uses: actions/setup-node@v3 + with: + node-version: 18.17.1 + - name: Setup configs + run: | + cp config/common.json.example config/common.json \ + && cp config/service.report.json.example config/service.report.json \ + && cp config/facs/grc.config.json.example config/facs/grc.config.json \ + && cp config/facs/grc-slack.config.json.example config/facs/grc-slack.config.json + - name: Install deps + run: npm i + - name: Run tests + run: npm test -- --reporter=json --reporter-option output=test-report.json + - uses: actions/upload-artifact@v3 + if: success() || failure() + with: + name: test-results + path: test-report.json diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml new file mode 100644 index 00000000..eb50c5e6 --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,23 @@ +name: 'Test Report' + +on: + workflow_run: + workflows: ['CI'] + types: + - completed + +permissions: + contents: read + actions: read + checks: write + +jobs: + report: + runs-on: ubuntu-22.04 + steps: + - uses: dorny/test-reporter@v1 + with: + artifact: test-results + name: Test Report + path: test-report.json + reporter: mocha-json From 28ada1a2ec5022554c4a512cb323d22e374da960 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 10 Oct 2023 15:17:43 +0300 Subject: [PATCH 5/6] Add summary with web page link to test report workflow --- .github/workflows/test-report.yml | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/.github/workflows/test-report.yml b/.github/workflows/test-report.yml index eb50c5e6..925aaf43 100644 --- a/.github/workflows/test-report.yml +++ b/.github/workflows/test-report.yml @@ -1,4 +1,5 @@ name: 'Test Report' +run-name: 'Test Report: Commit ${{ github.sha }}' on: workflow_run: @@ -12,12 +13,18 @@ permissions: checks: write jobs: - report: + web-page-report: + name: Web Page Report runs-on: ubuntu-22.04 steps: - uses: dorny/test-reporter@v1 + id: test-results with: artifact: test-results - name: Test Report + name: Mocha Tests path: test-report.json reporter: mocha-json + - name: Test Report Summary + run: | + echo "### Test Report page is ready! :rocket:" >> $GITHUB_STEP_SUMMARY + echo "And available at the following [Link](${{ steps.test-results.outputs.url_html }})" >> $GITHUB_STEP_SUMMARY From cf1f0bd3623673c2943e89481421f8c60b671f33 Mon Sep 17 00:00:00 2001 From: Vladimir Voronkov Date: Tue, 17 Oct 2023 08:16:20 +0300 Subject: [PATCH 6/6] Bump version up to 4.8.0 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 3e503cd0..48ff1fef 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "bfx-report", - "version": "4.7.0", + "version": "4.8.0", "description": "Reporting tool", "main": "worker.js", "license": "Apache-2.0",