From 6b51fd4e3e238b82d48c7525f2b40ee55011373b Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Tue, 9 Jan 2024 17:32:27 +0530 Subject: [PATCH 1/6] fix: optimise build and coverage Signed-off-by: Sai Sankeerth --- .github/workflows/report-code-coverage.yml | 3 --- .github/workflows/test.yml | 31 +++++++--------------- 2 files changed, 9 insertions(+), 25 deletions(-) diff --git a/.github/workflows/report-code-coverage.yml b/.github/workflows/report-code-coverage.yml index af6326ae88..1352a497a8 100644 --- a/.github/workflows/report-code-coverage.yml +++ b/.github/workflows/report-code-coverage.yml @@ -5,9 +5,6 @@ on: SONAR_TOKEN: required: true - pull_request: - types: ['opened', 'reopened', 'synchronize'] - jobs: coverage: name: Code Coverage diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 71a6706f94..bd12d22d40 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,4 +1,4 @@ -name: Tests +name: Tests & report coverage on: pull_request: @@ -8,29 +8,16 @@ on: - synchronize jobs: - test: - name: Run Tests + test-and-report-coverage: + name: Report Code Coverage + uses: ./.github/workflows/report-code-coverage.yml + secrets: + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + + ut_tests: + name: UT Tests runs-on: ubuntu-latest steps: - - name: Checkout - uses: actions/checkout@v4.1.1 - with: - fetch-depth: 1 - - - name: Setup Node - uses: actions/setup-node@v4.0.1 - with: - node-version-file: '.nvmrc' - cache: 'npm' - - - name: Install Dependencies - run: npm ci - - - name: Run Unit Tests - run: | - npm run test:js:ci - npm run test:ts:ci - - name: Setup Go uses: actions/setup-go@v4.1.0 with: From d5b4eba7bcf81953f649e4d56f92a983fb3c8e74 Mon Sep 17 00:00:00 2001 From: Sai Sankeerth Date: Tue, 9 Jan 2024 17:36:12 +0530 Subject: [PATCH 2/6] fix: add additional steps of checking out transformer before executing UT tests Signed-off-by: Sai Sankeerth --- .github/workflows/test.yml | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index bd12d22d40..6e36fad624 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -26,6 +26,20 @@ jobs: - name: Install Latest Version of Kind run: go install sigs.k8s.io/kind@v0.17.0 + - name: Checkout + uses: actions/checkout@v4.1.1 + with: + fetch-depth: 1 + + - name: Setup Node + uses: actions/setup-node@v4.0.1 + with: + node-version-file: '.nvmrc' + cache: 'npm' + + - name: Install Dependencies + run: npm ci + - name: Create Kind cluster run: kind create cluster --name kind-cluster --config=test/__tests__/data/worker-nodes-kind.yml From e6bd5ff3e25e5be7c74994d02b0db2672cefc636 Mon Sep 17 00:00:00 2001 From: Dilip Kola Date: Wed, 10 Jan 2024 11:39:27 +0530 Subject: [PATCH 3/6] chore: refactor test github workflows --- ...ode-coverage.yml => test-and-report-code-coverage.yml} | 5 ++++- .github/workflows/{test.yml => ut-test.yml} | 8 +------- 2 files changed, 5 insertions(+), 8 deletions(-) rename .github/workflows/{report-code-coverage.yml => test-and-report-code-coverage.yml} (94%) rename .github/workflows/{test.yml => ut-test.yml} (91%) diff --git a/.github/workflows/report-code-coverage.yml b/.github/workflows/test-and-report-code-coverage.yml similarity index 94% rename from .github/workflows/report-code-coverage.yml rename to .github/workflows/test-and-report-code-coverage.yml index 1352a497a8..7cea9c8117 100644 --- a/.github/workflows/report-code-coverage.yml +++ b/.github/workflows/test-and-report-code-coverage.yml @@ -1,10 +1,13 @@ -name: Report Code Coverage +name: Test and Report Code Coverage on: workflow_call: secrets: SONAR_TOKEN: required: true + pull_request: + types: ['opened', 'reopened', 'synchronize'] + jobs: coverage: name: Code Coverage diff --git a/.github/workflows/test.yml b/.github/workflows/ut-test.yml similarity index 91% rename from .github/workflows/test.yml rename to .github/workflows/ut-test.yml index 6e36fad624..6cd1345ce5 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/ut-test.yml @@ -1,4 +1,4 @@ -name: Tests & report coverage +name: UT Tests on: pull_request: @@ -8,12 +8,6 @@ on: - synchronize jobs: - test-and-report-coverage: - name: Report Code Coverage - uses: ./.github/workflows/report-code-coverage.yml - secrets: - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - ut_tests: name: UT Tests runs-on: ubuntu-latest From c7e0e5df8e65f0f88f7b3e085ebfdb67e5122504 Mon Sep 17 00:00:00 2001 From: Dilip Kola Date: Wed, 10 Jan 2024 11:42:36 +0530 Subject: [PATCH 4/6] chore: refactor test github workflows --- ...t-code-coverage.yml => dt-test-and-report-code-coverage.yml} | 2 +- .github/workflows/{ut-test.yml => ut-tests.yml} | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) rename .github/workflows/{test-and-report-code-coverage.yml => dt-test-and-report-code-coverage.yml} (97%) rename .github/workflows/{ut-test.yml => ut-tests.yml} (99%) diff --git a/.github/workflows/test-and-report-code-coverage.yml b/.github/workflows/dt-test-and-report-code-coverage.yml similarity index 97% rename from .github/workflows/test-and-report-code-coverage.yml rename to .github/workflows/dt-test-and-report-code-coverage.yml index 7cea9c8117..9129c55b88 100644 --- a/.github/workflows/test-and-report-code-coverage.yml +++ b/.github/workflows/dt-test-and-report-code-coverage.yml @@ -1,4 +1,4 @@ -name: Test and Report Code Coverage +name: DT Tests on: workflow_call: secrets: diff --git a/.github/workflows/ut-test.yml b/.github/workflows/ut-tests.yml similarity index 99% rename from .github/workflows/ut-test.yml rename to .github/workflows/ut-tests.yml index 6cd1345ce5..530a532325 100644 --- a/.github/workflows/ut-test.yml +++ b/.github/workflows/ut-tests.yml @@ -1,4 +1,4 @@ -name: UT Tests +name: Tests on: pull_request: From 6e2c268825838132ef9f458f5326261d7a7829a2 Mon Sep 17 00:00:00 2001 From: Dilip Kola Date: Wed, 10 Jan 2024 13:30:08 +0530 Subject: [PATCH 5/6] chore: supress logs during tests in github --- .github/workflows/dt-test-and-report-code-coverage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/dt-test-and-report-code-coverage.yml b/.github/workflows/dt-test-and-report-code-coverage.yml index 9129c55b88..4096227400 100644 --- a/.github/workflows/dt-test-and-report-code-coverage.yml +++ b/.github/workflows/dt-test-and-report-code-coverage.yml @@ -30,8 +30,9 @@ jobs: - name: Run Tests run: | - npm run test:js:ci - npm run test:ts:ci + # Supress logging in tests + LOG_LEVEL=100 npm run test:js:ci + LOG_LEVEL=100 npm run test:ts:ci - name: Run Lint Checks run: | From db0a99a278a3b67c5890d3fd2f22b76f71fa879c Mon Sep 17 00:00:00 2001 From: Dilip Kola Date: Wed, 10 Jan 2024 13:45:12 +0530 Subject: [PATCH 6/6] chore: remove logs from tests --- src/adapters/networkHandlerFactory.test.js | 2 -- src/v0/destinations/bqstream/util.test.js | 2 -- src/v0/destinations/ga4/utils.test.js | 1 - src/v0/destinations/mp/util.test.js | 1 - src/v0/util/index.test.js | 1 - test/__tests__/marketo_bulk_upload.test.js | 3 --- test/__tests__/user_transformation_errors.test.js | 1 - tsconfig.json | 2 +- 8 files changed, 1 insertion(+), 12 deletions(-) diff --git a/src/adapters/networkHandlerFactory.test.js b/src/adapters/networkHandlerFactory.test.js index ff5f26a02d..e2b4a231e1 100644 --- a/src/adapters/networkHandlerFactory.test.js +++ b/src/adapters/networkHandlerFactory.test.js @@ -23,14 +23,12 @@ describe(`Network Handler Tests`, () => { it('Should return v0 handler if v1 version and handler is present for destination in v0', () => { const { networkHandler, handlerVersion } = getNetworkHandler('braze', `v1`); const brazeProxy = require(`../v0/destinations/braze/networkHandler`).networkHandler; - console.log(networkHandler); expect(networkHandler).toEqual(new brazeProxy()); }); it('Should return generic handler', () => { const { networkHandler, handlerVersion } = getNetworkHandler('abc', `v1`); const brazeProxy = require(`../v0/destinations/braze/networkHandler`).networkHandler; - console.log(networkHandler); expect(networkHandler).toEqual(new GenericNetworkHandler()); }); }); diff --git a/src/v0/destinations/bqstream/util.test.js b/src/v0/destinations/bqstream/util.test.js index c7635772ac..ae07d90383 100644 --- a/src/v0/destinations/bqstream/util.test.js +++ b/src/v0/destinations/bqstream/util.test.js @@ -196,7 +196,6 @@ describe('getRearrangedEvents', () => { ], ]; const result = getRearrangedEvents(successEventslist, errorEventsList); - console.log(JSON.stringify(result)); expect(result).toEqual(expected); }); @@ -261,7 +260,6 @@ describe('getRearrangedEvents', () => { ], ]; const result = getRearrangedEvents(successEventslist, errorEventsList); - console.log(JSON.stringify(result)); expect(result).toEqual(expected); }); }); diff --git a/src/v0/destinations/ga4/utils.test.js b/src/v0/destinations/ga4/utils.test.js index 7826c23d35..18b3ab5766 100644 --- a/src/v0/destinations/ga4/utils.test.js +++ b/src/v0/destinations/ga4/utils.test.js @@ -147,7 +147,6 @@ describe('Google Analytics 4 utils test', () => { const output = validateEventName('Grisly1234567_Open_General_Setting'); expect(output).toEqual(); } catch (error) { - console.log(error.message); expect(error.message).toEqual(); } }); diff --git a/src/v0/destinations/mp/util.test.js b/src/v0/destinations/mp/util.test.js index fbaa6f9b9f..ebf140fadd 100644 --- a/src/v0/destinations/mp/util.test.js +++ b/src/v0/destinations/mp/util.test.js @@ -611,7 +611,6 @@ describe('Mixpanel utils test', () => { const setOnceProperties = ['name', 'email']; const result = trimTraits(traits, contextTraits, setOnceProperties); - console.log(result); expect(result).toEqual({ traits: { diff --git a/src/v0/util/index.test.js b/src/v0/util/index.test.js index 65d6313e30..a46b55fdd4 100644 --- a/src/v0/util/index.test.js +++ b/src/v0/util/index.test.js @@ -60,7 +60,6 @@ describe('Utility Functions Tests', () => { test.each(funcTestData)('$description', async ({ description, input, output }) => { try { let result; - console.log(Object.values(input)); result = utilities[funcName](...Object.values(input)); expect(result).toEqual(output); } catch (e) { diff --git a/test/__tests__/marketo_bulk_upload.test.js b/test/__tests__/marketo_bulk_upload.test.js index be4efa14e2..6cf4d559b9 100644 --- a/test/__tests__/marketo_bulk_upload.test.js +++ b/test/__tests__/marketo_bulk_upload.test.js @@ -93,9 +93,6 @@ describe(`${integration} Tests`, () => { const output = await vRouter.pollStatus(input); expect(output).toEqual(respPollBody[index]); } catch (error) { - console.log("CHEEECKKKK"); - console.log(error); - console.log(respPollBody[index].error); expect(error.message).toEqual(respPollBody[index].error); } }); diff --git a/test/__tests__/user_transformation_errors.test.js b/test/__tests__/user_transformation_errors.test.js index 62bf4db3ce..c2a99ce09d 100644 --- a/test/__tests__/user_transformation_errors.test.js +++ b/test/__tests__/user_transformation_errors.test.js @@ -163,7 +163,6 @@ describe("JS Transformation Error Tests", () => { true, ); - console.log('XTE: ', result.transformedEvents) expect(result.transformedEvents.length).toBe(1); result.transformedEvents.forEach(ev => { expect(ev.error).toEqual( `ReferenceError: x is not defined diff --git a/tsconfig.json b/tsconfig.json index 3d91523d78..9db40dd0e1 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -102,6 +102,6 @@ // "skipDefaultLibCheck": true, /* Skip type checking .d.ts files that are included with TypeScript. */ "skipLibCheck": true /* Skip type checking all .d.ts files. */ }, - "exclude": ["./src/**/*.test.js", "./src/**/*.test.ts"], + "exclude": ["./src/**/*.test.js", "./src/**/*.test.ts", "./test"], "include": ["./src", "./src/**/*.json"] }