From 0d507c401ee0389ff3bf498ba4c86cca46621130 Mon Sep 17 00:00:00 2001 From: Urvashi Sharma Date: Tue, 28 Jan 2025 10:07:04 +0530 Subject: [PATCH 1/2] chore(testing): Migrate code coverage to vitest-coverage-report-action --- .github/workflows/actions.yml | 21 --------------------- .github/workflows/coverage.yml | 21 +++++++++++++++++++++ .github/workflows/test.yml | 32 ++++++++++++++++++++++++++++++++ vite.config.ts | 6 ++++++ 4 files changed, 59 insertions(+), 21 deletions(-) create mode 100644 .github/workflows/coverage.yml create mode 100644 .github/workflows/test.yml diff --git a/.github/workflows/actions.yml b/.github/workflows/actions.yml index 12a5c30b6..a55b275b3 100644 --- a/.github/workflows/actions.yml +++ b/.github/workflows/actions.yml @@ -7,27 +7,6 @@ on: branches: - main jobs: - test: - name: Test - runs-on: ubuntu-latest - strategy: - matrix: - node-version: [18.x] - steps: - - uses: actions/checkout@v4 - - name: Use Node.js ${{ matrix.node-version }} - uses: actions/setup-node@v4 - with: - node-version: ${{ matrix.node-version }} - cache: "yarn" - - name: Install - run: yarn install --immutable - - run: yarn test --coverage - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v5 - with: - token: ${{ secrets.CODECOV_TOKEN }} - fail_ci_if_error: true prettier: name: Check Prettier runs-on: ubuntu-latest diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 000000000..79b6e9685 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,21 @@ +name: Report Coverage +on: + workflow_run: + workflows: ["Test"] + types: + - completed +jobs: + report: + runs-on: ubuntu-latest + permissions: + actions: read + contents: read + pull-requests: write + steps: + - uses: actions/checkout@v4 + - uses: actions/download-artifact@v4 + with: + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + - name: "Report Coverage" + uses: davelosert/vitest-coverage-report-action@v2 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 000000000..a4a637d9c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,32 @@ +name: Test +on: + push: + branches: + - main + pull_request: + branches: + - main +jobs: + test: + name: Test + runs-on: ubuntu-latest + permissions: + contents: read + strategy: + matrix: + node-version: [18.x] + steps: + - uses: actions/checkout@v4 + - name: Use Node.js ${{ matrix.node-version }} + uses: actions/setup-node@v4 + with: + node-version: ${{ matrix.node-version }} + cache: "yarn" + - name: Install + run: yarn install --immutable + - run: yarn test --coverage.enabled true + - name: "Upload Coverage" + uses: actions/upload-artifact@v4 + with: + name: coverage + path: coverage diff --git a/vite.config.ts b/vite.config.ts index 1f44540d9..e9dfbc85b 100644 --- a/vite.config.ts +++ b/vite.config.ts @@ -74,6 +74,12 @@ export default defineConfig(({ mode }) => { include: ["src/**/*.[jt]s?(x)"], reporter: ["text", "json-summary", "json", "cobertura"], reportOnFailure: true, + thresholds: { + lines: 95, + statements: 95, + functions: 95, + branches: 90, + }, }, environment: "happy-dom", globals: true, From b8a7af5ced22f8399f709041b48b0948851e66cf Mon Sep 17 00:00:00 2001 From: Urvashi Sharma Date: Tue, 28 Jan 2025 10:41:13 +0530 Subject: [PATCH 2/2] chore(testing): Remove unused codecov configuration file --- HACKING.md | 8 ++------ README.md | 1 - codecov.yml | 5 ----- 3 files changed, 2 insertions(+), 12 deletions(-) delete mode 100644 codecov.yml diff --git a/HACKING.md b/HACKING.md index 47d334422..0370a8b9d 100644 --- a/HACKING.md +++ b/HACKING.md @@ -212,10 +212,6 @@ should be used. The dashboard is unit tested and interaction tested using [Vitest](https://vitest.dev/) and [React Testing Library](https://testing-library.com/). -[Codecov](https://codecov.io/) is used to monitor test coverage on PRs and is -currently set to allow 90% coverage across the codebase, so new code should have -strong test coverage to maintain this amount. - #### Test factories The dashboard uses test factories instead of data dumps to allow each test to @@ -268,6 +264,7 @@ remove controllers as necessary and provides a way to have multiple controllers running at once (with different Juju versions if needed). There are three main types of deployment: + - [Juju controller](#juju-controller) - [Juju with Kubernetes](./docs/multipass-microk8s.md) - [JIMM controller](#jimm-controller) @@ -655,6 +652,7 @@ cp public/config.js public/config.local.js ``` Edit the file: + ```shell nano public/config.local.js ``` @@ -687,8 +685,6 @@ Each time you start the multipass container you need to do the following: 2. Recreate the JIMM environment with `make qa-lxd`. 3. Now you can start the dashboard as normal. - - ### Self signed certificates The Juju controller uses a self-signed certificate for the API. To allow your diff --git a/README.md b/README.md index 573256627..3b425502f 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,6 @@
-[![codecov](https://codecov.io/github/canonical/juju-dashboard/branch/main/graph/badge.svg?token=jpxOQiONwS)](https://codecov.io/github/canonical/juju-dashboard) [![Licence: LGPLv3](https://img.shields.io/badge/License-LGPL_v3-blue.svg)](/LICENSE.md)
diff --git a/codecov.yml b/codecov.yml deleted file mode 100644 index 9ec7ff829..000000000 --- a/codecov.yml +++ /dev/null @@ -1,5 +0,0 @@ -coverage: - status: - project: - default: - target: 90%