From ba46518a0ed6103006533ed203e42c5f39906b96 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 10:52:34 +0300 Subject: [PATCH 01/31] RI-7038: add code coverage summary for FE tests --- .github/workflows/tests-frontend.yml | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests-frontend.yml b/.github/workflows/tests-frontend.yml index 895ff34b56..c54e5954ae 100644 --- a/.github/workflows/tests-frontend.yml +++ b/.github/workflows/tests-frontend.yml @@ -10,7 +10,7 @@ env: jobs: unit-tests: runs-on: ubuntu-latest - name: Frontend tests + name: Frontend tests (Coverage: ${{ env.coverage }}%) steps: - uses: actions/checkout@v4 @@ -52,6 +52,13 @@ jobs: timeout-minutes: 30 run: yarn test:cov --ci --silent + - name: Extract Coverage Percentage + id: extract-coverage + run: | + COVERAGE=$(cat ./report/coverage/coverage-summary.json | jq '.total.lines.pct') + echo "Coverage: $COVERAGE%" + echo "coverage=$COVERAGE" >> $GITHUB_ENV + - name: Upload Test Report uses: actions/upload-artifact@v4 if: always() From 594e2694237b608d666dc714a7fe1b954bd9a902 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 11:05:02 +0300 Subject: [PATCH 02/31] temp: trigger code change --- redisinsight/ui/src/components/base/layout/list/Group.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redisinsight/ui/src/components/base/layout/list/Group.tsx b/redisinsight/ui/src/components/base/layout/list/Group.tsx index 25d7406d1f..ecf87ce97d 100644 --- a/redisinsight/ui/src/components/base/layout/list/Group.tsx +++ b/redisinsight/ui/src/components/base/layout/list/Group.tsx @@ -21,7 +21,7 @@ const Group = ({ if (maxWidth) { newStyle = { ...newStyle, - maxWidth: maxWidth === true ? MAX_FORM_WIDTH : maxWidth, + maxWidth: maxWidth === true ? MAX_FORM_WIDTH - 1 : maxWidth, } } const classes = classNames(ListClassNames.listGroup, className) From 5848a65d4146badf464c31f80b90c79b86c896de Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 11:33:52 +0300 Subject: [PATCH 03/31] update workflow --- .github/workflows/tests-frontend.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/tests-frontend.yml b/.github/workflows/tests-frontend.yml index c54e5954ae..8de056bd9e 100644 --- a/.github/workflows/tests-frontend.yml +++ b/.github/workflows/tests-frontend.yml @@ -10,7 +10,7 @@ env: jobs: unit-tests: runs-on: ubuntu-latest - name: Frontend tests (Coverage: ${{ env.coverage }}%) + name: 'Frontend tests (Coverage: ${{ env.coverage }}%)' steps: - uses: actions/checkout@v4 From 8e304f08fcd034698b93be32b2ac013820a35f5c Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 11:54:25 +0300 Subject: [PATCH 04/31] add jest coverage report --- .github/workflows/tests-frontend.yml | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/.github/workflows/tests-frontend.yml b/.github/workflows/tests-frontend.yml index 8de056bd9e..fae4e07c56 100644 --- a/.github/workflows/tests-frontend.yml +++ b/.github/workflows/tests-frontend.yml @@ -10,9 +10,10 @@ env: jobs: unit-tests: runs-on: ubuntu-latest - name: 'Frontend tests (Coverage: ${{ env.coverage }}%)' + name: Frontend tests steps: - uses: actions/checkout@v4 + - uses: ArtiomTr/jest-coverage-report-action@v2 - name: Install all libs and dependencies uses: ./.github/actions/install-all-build-libs @@ -52,13 +53,6 @@ jobs: timeout-minutes: 30 run: yarn test:cov --ci --silent - - name: Extract Coverage Percentage - id: extract-coverage - run: | - COVERAGE=$(cat ./report/coverage/coverage-summary.json | jq '.total.lines.pct') - echo "Coverage: $COVERAGE%" - echo "coverage=$COVERAGE" >> $GITHUB_ENV - - name: Upload Test Report uses: actions/upload-artifact@v4 if: always() From af7072673ebe616096a736e616bce39b501d8f5d Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 12:37:24 +0300 Subject: [PATCH 05/31] update workflows --- .github/workflows/code-coverage.yml | 17 +++++++++++++++++ .github/workflows/tests-frontend.yml | 1 - .github/workflows/tests.yml | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/code-coverage.yml diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml new file mode 100644 index 0000000000..b8d595443c --- /dev/null +++ b/.github/workflows/code-coverage.yml @@ -0,0 +1,17 @@ +name: 'Code Coverage' +on: + workflow_call: + +jobs: + coverage: + runs-on: ubuntu-latest + name: Frontend tests coverage + steps: + - uses: actions/checkout@v4 + - uses: jwalton/gh-find-current-pr@v1 + id: findPr + - uses: ArtiomTr/jest-coverage-report-action@v2 + with: + prnumber: ${{ steps.findPr.outputs.number }} + coverage-file: ./report/coverage/coverage-final.json + base-coverage-file: ./report/coverage/coverage-final.json diff --git a/.github/workflows/tests-frontend.yml b/.github/workflows/tests-frontend.yml index fae4e07c56..895ff34b56 100644 --- a/.github/workflows/tests-frontend.yml +++ b/.github/workflows/tests-frontend.yml @@ -13,7 +13,6 @@ jobs: name: Frontend tests steps: - uses: actions/checkout@v4 - - uses: ArtiomTr/jest-coverage-report-action@v2 - name: Install all libs and dependencies uses: ./.github/actions/install-all-build-libs diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 5d38bd21b3..d2b780d46a 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -94,6 +94,11 @@ jobs: uses: ./.github/workflows/tests-frontend.yml secrets: inherit + frontend-tests-coverage: + needs: frontend-tests + uses: ./.github/workflows/code-coverage.yml + secrets: inherit + backend-tests: needs: changes if: inputs.group_tests == 'all' || inputs.group_tests == 'without_e2e' || startsWith(github.ref_name, 'be/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/') From a4828dd6d7ca1d733360b99220dc7e4f044c3ab1 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 14:17:13 +0300 Subject: [PATCH 06/31] update workflow --- .github/workflows/code-coverage.yml | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index b8d595443c..691675027f 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -7,11 +7,19 @@ jobs: runs-on: ubuntu-latest name: Frontend tests coverage steps: + - name: Debug Coverage Folder + run: | + echo "Checking folder contents..." + ls -l . + - name: Debug Coverage File + run: | + echo "Checking if coverage-final.json exists..." + ls -l report/coverage/ - uses: actions/checkout@v4 - uses: jwalton/gh-find-current-pr@v1 id: findPr - uses: ArtiomTr/jest-coverage-report-action@v2 with: prnumber: ${{ steps.findPr.outputs.number }} - coverage-file: ./report/coverage/coverage-final.json - base-coverage-file: ./report/coverage/coverage-final.json + coverage-file: report/coverage/coverage-final.json + base-coverage-file: report/coverage/coverage-final.json From d46f303f5f37e105e1cd8e86a3306df91d2dc1bd Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 14:48:31 +0300 Subject: [PATCH 07/31] update workflow --- .github/workflows/code-coverage.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 691675027f..f0b3b709c0 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -7,6 +7,11 @@ jobs: runs-on: ubuntu-latest name: Frontend tests coverage steps: + - name: Download Coverage Report + uses: actions/download-artifact@v4 + with: + name: report-fe + path: report - name: Debug Coverage Folder run: | echo "Checking folder contents..." From 300eae38b83256c640d4abe95cfc43de337b8ffd Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 15:19:25 +0300 Subject: [PATCH 08/31] update workflow file --- .github/workflows/code-coverage.yml | 21 ++++++++++++++++----- 1 file changed, 16 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index f0b3b709c0..463d7a042c 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -12,19 +12,30 @@ jobs: with: name: report-fe path: report - - name: Debug Coverage Folder + + - name: Set Permissions for Coverage File + run: chmod 644 report/coverage/coverage-final.json + + - name: Validate Coverage File run: | - echo "Checking folder contents..." - ls -l . + echo "Validating coverage-final.json..." + cat report/coverage/coverage-final.json + jq . report/coverage/coverage-final.json + - name: Debug Coverage File run: | echo "Checking if coverage-final.json exists..." ls -l report/coverage/ - uses: actions/checkout@v4 + - uses: jwalton/gh-find-current-pr@v1 id: findPr + + - name: Enable Debug Logging + run: echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV + - uses: ArtiomTr/jest-coverage-report-action@v2 with: prnumber: ${{ steps.findPr.outputs.number }} - coverage-file: report/coverage/coverage-final.json - base-coverage-file: report/coverage/coverage-final.json + coverage-file: ${{ github.workspace }}/report/coverage/coverage-final.json + base-coverage-file: ${{ github.workspace }}/report/coverage/coverage-final.json From b5a63a1ee9b2f32263d64ec6fb827899ae205256 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 15:54:05 +0300 Subject: [PATCH 09/31] update workflow --- .github/workflows/code-coverage.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 463d7a042c..62cd7a0613 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -37,5 +37,6 @@ jobs: - uses: ArtiomTr/jest-coverage-report-action@v2 with: prnumber: ${{ steps.findPr.outputs.number }} - coverage-file: ${{ github.workspace }}/report/coverage/coverage-final.json - base-coverage-file: ${{ github.workspace }}/report/coverage/coverage-final.json + coverage-file: report/coverage/coverage-final.json + base-coverage-file: report/coverage/coverage-final.json + working-directory: ${{ github.workspace }} From e88b8acc7ecf1f13dc2e1d79603d9fd8e8630012 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 16:38:10 +0300 Subject: [PATCH 10/31] update workflow --- .github/workflows/code-coverage.yml | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 62cd7a0613..c5ee1a9c1d 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -22,6 +22,12 @@ jobs: cat report/coverage/coverage-final.json jq . report/coverage/coverage-final.json + - name: Validate Coverage File Working Directory + run: | + echo "Validating ${{ github.workspace }} coverage-final.json..." + cat ${{ github.workspace }}/report/coverage/coverage-final.json + jq . ${{ github.workspace }}/report/coverage/coverage-final.json + - name: Debug Coverage File run: | echo "Checking if coverage-final.json exists..." @@ -31,8 +37,8 @@ jobs: - uses: jwalton/gh-find-current-pr@v1 id: findPr - - name: Enable Debug Logging - run: echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV + # - name: Enable Debug Logging + # run: echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV - uses: ArtiomTr/jest-coverage-report-action@v2 with: From 990279666c82cb684c4804b7c3f41281bc0512df Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 17:03:21 +0300 Subject: [PATCH 11/31] update workflow --- .github/workflows/code-coverage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index c5ee1a9c1d..8326c86009 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -39,6 +39,8 @@ jobs: # - name: Enable Debug Logging # run: echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV + - name: Install dotenv + run: npm install dotenv - uses: ArtiomTr/jest-coverage-report-action@v2 with: From ce112f9195524ef07d05c737ff1c42bb21f80c2c Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Fri, 16 May 2025 17:39:50 +0300 Subject: [PATCH 12/31] update workflow --- .github/workflows/code-coverage.yml | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 8326c86009..58866094e2 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -7,14 +7,21 @@ jobs: runs-on: ubuntu-latest name: Frontend tests coverage steps: + - uses: actions/checkout@v4 + - name: Download Coverage Report uses: actions/download-artifact@v4 with: name: report-fe path: report - - name: Set Permissions for Coverage File - run: chmod 644 report/coverage/coverage-final.json + - name: Install all libs and dependencies + uses: ./.github/actions/install-all-build-libs + with: + skip-backend-deps: '1' + + # - name: Set Permissions for Coverage File + # run: chmod 644 report/coverage/coverage-final.json - name: Validate Coverage File run: | @@ -32,19 +39,16 @@ jobs: run: | echo "Checking if coverage-final.json exists..." ls -l report/coverage/ - - uses: actions/checkout@v4 - uses: jwalton/gh-find-current-pr@v1 id: findPr # - name: Enable Debug Logging # run: echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV - - name: Install dotenv - run: npm install dotenv - uses: ArtiomTr/jest-coverage-report-action@v2 with: prnumber: ${{ steps.findPr.outputs.number }} coverage-file: report/coverage/coverage-final.json base-coverage-file: report/coverage/coverage-final.json - working-directory: ${{ github.workspace }} + # working-directory: ${{ github.workspace }} From 901ac4b74537afce5da498114f561c7ccffa89ca Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 11:11:31 +0300 Subject: [PATCH 13/31] update workflow --- .github/workflows/code-coverage.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 58866094e2..e1599697f0 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -51,4 +51,6 @@ jobs: prnumber: ${{ steps.findPr.outputs.number }} coverage-file: report/coverage/coverage-final.json base-coverage-file: report/coverage/coverage-final.json + github-token: ${{ secrets.GITHUB_TOKEN }} + skip-step: all # working-directory: ${{ github.workspace }} From 0ef0260c18e32ddbea3dab80c8838241d99e8768 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 13:50:18 +0300 Subject: [PATCH 14/31] update workflow --- .github/workflows/code-coverage.yml | 24 +++--------------------- package.json | 2 +- 2 files changed, 4 insertions(+), 22 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index e1599697f0..060bcffffa 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -20,37 +20,19 @@ jobs: with: skip-backend-deps: '1' - # - name: Set Permissions for Coverage File - # run: chmod 644 report/coverage/coverage-final.json - - - name: Validate Coverage File - run: | - echo "Validating coverage-final.json..." - cat report/coverage/coverage-final.json - jq . report/coverage/coverage-final.json - - - name: Validate Coverage File Working Directory - run: | - echo "Validating ${{ github.workspace }} coverage-final.json..." - cat ${{ github.workspace }}/report/coverage/coverage-final.json - jq . ${{ github.workspace }}/report/coverage/coverage-final.json - - name: Debug Coverage File run: | - echo "Checking if coverage-final.json exists..." + echo "Checking if report exists..." ls -l report/coverage/ - uses: jwalton/gh-find-current-pr@v1 id: findPr - # - name: Enable Debug Logging - # run: echo "ACTIONS_STEP_DEBUG=true" >> $GITHUB_ENV - - uses: ArtiomTr/jest-coverage-report-action@v2 with: prnumber: ${{ steps.findPr.outputs.number }} - coverage-file: report/coverage/coverage-final.json - base-coverage-file: report/coverage/coverage-final.json + coverage-file: report/coverage/report.json + base-coverage-file: report/coverage/report.json github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all # working-directory: ${{ github.workspace }} diff --git a/package.json b/package.json index f7310ef097..368c880143 100644 --- a/package.json +++ b/package.json @@ -48,7 +48,7 @@ "test:api": "yarn --cwd redisinsight/api test", "test:api:integration": "yarn --cwd redisinsight/api test:api", "test:watch": "jest ./redisinsight/ui --watch -w 1", - "test:cov": "cross-env NODE_OPTIONS='' jest ./redisinsight/ui --silent --coverage --no-cache --forceExit -w 3", + "test:cov": "cross-env NODE_OPTIONS='' jest ./redisinsight/ui --testLocationInResults --json --outputFile=\"report/coverage/report.json\" --silent --coverage --no-cache --forceExit -w 3", "test:cov:unit": "jest ./redisinsight/ui --group=-component --coverage -w 1", "test:cov:component": "jest ./redisinsight/ui --group=component --coverage -w 1", "type-check:ui": "tsc --project redisinsight/ui --noEmit" From 157d06a18357ded925f15f50780ea49eb94999cc Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 14:40:35 +0300 Subject: [PATCH 15/31] update workflows --- .github/workflows/code-coverage.yml | 12 ++++++------ .github/workflows/tests.yml | 9 +++++++++ redisinsight/api/package.json | 2 +- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 060bcffffa..bd671e28be 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -1,6 +1,10 @@ name: 'Code Coverage' on: workflow_call: + inputs: + resource_name: + description: Resource name of report folder + type: string jobs: coverage: @@ -12,7 +16,7 @@ jobs: - name: Download Coverage Report uses: actions/download-artifact@v4 with: - name: report-fe + name: ${{ inputs.resource_name }} path: report - name: Install all libs and dependencies @@ -20,11 +24,6 @@ jobs: with: skip-backend-deps: '1' - - name: Debug Coverage File - run: | - echo "Checking if report exists..." - ls -l report/coverage/ - - uses: jwalton/gh-find-current-pr@v1 id: findPr @@ -35,4 +34,5 @@ jobs: base-coverage-file: report/coverage/report.json github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all + custom-title: Code Coverage report for ${{ inputs.resource_name }} # working-directory: ${{ github.workspace }} diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index d2b780d46a..58732cca52 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -98,6 +98,8 @@ jobs: needs: frontend-tests uses: ./.github/workflows/code-coverage.yml secrets: inherit + with: + resource_name: report-fe backend-tests: needs: changes @@ -105,6 +107,13 @@ jobs: uses: ./.github/workflows/tests-backend.yml secrets: inherit + backend-tests-coverage: + needs: backend-tests + uses: ./.github/workflows/code-coverage.yml + secrets: inherit + with: + resource_name: report-be + integration-tests: needs: changes if: inputs.group_tests == 'all' || inputs.group_tests == 'without_e2e' || startsWith(github.ref_name, 'be/') || startsWith(github.ref_name, 'fe-be/') || startsWith(github.ref_name, 'feature/') || startsWith(github.ref_name, 'bugfix/') || startsWith(github.ref_name, 'ric/') diff --git a/redisinsight/api/package.json b/redisinsight/api/package.json index 167800402a..ea968bfacd 100644 --- a/redisinsight/api/package.json +++ b/redisinsight/api/package.json @@ -29,7 +29,7 @@ "start:prod": "cross-env NODE_ENV=production node dist/src/main", "test": "cross-env NODE_ENV=test ./node_modules/.bin/jest -w 1", "test:watch": "cross-env NODE_ENV=test jest --watch -w 1", - "test:cov": "cross-env NODE_ENV=test ./node_modules/.bin/jest --forceExit --coverage --runInBand", + "test:cov": "cross-env NODE_ENV=test ./node_modules/.bin/jest --testLocationInResults --json --outputFile=\"report/coverage/report.json\" --forceExit --coverage --runInBand", "test:debug": "node --inspect-brk -r tsconfig-paths/register -r ts-node/register node_modules/.bin/jest --runInBand -w 1", "test:e2e": "jest --config ./test/jest-e2e.json -w 1", "typeorm": "ts-node -r tsconfig-paths/register ./node_modules/typeorm/cli.js -d ./config/ormconfig.ts", From 5a80bdd7e0d3a27f5b02133b51b1fae39fa6af3b Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 15:04:54 +0300 Subject: [PATCH 16/31] update code coverage title --- .github/workflows/code-coverage.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index bd671e28be..139127a809 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -9,7 +9,7 @@ on: jobs: coverage: runs-on: ubuntu-latest - name: Frontend tests coverage + name: Jest tests coverage steps: - uses: actions/checkout@v4 @@ -34,5 +34,5 @@ jobs: base-coverage-file: report/coverage/report.json github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all - custom-title: Code Coverage report for ${{ inputs.resource_name }} + custom-title: Code Coverage - ${{ inputs.resource_name == 'report-be' && 'Backend' || 'Frontend' }} unit tests # working-directory: ${{ github.workspace }} From 30d728fe227ef68dc1746fa8377c7346d6ed5396 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 15:05:09 +0300 Subject: [PATCH 17/31] remove comment --- .github/workflows/code-coverage.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 139127a809..922cb805b6 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -35,4 +35,3 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all custom-title: Code Coverage - ${{ inputs.resource_name == 'report-be' && 'Backend' || 'Frontend' }} unit tests - # working-directory: ${{ github.workspace }} From d37c01cb72f218424b5f015c1da8222a6e81ace2 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 15:29:32 +0300 Subject: [PATCH 18/31] add integration tests code coverage --- .github/workflows/tests-integration.yml | 37 ++++++++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 45513874c2..c76174623b 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -191,7 +191,42 @@ jobs: sudo mkdir -p /usr/src/app sudo cp -a ./redisinsight/api/. /usr/src/app/ sudo cp -R ./coverages /usr/src/app && sudo chmod 777 -R /usr/src/app - cd /usr/src/app && npx nyc report -t ./coverages -r text -r text-summary + cd /usr/src/app && npx nyc report -t ./coverages -r text -r text-summary > coverage-summary.txt + + - name: Parse Coverage Summary + id: parse-coverage + run: | + # Extract coverage data from the summary + STATEMENTS=$(grep "Statements" coverage-summary.txt | awk '{print $3}') + BRANCHES=$(grep "Branches" coverage-summary.txt | awk '{print $3}') + FUNCTIONS=$(grep "Functions" coverage-summary.txt | awk '{print $3}') + LINES=$(grep "Lines" coverage-summary.txt | awk '{print $3}') + + # Format as a Markdown table + echo "| Metric | Coverage |" > coverage-table.md + echo "|-------------|----------|" >> coverage-table.md + echo "| Statements | $STATEMENTS |" >> coverage-table.md + echo "| Branches | $BRANCHES |" >> coverage-table.md + echo "| Functions | $FUNCTIONS |" >> coverage-table.md + echo "| Lines | $LINES |" >> coverage-table.md + + # Output the table for the next step + cat coverage-table.md + echo "table=$(cat coverage-table.md)" >> $GITHUB_OUTPUT + + - name: Post Coverage Summary as Comment + uses: actions/github-script@v7 + with: + script: | + const table = process.env.TABLE; + github.rest.issues.createComment({ + issue_number: context.payload.pull_request.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `### Code Coverage - Integration Tests\n\n${table}` + }); + env: + TABLE: ${{ steps.parse-coverage.outputs.table }} - name: Delete Artifact uses: actions/github-script@v7 From efe69394219afe0c504a36e3bce0f8f2ca34bcbe Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 15:38:18 +0300 Subject: [PATCH 19/31] fix workflow --- .github/workflows/tests-integration.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index c76174623b..1e92fdeb69 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -225,8 +225,8 @@ jobs: repo: context.repo.repo, body: `### Code Coverage - Integration Tests\n\n${table}` }); - env: - TABLE: ${{ steps.parse-coverage.outputs.table }} + env: + TABLE: ${{ steps.parse-coverage.outputs.table }} - name: Delete Artifact uses: actions/github-script@v7 From d2860fdcbaa288560e158d460a56e8658a22e570 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 15:54:11 +0300 Subject: [PATCH 20/31] update integration workflow --- .github/workflows/tests-integration.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 1e92fdeb69..89b6dbb008 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -192,6 +192,7 @@ jobs: sudo cp -a ./redisinsight/api/. /usr/src/app/ sudo cp -R ./coverages /usr/src/app && sudo chmod 777 -R /usr/src/app cd /usr/src/app && npx nyc report -t ./coverages -r text -r text-summary > coverage-summary.txt + cp coverage-summary.txt $GITHUB_WORKSPACE/coverage-summary.txt - name: Parse Coverage Summary id: parse-coverage From 8c93fed72d34461b1f0c29e1dd70c6539f96e62b Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 16:06:54 +0300 Subject: [PATCH 21/31] update integration workflow --- .github/workflows/tests-integration.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 89b6dbb008..11cb0d2115 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -211,15 +211,12 @@ jobs: echo "| Functions | $FUNCTIONS |" >> coverage-table.md echo "| Lines | $LINES |" >> coverage-table.md - # Output the table for the next step - cat coverage-table.md - echo "table=$(cat coverage-table.md)" >> $GITHUB_OUTPUT - - name: Post Coverage Summary as Comment uses: actions/github-script@v7 with: script: | - const table = process.env.TABLE; + const fs = require('fs'); + const table = fs.readFileSync('coverage-table.md', 'utf8'); github.rest.issues.createComment({ issue_number: context.payload.pull_request.number, owner: context.repo.owner, From 601780f643d683c0374120b69e46f0ba0f51f6c8 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 16:44:05 +0300 Subject: [PATCH 22/31] debug integration workflow --- .github/workflows/tests-integration.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 11cb0d2115..78c3c4c84d 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -211,6 +211,18 @@ jobs: echo "| Functions | $FUNCTIONS |" >> coverage-table.md echo "| Lines | $LINES |" >> coverage-table.md + - uses: jwalton/gh-find-current-pr@v1 + id: findPr + + - name: Debug Event Context + run: | + echo "Event Name: ${{ github.event_name }}" + echo "PR: ${{ context.payload.pull_request.number }}" + echo "PR2: ${{ steps.findPr.outputs.number }} + echo "Payload: ${{ toJson(github.event) }}" + echo "Owner: ${{ context.repo.owner }}" + echo "Repo: ${{ context.repo.repo }}" + - name: Post Coverage Summary as Comment uses: actions/github-script@v7 with: @@ -218,13 +230,13 @@ jobs: const fs = require('fs'); const table = fs.readFileSync('coverage-table.md', 'utf8'); github.rest.issues.createComment({ - issue_number: context.payload.pull_request.number, + issue_number: process.env.RR_Number, owner: context.repo.owner, repo: context.repo.repo, body: `### Code Coverage - Integration Tests\n\n${table}` }); env: - TABLE: ${{ steps.parse-coverage.outputs.table }} + RR_Number: ${{ steps.findPr.outputs.number }} - name: Delete Artifact uses: actions/github-script@v7 From 1f8be593218df9cb55b019c1f9d3c5e9b4db21c2 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 16:50:24 +0300 Subject: [PATCH 23/31] update workflow --- .github/workflows/tests-integration.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 78c3c4c84d..bc197bf913 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -217,11 +217,8 @@ jobs: - name: Debug Event Context run: | echo "Event Name: ${{ github.event_name }}" - echo "PR: ${{ context.payload.pull_request.number }}" echo "PR2: ${{ steps.findPr.outputs.number }} echo "Payload: ${{ toJson(github.event) }}" - echo "Owner: ${{ context.repo.owner }}" - echo "Repo: ${{ context.repo.repo }}" - name: Post Coverage Summary as Comment uses: actions/github-script@v7 From 591df4a48ea377130b581ca695dc9d99da26fd0f Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Tue, 20 May 2025 16:59:48 +0300 Subject: [PATCH 24/31] remove debug section --- .github/workflows/tests-integration.yml | 6 ------ 1 file changed, 6 deletions(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index bc197bf913..c371c5c3a0 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -214,12 +214,6 @@ jobs: - uses: jwalton/gh-find-current-pr@v1 id: findPr - - name: Debug Event Context - run: | - echo "Event Name: ${{ github.event_name }}" - echo "PR2: ${{ steps.findPr.outputs.number }} - echo "Payload: ${{ toJson(github.event) }}" - - name: Post Coverage Summary as Comment uses: actions/github-script@v7 with: From bcc39597115b28d01977cdfc25d3ba7bc83b197f Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Wed, 21 May 2025 10:19:04 +0300 Subject: [PATCH 25/31] update integration tests coverage markdown --- .github/workflows/tests-integration.yml | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index c371c5c3a0..c8b273b3af 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -197,15 +197,15 @@ jobs: - name: Parse Coverage Summary id: parse-coverage run: | - # Extract coverage data from the summary - STATEMENTS=$(grep "Statements" coverage-summary.txt | awk '{print $3}') - BRANCHES=$(grep "Branches" coverage-summary.txt | awk '{print $3}') - FUNCTIONS=$(grep "Functions" coverage-summary.txt | awk '{print $3}') - LINES=$(grep "Lines" coverage-summary.txt | awk '{print $3}') + # Extract coverage data from the summary and remove any trailing newlines + STATEMENTS=$(grep "Statements" coverage-summary.txt | awk '{print $3}' | tr -d '\n') + BRANCHES=$(grep "Branches" coverage-summary.txt | awk '{print $3}' | tr -d '\n') + FUNCTIONS=$(grep "Functions" coverage-summary.txt | awk '{print $3}' | tr -d '\n') + LINES=$(grep "Lines" coverage-summary.txt | awk '{print $3}' | tr -d '\n') # Format as a Markdown table - echo "| Metric | Coverage |" > coverage-table.md - echo "|-------------|----------|" >> coverage-table.md + echo "| Category | Percentage |" > coverage-table.md + echo "|-------------|-------------|" >> coverage-table.md echo "| Statements | $STATEMENTS |" >> coverage-table.md echo "| Branches | $BRANCHES |" >> coverage-table.md echo "| Functions | $FUNCTIONS |" >> coverage-table.md From 628c35415a611c7fa8a3e2c3e0faa4296cfbc227 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Wed, 21 May 2025 10:19:27 +0300 Subject: [PATCH 26/31] remove dep install for jest test coverage --- .github/workflows/code-coverage.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 922cb805b6..316b3d9a8e 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -19,11 +19,6 @@ jobs: name: ${{ inputs.resource_name }} path: report - - name: Install all libs and dependencies - uses: ./.github/actions/install-all-build-libs - with: - skip-backend-deps: '1' - - uses: jwalton/gh-find-current-pr@v1 id: findPr From c941a2a1167a111bf61a2e1662384f6298204096 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Wed, 21 May 2025 10:55:27 +0300 Subject: [PATCH 27/31] update integration flow and formatting --- .github/workflows/tests-integration.yml | 42 ++++++++++++++++++------- 1 file changed, 31 insertions(+), 11 deletions(-) diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index c8b273b3af..0bc5a5eefe 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -197,19 +197,39 @@ jobs: - name: Parse Coverage Summary id: parse-coverage run: | - # Extract coverage data from the summary and remove any trailing newlines - STATEMENTS=$(grep "Statements" coverage-summary.txt | awk '{print $3}' | tr -d '\n') - BRANCHES=$(grep "Branches" coverage-summary.txt | awk '{print $3}' | tr -d '\n') - FUNCTIONS=$(grep "Functions" coverage-summary.txt | awk '{print $3}' | tr -d '\n') - LINES=$(grep "Lines" coverage-summary.txt | awk '{print $3}' | tr -d '\n') + # Extract coverage data from the summary + STATEMENTS_PERCENT=$(grep "Statements" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + STATEMENTS_COVERED=$(grep "Statements" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') + BRANCHES_PERCENT=$(grep "Branches" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + BRANCHES_COVERED=$(grep "Branches" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') + FUNCTIONS_PERCENT=$(grep "Functions" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + FUNCTIONS_COVERED=$(grep "Functions" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') + LINES_PERCENT=$(grep "Lines" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + LINES_COVERED=$(grep "Lines" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') + + # Determine status based on percentage + get_status() { + if [ "$1" -lt 50 ]; then + echo "🔴" + elif [ "$1" -lt 80 ]; then + echo "🟡" + else + echo "🟢" + fi + } + + STATEMENTS_STATUS=$(get_status $STATEMENTS_PERCENT) + BRANCHES_STATUS=$(get_status $BRANCHES_PERCENT) + FUNCTIONS_STATUS=$(get_status $FUNCTIONS_PERCENT) + LINES_STATUS=$(get_status $LINES_PERCENT) # Format as a Markdown table - echo "| Category | Percentage |" > coverage-table.md - echo "|-------------|-------------|" >> coverage-table.md - echo "| Statements | $STATEMENTS |" >> coverage-table.md - echo "| Branches | $BRANCHES |" >> coverage-table.md - echo "| Functions | $FUNCTIONS |" >> coverage-table.md - echo "| Lines | $LINES |" >> coverage-table.md + echo "| Status | Category | Percentage | Covered/Total |" > coverage-table.md + echo "|-------------|-------------|-------------|---------------|" >> coverage-table.md + echo "| $STATEMENTS_STATUS | Statements | ${STATEMENTS_PERCENT}% | $STATEMENTS_COVERED |" >> coverage-table.md + echo "| $BRANCHES_STATUS | Branches | ${BRANCHES_PERCENT}% | $BRANCHES_COVERED |" >> coverage-table.md + echo "| $FUNCTIONS_STATUS | Functions | ${FUNCTIONS_PERCENT}% | $FUNCTIONS_COVERED |" >> coverage-table.md + echo "| $LINES_STATUS | Lines | ${LINES_PERCENT}% | $LINES_COVERED |" >> coverage-table.md - uses: jwalton/gh-find-current-pr@v1 id: findPr From 5b500e9df50a6497959bf5d579462d7777823465 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Wed, 21 May 2025 11:13:53 +0300 Subject: [PATCH 28/31] refactor workflows --- .github/workflows/code-coverage.yml | 80 ++++++++++++++++++++++++- .github/workflows/tests-integration.yml | 61 ++----------------- .github/workflows/tests.yml | 9 +++ 3 files changed, 94 insertions(+), 56 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 316b3d9a8e..919dceb9da 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -2,14 +2,19 @@ name: 'Code Coverage' on: workflow_call: inputs: + type: + description: Type of report (unit or integration) + type: string + default: unit resource_name: description: Resource name of report folder type: string jobs: - coverage: + coverage-unit: runs-on: ubuntu-latest name: Jest tests coverage + if: ${{ inputs.type == 'unit' }} steps: - uses: actions/checkout@v4 @@ -30,3 +35,76 @@ jobs: github-token: ${{ secrets.GITHUB_TOKEN }} skip-step: all custom-title: Code Coverage - ${{ inputs.resource_name == 'report-be' && 'Backend' || 'Frontend' }} unit tests + + coverage-integration: + runs-on: ubuntu-latest + name: Jest tests coverage + if: ${{ inputs.type == 'integration' }} + steps: + - uses: actions/checkout@v4 + + - name: Download Coverage Report + uses: actions/download-artifact@v4 + with: + name: ${{ inputs.resource_name }} + + - name: Parse Coverage Summary + id: parse-coverage + run: | + # Extract coverage data from the summary + STATEMENTS_PERCENT=$(grep "Statements" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + STATEMENTS_COVERED=$(grep "Statements" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') + BRANCHES_PERCENT=$(grep "Branches" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + BRANCHES_COVERED=$(grep "Branches" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') + FUNCTIONS_PERCENT=$(grep "Functions" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + FUNCTIONS_COVERED=$(grep "Functions" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') + LINES_PERCENT=$(grep "Lines" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') + LINES_COVERED=$(grep "Lines" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') + + # Ensure percentages are treated as numbers + STATEMENTS_PERCENT=$(printf "%.0f" $STATEMENTS_PERCENT) + BRANCHES_PERCENT=$(printf "%.0f" $BRANCHES_PERCENT) + FUNCTIONS_PERCENT=$(printf "%.0f" $FUNCTIONS_PERCENT) + LINES_PERCENT=$(printf "%.0f" $LINES_PERCENT) + + # Determine status based on percentage + get_status() { + if [ "$1" -lt 50 ]; then + echo "🔴" + elif [ "$1" -lt 80 ]; then + echo "🟡" + else + echo "🟢" + fi + } + + STATEMENTS_STATUS=$(get_status $STATEMENTS_PERCENT) + BRANCHES_STATUS=$(get_status $BRANCHES_PERCENT) + FUNCTIONS_STATUS=$(get_status $FUNCTIONS_PERCENT) + LINES_STATUS=$(get_status $LINES_PERCENT) + + # Format as a Markdown table + echo "| Status | Category | Percentage | Covered/Total |" > coverage-table.md + echo "|-------------|-------------|-------------|---------------|" >> coverage-table.md + echo "| $STATEMENTS_STATUS | Statements | ${STATEMENTS_PERCENT}% | $STATEMENTS_COVERED |" >> coverage-table.md + echo "| $BRANCHES_STATUS | Branches | ${BRANCHES_PERCENT}% | $BRANCHES_COVERED |" >> coverage-table.md + echo "| $FUNCTIONS_STATUS | Functions | ${FUNCTIONS_PERCENT}% | $FUNCTIONS_COVERED |" >> coverage-table.md + echo "| $LINES_STATUS | Lines | ${LINES_PERCENT}% | $LINES_COVERED |" >> coverage-table.md + + - uses: jwalton/gh-find-current-pr@v1 + id: findPr + + - name: Post Coverage Summary as Comment + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + const table = fs.readFileSync('coverage-table.md', 'utf8'); + github.rest.issues.createComment({ + issue_number: process.env.RR_Number, + owner: context.repo.owner, + repo: context.repo.repo, + body: `### Code Coverage - Integration Tests\n\n${table}` + }); + env: + RR_Number: ${{ steps.findPr.outputs.number }} diff --git a/.github/workflows/tests-integration.yml b/.github/workflows/tests-integration.yml index 0bc5a5eefe..8099e0eade 100644 --- a/.github/workflows/tests-integration.yml +++ b/.github/workflows/tests-integration.yml @@ -191,63 +191,14 @@ jobs: sudo mkdir -p /usr/src/app sudo cp -a ./redisinsight/api/. /usr/src/app/ sudo cp -R ./coverages /usr/src/app && sudo chmod 777 -R /usr/src/app - cd /usr/src/app && npx nyc report -t ./coverages -r text -r text-summary > coverage-summary.txt - cp coverage-summary.txt $GITHUB_WORKSPACE/coverage-summary.txt + cd /usr/src/app && npx nyc report -t ./coverages -r text -r text-summary > integration-coverage.txt + cp integration-coverage.txt $GITHUB_WORKSPACE/integration-coverage.txt - - name: Parse Coverage Summary - id: parse-coverage - run: | - # Extract coverage data from the summary - STATEMENTS_PERCENT=$(grep "Statements" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - STATEMENTS_COVERED=$(grep "Statements" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') - BRANCHES_PERCENT=$(grep "Branches" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - BRANCHES_COVERED=$(grep "Branches" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') - FUNCTIONS_PERCENT=$(grep "Functions" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - FUNCTIONS_COVERED=$(grep "Functions" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') - LINES_PERCENT=$(grep "Lines" coverage-summary.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - LINES_COVERED=$(grep "Lines" coverage-summary.txt | awk '{print $4}' | tr -d '\n' | tr -d '()') - - # Determine status based on percentage - get_status() { - if [ "$1" -lt 50 ]; then - echo "🔴" - elif [ "$1" -lt 80 ]; then - echo "🟡" - else - echo "🟢" - fi - } - - STATEMENTS_STATUS=$(get_status $STATEMENTS_PERCENT) - BRANCHES_STATUS=$(get_status $BRANCHES_PERCENT) - FUNCTIONS_STATUS=$(get_status $FUNCTIONS_PERCENT) - LINES_STATUS=$(get_status $LINES_PERCENT) - - # Format as a Markdown table - echo "| Status | Category | Percentage | Covered/Total |" > coverage-table.md - echo "|-------------|-------------|-------------|---------------|" >> coverage-table.md - echo "| $STATEMENTS_STATUS | Statements | ${STATEMENTS_PERCENT}% | $STATEMENTS_COVERED |" >> coverage-table.md - echo "| $BRANCHES_STATUS | Branches | ${BRANCHES_PERCENT}% | $BRANCHES_COVERED |" >> coverage-table.md - echo "| $FUNCTIONS_STATUS | Functions | ${FUNCTIONS_PERCENT}% | $FUNCTIONS_COVERED |" >> coverage-table.md - echo "| $LINES_STATUS | Lines | ${LINES_PERCENT}% | $LINES_COVERED |" >> coverage-table.md - - - uses: jwalton/gh-find-current-pr@v1 - id: findPr - - - name: Post Coverage Summary as Comment - uses: actions/github-script@v7 + - name: Upload integration-coverage as artifact + uses: actions/upload-artifact@v4 with: - script: | - const fs = require('fs'); - const table = fs.readFileSync('coverage-table.md', 'utf8'); - github.rest.issues.createComment({ - issue_number: process.env.RR_Number, - owner: context.repo.owner, - repo: context.repo.repo, - body: `### Code Coverage - Integration Tests\n\n${table}` - }); - env: - RR_Number: ${{ steps.findPr.outputs.number }} + name: integration-coverage + path: integration-coverage.txt - name: Delete Artifact uses: actions/github-script@v7 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index 58732cca52..fd74a6aa03 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -100,6 +100,7 @@ jobs: secrets: inherit with: resource_name: report-fe + type: unit backend-tests: needs: changes @@ -124,6 +125,14 @@ jobs: redis_client: ${{ inputs.redis_client || '' }} debug: ${{ inputs.debug || false }} + integration-tests-coverage: + needs: integration-tests + uses: ./.github/workflows/code-coverage.yml + secrets: inherit + with: + resource_name: integration-coverage + type: integration + # # E2E Approve e2e-approve: runs-on: ubuntu-latest From a5c83e687b8b2b7e563ac20d292370a030107d64 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Wed, 21 May 2025 12:07:59 +0300 Subject: [PATCH 29/31] update workflow --- .github/workflows/code-coverage.yml | 92 +++++++++++++++++++---------- 1 file changed, 60 insertions(+), 32 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 919dceb9da..86556afca7 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -51,60 +51,88 @@ jobs: - name: Parse Coverage Summary id: parse-coverage run: | - # Extract coverage data from the summary - STATEMENTS_PERCENT=$(grep "Statements" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - STATEMENTS_COVERED=$(grep "Statements" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') - BRANCHES_PERCENT=$(grep "Branches" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - BRANCHES_COVERED=$(grep "Branches" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') - FUNCTIONS_PERCENT=$(grep "Functions" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - FUNCTIONS_COVERED=$(grep "Functions" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') - LINES_PERCENT=$(grep "Lines" integration-coverage.txt | awk '{print $3}' | tr -d '\n' | tr -d '%') - LINES_COVERED=$(grep "Lines" integration-coverage.txt | awk '{print $4}' | tr -d '\n' | sed 's/[()]//g') - - # Ensure percentages are treated as numbers - STATEMENTS_PERCENT=$(printf "%.0f" $STATEMENTS_PERCENT) - BRANCHES_PERCENT=$(printf "%.0f" $BRANCHES_PERCENT) - FUNCTIONS_PERCENT=$(printf "%.0f" $FUNCTIONS_PERCENT) - LINES_PERCENT=$(printf "%.0f" $LINES_PERCENT) + # Define a reusable function to extract coverage data + extract_coverage_data() { + local keyword=$1 + local field=$2 + awk "/$keyword/ {print $field}" integration-coverage.txt | tr -d '\n|%' + } # Determine status based on percentage get_status() { - if [ "$1" -lt 50 ]; then - echo "🔴" - elif [ "$1" -lt 80 ]; then - echo "🟡" - else - echo "🟢" - fi + if [ "$(echo "$1 < 50" | bc)" -eq 1 ]; then + echo "🔴" + elif [ "$(echo "$1 < 80" | bc)" -eq 1 ]; then + echo "🟡" + else + echo "🟢" + fi } + # Extract coverage data from the summary + STATEMENTS_PERCENT=$(extract_coverage_data "Statements" '$3') + STATEMENTS_COVERED=$(extract_coverage_data "Statements" '$5') STATEMENTS_STATUS=$(get_status $STATEMENTS_PERCENT) + + BRANCHES_PERCENT=$(extract_coverage_data "Branches" '$3') + BRANCHES_COVERED=$(extract_coverage_data "Branches" '$5') BRANCHES_STATUS=$(get_status $BRANCHES_PERCENT) + + FUNCTIONS_PERCENT=$(extract_coverage_data "Functions" '$3') + FUNCTIONS_COVERED=$(extract_coverage_data "Functions" '$5') FUNCTIONS_STATUS=$(get_status $FUNCTIONS_PERCENT) + + LINES_PERCENT=$(extract_coverage_data "Lines" '$3') + LINES_COVERED=$(extract_coverage_data "Lines" '$5') LINES_STATUS=$(get_status $LINES_PERCENT) # Format as a Markdown table - echo "| Status | Category | Percentage | Covered/Total |" > coverage-table.md - echo "|-------------|-------------|-------------|---------------|" >> coverage-table.md - echo "| $STATEMENTS_STATUS | Statements | ${STATEMENTS_PERCENT}% | $STATEMENTS_COVERED |" >> coverage-table.md - echo "| $BRANCHES_STATUS | Branches | ${BRANCHES_PERCENT}% | $BRANCHES_COVERED |" >> coverage-table.md - echo "| $FUNCTIONS_STATUS | Functions | ${FUNCTIONS_PERCENT}% | $FUNCTIONS_COVERED |" >> coverage-table.md - echo "| $LINES_STATUS | Lines | ${LINES_PERCENT}% | $LINES_COVERED |" >> coverage-table.md + echo "| Status | Category | Percentage | Covered / Total |" > coverage-table.md + echo "|-------------|-------------|-------------|-----------------|" >> coverage-table.md + echo "| $STATEMENTS_STATUS | Statements | ${STATEMENTS_PERCENT}% | ${STATEMENTS_COVERED} |" >> coverage-table.md + echo "| $BRANCHES_STATUS | Branches | ${BRANCHES_PERCENT}% | ${BRANCHES_COVERED} |" >> coverage-table.md + echo "| $FUNCTIONS_STATUS | Functions | ${FUNCTIONS_PERCENT}% | ${FUNCTIONS_COVERED} |" >> coverage-table.md + echo "| $LINES_STATUS | Lines | ${LINES_PERCENT}% | ${LINES_COVERED} |" >> coverage-table.md - uses: jwalton/gh-find-current-pr@v1 id: findPr - - name: Post Coverage Summary as Comment + - name: Post or Update Coverage Summary Comment uses: actions/github-script@v7 with: script: | const fs = require('fs'); const table = fs.readFileSync('coverage-table.md', 'utf8'); - github.rest.issues.createComment({ - issue_number: process.env.RR_Number, + const commentBody = `### Code Coverage - Integration Tests\n\n${table}`; + + // Fetch existing comments on the pull request + const { data: comments } = await github.rest.issues.listComments({ owner: context.repo.owner, repo: context.repo.repo, - body: `### Code Coverage - Integration Tests\n\n${table}` + issue_number: process.env.RR_Number, }); + + // Check if a comment with the same header already exists + const existingComment = comments.find(comment => + comment.body.startsWith('### Code Coverage - Integration Tests') + ); + + if (existingComment) { + // Update the existing comment + await github.rest.issues.updateComment({ + owner: context.repo.owner, + repo: context.repo.repo, + comment_id: existingComment.id, + body: commentBody, + }); + } else { + // Create a new comment + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: process.env.RR_Number, + body: commentBody, + }); + } env: RR_Number: ${{ steps.findPr.outputs.number }} From 532a0a205c66edf64fe7e7b57a6af92e39b59d3a Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Wed, 21 May 2025 12:22:35 +0300 Subject: [PATCH 30/31] revert temp code change --- redisinsight/ui/src/components/base/layout/list/Group.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/redisinsight/ui/src/components/base/layout/list/Group.tsx b/redisinsight/ui/src/components/base/layout/list/Group.tsx index ecf87ce97d..25d7406d1f 100644 --- a/redisinsight/ui/src/components/base/layout/list/Group.tsx +++ b/redisinsight/ui/src/components/base/layout/list/Group.tsx @@ -21,7 +21,7 @@ const Group = ({ if (maxWidth) { newStyle = { ...newStyle, - maxWidth: maxWidth === true ? MAX_FORM_WIDTH - 1 : maxWidth, + maxWidth: maxWidth === true ? MAX_FORM_WIDTH : maxWidth, } } const classes = classNames(ListClassNames.listGroup, className) From c207a2d335fd98fb01513a86749cd9d468f231e6 Mon Sep 17 00:00:00 2001 From: Krum Tyukenov Date: Wed, 21 May 2025 15:01:37 +0300 Subject: [PATCH 31/31] RI-7038: apply review suggestions --- .github/workflows/code-coverage.yml | 12 +++++++----- .github/workflows/tests.yml | 1 + 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/.github/workflows/code-coverage.yml b/.github/workflows/code-coverage.yml index 86556afca7..b437b0d023 100644 --- a/.github/workflows/code-coverage.yml +++ b/.github/workflows/code-coverage.yml @@ -5,15 +5,14 @@ on: type: description: Type of report (unit or integration) type: string - default: unit resource_name: - description: Resource name of report folder + description: Resource name of coverage report type: string jobs: coverage-unit: runs-on: ubuntu-latest - name: Jest tests coverage + name: Unit tests coverage if: ${{ inputs.type == 'unit' }} steps: - uses: actions/checkout@v4 @@ -38,7 +37,7 @@ jobs: coverage-integration: runs-on: ubuntu-latest - name: Jest tests coverage + name: Integration tests coverage if: ${{ inputs.type == 'integration' }} steps: - uses: actions/checkout@v4 @@ -51,7 +50,10 @@ jobs: - name: Parse Coverage Summary id: parse-coverage run: | - # Define a reusable function to extract coverage data + # Extract coverage data from file. + # Example of processed row: + # Statements : 81.75% ( 16130/19730 ) + # field '$3' = 81.75%, field '$5' = 16130 extract_coverage_data() { local keyword=$1 local field=$2 diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml index fd74a6aa03..7040d652c8 100644 --- a/.github/workflows/tests.yml +++ b/.github/workflows/tests.yml @@ -114,6 +114,7 @@ jobs: secrets: inherit with: resource_name: report-be + type: unit integration-tests: needs: changes