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..925aaf43 --- /dev/null +++ b/.github/workflows/test-report.yml @@ -0,0 +1,30 @@ +name: 'Test Report' +run-name: 'Test Report: Commit ${{ github.sha }}' + +on: + workflow_run: + workflows: ['CI'] + types: + - completed + +permissions: + contents: read + actions: read + checks: write + +jobs: + 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: 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 diff --git a/package.json b/package.json index 3e0baef5..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", @@ -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/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/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) => { 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/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/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 7b336132..7e8fdbb1 100644 --- a/workers/loc.api/queue/processor.js +++ b/workers/loc.api/queue/processor.js @@ -3,7 +3,7 @@ const { omit, cloneDeep -} = require('lodash') +} = require('lib-js-util-base') 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,