Skip to content

Commit

Permalink
Merge pull request #1839 from Ninfa-Jeon/migrate-code-coverage
Browse files Browse the repository at this point in the history
chore(testing): Migrate code coverage to vitest-coverage-report-action
  • Loading branch information
Ninfa-Jeon authored Jan 28, 2025
2 parents e467ef3 + b8a7af5 commit b9db5b4
Show file tree
Hide file tree
Showing 7 changed files with 61 additions and 33 deletions.
21 changes: 0 additions & 21 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/coverage.yml
Original file line number Diff line number Diff line change
@@ -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
32 changes: 32 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -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
8 changes: 2 additions & 6 deletions HACKING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -655,6 +652,7 @@ cp public/config.js public/config.local.js
```

Edit the file:

```shell
nano public/config.local.js
```
Expand Down Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

<br />

[![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)

<br />
Expand Down
5 changes: 0 additions & 5 deletions codecov.yml

This file was deleted.

6 changes: 6 additions & 0 deletions vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit b9db5b4

Please sign in to comment.