diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml deleted file mode 100644 index 93535b5..0000000 --- a/.github/workflows/release.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: NPM Semantic Release - -on: - push: - branches: ['main'] - -jobs: - Deployment: - name: Publish Chain Indexer Framework - runs-on: ubuntu-latest - env: - working-directory: ./ - permissions: - contents: read - packages: write - steps: - - name: CHECK-OUT GIT REPOSITORY - uses: actions/checkout@v3 - with: - persist-credentials: false - fetch-depth: 0 - - - name: Use Node.js - uses: actions/setup-node@v3 - with: - node-version: '18.x' - registry-url: 'https://npm.pkg.github.com' - - - name: Install dependencies - run: npm install - - - name: Build - run: npm run build - - - name: Run semantic-release - run: npx semantic-release - env: - GH_TOKEN: ${{ secrets.PERSONAL_ACCESS_TOKEN }} - NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }} diff --git a/package-lock.json b/package-lock.json index 18fe12c..c07351f 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "@maticnetwork/chain-indexer-framework", - "version": "1.3.10", + "version": "1.3.14", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "@maticnetwork/chain-indexer-framework", - "version": "1.3.10", + "version": "1.3.14", "license": "MIT", "dependencies": { "axios": "^1.3.6", diff --git a/package.json b/package.json index 8beb620..d397e85 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@maticnetwork/chain-indexer-framework", - "version": "1.3.13", + "version": "1.3.14", "description": "blockchain data indexer", "type": "module", "exports": { diff --git a/tests/logger/logger.test.ts b/tests/logger/logger.test.ts index f502776..f4c29d1 100644 --- a/tests/logger/logger.test.ts +++ b/tests/logger/logger.test.ts @@ -22,10 +22,10 @@ jest.mock("winston", () => { }, transports: { Console: jest.fn().mockImplementation(() => { - return {console: true}; + return { console: true }; }), Http: jest.fn().mockImplementation(() => { - return {datadog: true}; + return { datadog: true }; }) }, createLogger: jest.fn() @@ -40,42 +40,42 @@ describe("Logger", () => { mockedSentry: jest.MockedObject; let mockedLogger: jest.MockedObject = { - info: jest.fn(), - debug: jest.fn(), - error: jest.fn(), - warn: jest.fn(), - log: jest.fn() - } as jest.MockedObject; - - beforeAll(()=>{ - Logger.create({ + info: jest.fn(), + debug: jest.fn(), + error: jest.fn(), + warn: jest.fn(), + log: jest.fn() + } as jest.MockedObject; + + beforeAll(() => { + Logger.create({ winston: { level: "error" }, sentry: { - dsn: 'test_dsn', - level: 'error', + dsn: 'test_dsn', + level: 'error', environment: 'staging' - }, + }, datadog: { - api_key: 'test_api_key', - service_name: 'test_app_key' + api_key: 'test_api_key', + service_name: 'test_app_key' } }); }) - beforeEach(() => { + beforeEach(() => { mockedWinston = winston as jest.Mocked; mockedWinstonFormat = winston.format as jest.MockedObject; - mockedWinstonTransports = winston.transports; + mockedWinstonTransports = winston.transports; mockedSentryClass = Sentry as jest.MockedClass; }); test("create - should create logger with passed config or default config otherwise", () => { const colorizer = { addColors: (colors) => { } } as winston.Logform.Colorizer; - mockedWinstonFormat.combine.mockReturnValueOnce({format: true} as unknown as winston.Logform.Format); - + mockedWinstonFormat.combine.mockReturnValueOnce({ format: true } as unknown as winston.Logform.Format); + mockedWinston.createLogger.mockReturnValueOnce(mockedLogger); mockedWinstonFormat.timestamp.mockReturnValueOnce( @@ -86,23 +86,23 @@ describe("Logger", () => { {} as winston.Logform.Format ); - Logger.create({ + Logger.create({ winston: { level: "error" }, sentry: { - dsn: 'test_dsn', - level: 'error', + dsn: 'test_dsn', + level: 'error', environment: 'staging' - }, + }, datadog: { - api_key: 'test_api_key', - service_name: 'test_app_key' + api_key: 'test_api_key', + service_name: 'test_app_key' } }); mockedSentry = mockedSentryClass.mock.instances[0] as unknown as jest.MockedObject; - + expect(mockedWinstonFormat.combine).toHaveBeenNthCalledWith( 1, { options: {} }, @@ -116,11 +116,11 @@ describe("Logger", () => { expect(mockedWinston.createLogger).toHaveBeenCalledWith( { level: 'error', - format: {format: true}, + format: { format: true }, transports: [ - {console: true}, + { console: true }, mockedSentry, - {datadog: true} + { datadog: true } ] } ); @@ -152,8 +152,8 @@ describe("Logger", () => { { level: 'error', sentry: { - dsn: 'test_dsn', - environment: 'staging' + dsn: 'test_dsn', + // environment: 'staging' } } ); @@ -172,18 +172,18 @@ describe("Logger", () => { test('Logger is a singleton', () => { // Create an instance of Logger - Logger.create({ + Logger.create({ winston: { level: "error" }, sentry: { - dsn: 'test_dsn2', - level: 'error' , + dsn: 'test_dsn2', + level: 'error', environment: 'staging' - }, + }, datadog: { - api_key: 'test_api_key2', - service_name: 'test_app_key' + api_key: 'test_api_key2', + service_name: 'test_app_key' } }); @@ -191,7 +191,7 @@ describe("Logger", () => { //calling Logger create method will not call the createLogger of mockedWinston. Verifying this will serve as our test for Singleton. expect(mockedWinston.createLogger).toHaveBeenCalledTimes(0); }); - + test("info must call logger.info with the message passed", () => { Logger.info("mock");