From a1ef1103d90f72ec065d5a757e0b42235f1e7c5e Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 08:46:16 -0300 Subject: [PATCH 01/13] add sonar to main workflow --- .github/workflows/main.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bd443c5..c631ba8 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,3 +29,18 @@ jobs: run: cd client && npm run lint #- name: Unit tests # run: npm run test + + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + needs: + - code-checks + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@3.0.0 + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From a7d1bb57d16bd840b1fa3d5b12e00dd86e0df663 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 08:50:40 -0300 Subject: [PATCH 02/13] add sonar to PR workflow --- .github/workflows/pr.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 732930e..600cfff 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -26,11 +26,26 @@ jobs: #- name: Unit tests # run: npm run test + sonarcloud: + name: SonarCloud + runs-on: ubuntu-latest + needs: + - code-checks + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis + - name: SonarCloud Scan + uses: SonarSource/sonarcloud-github-action@master + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + docker-build: name: Build Docker image runs-on: ubuntu-latest needs: - - code-checks + - sonarcloud steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 From 745f7c88b09670651252210b2d576312a0aaa214 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 08:52:13 -0300 Subject: [PATCH 03/13] add sonar-project.properties file --- client/sonar-project.properties | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 client/sonar-project.properties diff --git a/client/sonar-project.properties b/client/sonar-project.properties new file mode 100644 index 0000000..32cfb2a --- /dev/null +++ b/client/sonar-project.properties @@ -0,0 +1,12 @@ +sonar.projectKey=ricardo-campos-org_react-typescript-todolist +sonar.organization=ricardo-campos-org + +# This is the name and version displayed in the SonarCloud UI. +#sonar.projectName=react-typescript-todolist +#sonar.projectVersion=1.0 + +# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. +#sonar.sources=. + +# Encoding of the source code. Default is default system encoding +sonar.sourceEncoding=UTF-8 From bb4e13c3ca2569a81dc3063ce92f91fa82f58e60 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 08:58:12 -0300 Subject: [PATCH 04/13] Update pr.yml --- .github/workflows/pr.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 600cfff..03a54ae 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -36,7 +36,17 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@master + uses: SonarSource/sonarcloud-github-action@3.0.0 + with: + projectBaseDir: client + args: > + -Dsonar.organization=ricardo-campos-org + -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist + -Dsonar.python.coverage.reportPaths=coverage.xml + -Dsonar.sources=src/ + -Dsonar.test.exclusions=tests/** + -Dsonar.tests=src/tests/ + -Dsonar.verbose=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} From 6f81382a8a34dc45c41c9450d61f6b67fe80e139 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 10:11:00 -0300 Subject: [PATCH 05/13] ci: fix action version --- .github/workflows/main.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c631ba8..36b3627 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -40,7 +40,7 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@3.0.0 + uses: SonarSource/sonarcloud-github-action@v3.0.0 env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 03a54ae..dd395da 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -36,7 +36,7 @@ jobs: with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan - uses: SonarSource/sonarcloud-github-action@3.0.0 + uses: SonarSource/sonarcloud-github-action@v3.0.0 with: projectBaseDir: client args: > From 7ec980e98f53aeee0e93f93fe4215c90a5ec6a26 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 10:27:16 -0300 Subject: [PATCH 06/13] test: add basic test case and setup coverage --- .github/workflows/main.yml | 19 ++++++++++++++----- .github/workflows/pr.yml | 19 +++++++++---------- client/src/__test__/App.test.tsx | 13 +++++++++++++ .../src/__test__/__mocks__/authContextMock.ts | 12 ++++++++++++ client/src/__test__/setup.ts | 15 +++++++++++++++ 5 files changed, 63 insertions(+), 15 deletions(-) create mode 100644 client/src/__test__/App.test.tsx create mode 100644 client/src/__test__/__mocks__/authContextMock.ts create mode 100644 client/src/__test__/setup.ts diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 36b3627..a922755 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,8 +7,8 @@ on: workflow_dispatch: jobs: - code-checks: - name: Code Checks + client-code-checks: + name: Client Code Checks runs-on: ubuntu-latest steps: - name: Checkout @@ -30,17 +30,26 @@ jobs: #- name: Unit tests # run: npm run test - sonarcloud: - name: SonarCloud + client-sonarcloud: + name: Client SonarCloud runs-on: ubuntu-latest needs: - - code-checks + - client-code-checks steps: - uses: actions/checkout@v4 with: fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@v3.0.0 + with: + projectBaseDir: client + args: > + -Dsonar.organization=ricardo-campos-org + -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + -Dsonar.sources=src/ + -Dsonar.tests=src/__test__/__ + -Dsonar.verbose=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index dd395da..aacdfe1 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -8,8 +8,8 @@ concurrency: cancel-in-progress: true jobs: - code-checks: - name: Code Checks + client-code-checks: + name: Client Code Checks runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 @@ -26,11 +26,11 @@ jobs: #- name: Unit tests # run: npm run test - sonarcloud: - name: SonarCloud + client-sonarcloud: + name: Client SonarCloud runs-on: ubuntu-latest needs: - - code-checks + - client-code-checks steps: - uses: actions/checkout@v4 with: @@ -42,20 +42,19 @@ jobs: args: > -Dsonar.organization=ricardo-campos-org -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist - -Dsonar.python.coverage.reportPaths=coverage.xml + -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ - -Dsonar.test.exclusions=tests/** - -Dsonar.tests=src/tests/ + -Dsonar.tests=src/__test__/__ -Dsonar.verbose=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} - docker-build: + client-docker-build: name: Build Docker image runs-on: ubuntu-latest needs: - - sonarcloud + - client-sonarcloud steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3 diff --git a/client/src/__test__/App.test.tsx b/client/src/__test__/App.test.tsx new file mode 100644 index 0000000..6f5e9a7 --- /dev/null +++ b/client/src/__test__/App.test.tsx @@ -0,0 +1,13 @@ +import { test } from "vitest"; +import App from "../App"; +import { render } from "@testing-library/react"; +import AuthContext from "../context/AuthContext"; +import authContextMock from "./__mocks__/authContextMock"; + +test('Renders the app', () => { + render( + + + + ); +}); diff --git a/client/src/__test__/__mocks__/authContextMock.ts b/client/src/__test__/__mocks__/authContextMock.ts new file mode 100644 index 0000000..3ba2542 --- /dev/null +++ b/client/src/__test__/__mocks__/authContextMock.ts @@ -0,0 +1,12 @@ +import { vi } from "vitest"; + +const authContextMock = { + signed: true, + user: undefined, + checkCurrentAuthUser: vi.fn(), + signIn: vi.fn(), + signOut: vi.fn(), + isAdmin: false +}; + +export default authContextMock; diff --git a/client/src/__test__/setup.ts b/client/src/__test__/setup.ts new file mode 100644 index 0000000..3be45d6 --- /dev/null +++ b/client/src/__test__/setup.ts @@ -0,0 +1,15 @@ +import { afterEach } from 'vitest'; +import { cleanup } from '@testing-library/react'; + +// runs a cleanup after each test case (e.g. clearing jsdom) +afterEach(() => { + cleanup(); +}); + +window.matchMedia = window.matchMedia || function() { + return { + matches: false, + addListener: function() {}, + removeListener: function() {} + }; +}; From 0e6c3ffb70fead5ebdf301d93ac95206eb95b2a3 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 10:29:12 -0300 Subject: [PATCH 07/13] ci: fix test directory --- .github/workflows/main.yml | 6 +++--- .github/workflows/pr.yml | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a922755..1928c6a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,8 +27,8 @@ jobs: run: cd client && npm run build - name: Lint run: cd client && npm run lint - #- name: Unit tests - # run: npm run test + - name: Unit tests + run: cd client && npm run test:coverage client-sonarcloud: name: Client SonarCloud @@ -48,7 +48,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ - -Dsonar.tests=src/__test__/__ + -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index aacdfe1..46549b7 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -23,8 +23,8 @@ jobs: run: cd client && npm run build - name: Lint run: cd client && npm run lint - #- name: Unit tests - # run: npm run test + - name: Unit tests + run: cd client && npm run test:coverage client-sonarcloud: name: Client SonarCloud @@ -44,7 +44,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ - -Dsonar.tests=src/__test__/__ + -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any From 8f5ca9bce48d03b0ba880f261cb02b2bbd007b24 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 10:36:15 -0300 Subject: [PATCH 08/13] ci: exclude setup tests ts file from sonar --- .github/workflows/main.yml | 1 + .github/workflows/pr.yml | 1 + 2 files changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1928c6a..172ab77 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,6 +48,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ + -Dsonar.test.exclusions=src/__test__/setup.ts -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 46549b7..6aedf20 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -44,6 +44,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ + -Dsonar.test.exclusions=src/__test__/setup.ts -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: From 004cbc29b7ad0908a017a61f0b3f33ab46e5dcaa Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 10:39:23 -0300 Subject: [PATCH 09/13] ci: exclude mocks files from sonar --- .github/workflows/main.yml | 2 +- .github/workflows/pr.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 172ab77..63287b1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ - -Dsonar.test.exclusions=src/__test__/setup.ts + -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/ -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 6aedf20..2e55228 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -44,7 +44,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ - -Dsonar.test.exclusions=src/__test__/setup.ts + -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/ -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: From df287c4de0dcfaa9fc6bc05bdfa73da4424218fe Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 10:44:57 -0300 Subject: [PATCH 10/13] ci: delete ci, not needed and another attempt to fix sonar analysis --- .github/workflows/ci.yml | 36 ------------------------------------ .github/workflows/main.yml | 2 +- .github/workflows/pr.yml | 2 +- 3 files changed, 2 insertions(+), 38 deletions(-) delete mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml deleted file mode 100644 index d2f67ef..0000000 --- a/.github/workflows/ci.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: CI - -on: - push: - branches: - - '*' - - '*/*' - -jobs: - code-checks: - name: Code Checks - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v4 - with: - fetch-depth: 0 - ref: ${{ github.event.pull_request.head.ref }} - - - name: Set up Node - uses: actions/setup-node@v4 - with: - path: ~/.npm - key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} - node-version: '20' - restore-keys: | - ${{ runner.os }}-node- - - - name: Clean and Install - run: cd client && npm ci - - name: Build - run: cd client && npm run build - - name: Lint - run: cd client && npm run lint - #- name: Unit tests - # run: npm run test diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 63287b1..c1a4e1e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -48,7 +48,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ - -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/ + -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/** -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 2e55228..db121f4 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -44,7 +44,7 @@ jobs: -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info -Dsonar.sources=src/ - -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/ + -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/** -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: From 1295257d1a9d486ac4cd412ae8da93dc5dfd3653 Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 11:23:31 -0300 Subject: [PATCH 11/13] ci: fix sonar exclusion --- .github/workflows/main.yml | 3 ++- .github/workflows/pr.yml | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1a4e1e..be40a99 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -47,8 +47,9 @@ jobs: -Dsonar.organization=ricardo-campos-org -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + -Dsonar.typescript.tsconfigPaths=tsconfig.json -Dsonar.sources=src/ - -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/** + -Dsonar.exclusions=src/__test__/** -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index db121f4..8e30423 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -43,8 +43,9 @@ jobs: -Dsonar.organization=ricardo-campos-org -Dsonar.projectKey=ricardo-campos-org_react-typescript-todolist -Dsonar.javascript.lcov.reportPaths=coverage/lcov.info + -Dsonar.typescript.tsconfigPaths=tsconfig.json -Dsonar.sources=src/ - -Dsonar.test.exclusions=src/__test__/setup.ts,src/__test__/__mocks__/** + -Dsonar.exclusions=src/__test__/** -Dsonar.tests=src/__test__/ -Dsonar.verbose=true env: From e065e3deb59d6da1c078f2403eac24c1d5acf3ce Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 11:42:15 -0300 Subject: [PATCH 12/13] ci: fix test and workflows --- .github/workflows/main.yml | 2 +- .github/workflows/pr.yml | 4 ++-- client/sonar-project.properties | 12 ------------ client/src/__test__/App.test.tsx | 1 + client/tsconfig.json | 3 +++ 5 files changed, 7 insertions(+), 15 deletions(-) delete mode 100644 client/sonar-project.properties diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index be40a99..4745367 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -51,7 +51,7 @@ jobs: -Dsonar.sources=src/ -Dsonar.exclusions=src/__test__/** -Dsonar.tests=src/__test__/ - -Dsonar.verbose=true + -Dsonar.verbose=false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 8e30423..9a517c9 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -47,13 +47,13 @@ jobs: -Dsonar.sources=src/ -Dsonar.exclusions=src/__test__/** -Dsonar.tests=src/__test__/ - -Dsonar.verbose=true + -Dsonar.verbose=false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} client-docker-build: - name: Build Docker image + name: Build Client Docker image runs-on: ubuntu-latest needs: - client-sonarcloud diff --git a/client/sonar-project.properties b/client/sonar-project.properties deleted file mode 100644 index 32cfb2a..0000000 --- a/client/sonar-project.properties +++ /dev/null @@ -1,12 +0,0 @@ -sonar.projectKey=ricardo-campos-org_react-typescript-todolist -sonar.organization=ricardo-campos-org - -# This is the name and version displayed in the SonarCloud UI. -#sonar.projectName=react-typescript-todolist -#sonar.projectVersion=1.0 - -# Path is relative to the sonar-project.properties file. Replace "\" by "/" on Windows. -#sonar.sources=. - -# Encoding of the source code. Default is default system encoding -sonar.sourceEncoding=UTF-8 diff --git a/client/src/__test__/App.test.tsx b/client/src/__test__/App.test.tsx index 6f5e9a7..b63206d 100644 --- a/client/src/__test__/App.test.tsx +++ b/client/src/__test__/App.test.tsx @@ -1,3 +1,4 @@ +import React from 'react'; import { test } from "vitest"; import App from "../App"; import { render } from "@testing-library/react"; diff --git a/client/tsconfig.json b/client/tsconfig.json index 50daaae..ac1c0ab 100644 --- a/client/tsconfig.json +++ b/client/tsconfig.json @@ -25,5 +25,8 @@ }, "include": [ "src" + ], + "exclude": [ + "src/__test__/" ] } From d94becd72151e0b20df97ee626254fae04abac9a Mon Sep 17 00:00:00 2001 From: Ricardo Campos Date: Fri, 20 Sep 2024 11:45:11 -0300 Subject: [PATCH 13/13] ci: add sonar to the same test coverage workflow --- .github/workflows/main.yml | 12 +----------- .github/workflows/pr.yml | 12 +----------- 2 files changed, 2 insertions(+), 22 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 4745367..43d9e0b 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,16 +29,6 @@ jobs: run: cd client && npm run lint - name: Unit tests run: cd client && npm run test:coverage - - client-sonarcloud: - name: Client SonarCloud - runs-on: ubuntu-latest - needs: - - client-code-checks - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@v3.0.0 with: @@ -54,4 +44,4 @@ jobs: -Dsonar.verbose=false env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any - SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} + SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }} diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 9a517c9..64f46f8 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -25,16 +25,6 @@ jobs: run: cd client && npm run lint - name: Unit tests run: cd client && npm run test:coverage - - client-sonarcloud: - name: Client SonarCloud - runs-on: ubuntu-latest - needs: - - client-code-checks - steps: - - uses: actions/checkout@v4 - with: - fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis - name: SonarCloud Scan uses: SonarSource/sonarcloud-github-action@v3.0.0 with: @@ -56,7 +46,7 @@ jobs: name: Build Client Docker image runs-on: ubuntu-latest needs: - - client-sonarcloud + - client-code-checks steps: - uses: actions/checkout@v4 - uses: docker/setup-buildx-action@v3