Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add code coverage checks and badges #99

Merged
merged 9 commits into from
May 31, 2023
Merged
21 changes: 20 additions & 1 deletion .github/workflows/tests-ci.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Run Tests in Node and Browsers
name: Continuous Integration

on:
push:
Expand All @@ -12,6 +12,20 @@ on:
workflow_dispatch:

jobs:
security-audit:
runs-on: ubuntu-latest
steps:
- name: Checkout source
uses: actions/checkout@8e5e7e5ab8b370d6c329ec480221332ada57f0ab # v3.5.2

- name: Set up Node.js
uses: actions/setup-node@64ed1c7eab4cce3362f8c340dee64e5eaeef8f7c # v3.6.0
with:
node-version: 18

- name: Report known vulnerabilities
run: npm audit

test-with-node:
runs-on: ubuntu-latest
steps:
Expand All @@ -36,6 +50,11 @@ jobs:
- name: Run tests for all packages
run: npm run test:node --ws

- name: Upload test coverage to Codecov
uses: codecov/codecov-action@eaaf4bedf32dbdc6b720b63067d99c4d77d6047d # v3.1.4
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}

test-with-browsers:
# Run browser tests using macOS so that WebKit tests don't fail under a Linux environment
runs-on: macos-latest
Expand Down
7 changes: 0 additions & 7 deletions .vscode/launch.json

This file was deleted.

25 changes: 23 additions & 2 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

There are many ways to be an open source contributor, and we're here to help you on your way! You may:

- Propose ideas in our Web5 [discord](https://discord.com/channels/937858703112155166/969272658501976117) channel
- Propose ideas in our Web5 [Discord](https://discord.com/channels/937858703112155166/969272658501976117) channel
- Raise an issue or feature request in our [issue tracker](https://github.com/TBD54566975/web5-js/issues)
- Help another contributor with one of their questions, or a code review
- Suggest improvements to our Getting Started documentation by supplying a Pull Request
Expand Down Expand Up @@ -96,17 +96,38 @@ to your valuable work:
having trouble - feel free to ask a member or the community for help or leave the commits as-is, and flag that you'd like
rebasing assistance in your PR! We're here to support you.
- Open a PR in the project to bring in the code from your feature branch.
- [Codecov](https://app.codecov.io/github/TBD54566975/web5-js) will automatically comment on your pull request showing the impact to the overall test coverage.
- The maintainers noted in the [`CODEOWNERS`](https://github.com/TBD54566975/web5-js/blob/main/CODEOWNERS) file will review your PR and optionally
open a discussion about its contents before moving forward.
- Remain responsive to follow-up questions, be open to making requested changes, and...
You're a contributor!
- And remember to respect everyone in our global development community. Guidelines
are established in our [`CODE_OF_CONDUCT.md`](https://github.com/TBD54566975/web5-js/blob/main/CODE_OF_CONDUCT.md).

### Running tests
### Running Tests

- Running the `npm run test:node --ws` command from the root of the project will run all tests using node.
- This is run via CI whenever a pull request is opened, or a commit is pushed to a branch that has an open PR
- Running the `npm run test:browser --ws` command from the root of the project will run the tests in a browser environment
- Please make sure there are no failing tests before switching your PR to ready for review! We hope to have this automated via a github action very soon.
- You can also run `npm run test:node -w=packages/DIR` or `npm run test:browser -w=packages/DIR` from the root of the project to run tests for a single package. For example, to run the tests only for the `web5` package run `npm run test:node -w=packages/web5`.

### Test Coverage Expectations

To maintain the robustness and reliability of the codebase, we highly value test coverage.

- [Codecov](https://app.codecov.io/github/TBD54566975/web5-js) is used to track
the coverage of our tests and will automatically comment on every pull request
showing the impact to overall coverage.
- We have a strong expectation for every pull request to strive for 100% test
coverage. This means that all new code you contribute should be fully covered
by tests, and it should not decrease the overall test coverage of the project.
- If your pull request introduces new features or changes existing logic, please
ensure you include comprehensive tests that cover edge-cases and failure
scenarios. This ensures that your contributions are of the highest quality and
safeguards our codebase against potential bugs or breaking changes.
- Thorough tests are also a great way to better understand your proposed changes.
- If you encounter any difficulties while writing tests, don't hesitate to reach
out for help or guidance in our Web5
[Discord](https://discord.com/channels/937858703112155166/969272658501976117)
channel.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# Web5 JS SDK

[![npm version](https://badge.fury.io/js/web5-js.svg)](https://www.npmjs.com/package/@tbd54566975/web5)

[![NPM](https://img.shields.io/npm/v/@tbd54566975/web5.svg?style=flat-square&logo=npm&logoColor=FFFFFF&color=FFEC19&santize=true)](https://www.npmjs.com/package/@tbd54566975/web5)
[![Build Status](https://img.shields.io/github/actions/workflow/status/TBD54566975/web5-js/tests-ci.yml?branch=main&logo=github&label=ci&logoColor=FFFFFF&style=flat-square)](https://github.com/TBD54566975/web5-js/actions/workflows/tests-ci.yml)
[![Coverage](https://img.shields.io/codecov/c/gh/frankhinek/test-web5-js/main?logo=codecov&logoColor=FFFFFF&style=flat-square&token=YI87CKF1LI)](https://codecov.io/github/TBD54566975/web5-js)
[![License](https://img.shields.io/npm/l/@tbd54566975/web5.svg?style=flat-square&color=24f2ff&logo=apache&logoColor=FFFFFF&santize=true)](https://github.com/TBD54566975/web5-js/blob/main/LICENSE)
[![Chat](https://img.shields.io/badge/chat-on%20discord-7289da.svg?style=flat-square&color=9a1aff&logo=discord&logoColor=FFFFFF&sanitize=true)](https://discord.com/channels/937858703112155166/969272658501976117)

Making developing with Web5 components at least 5 times easier to work with.

Expand Down
45 changes: 45 additions & 0 deletions codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
comment:
layout: "header, diff, components"

component_management:
default_rules:
statuses:
- type: project
target: auto # auto compares coverage to the previous base commit
threshold: 5% # allows a 5% drop from the previous base commit coverage
- type: patch
target: 100 # every PR opened should strive for full test coverage

individual_components:
- component_id: package_crypto
name: crypto
paths: ["packages/crypto/**"]

- component_id: package_dids
name: dids
paths: ["packages/dids/**"]

- component_id: package-web5
name: web5
paths: ["packages/web5/**"]

- component_id: package-web5-agent
name: web5-agent
paths: ["packages/web5-agent/**"]

- component_id: package-web5-proxy-agent
name: web5-proxy-agent
paths: ["packages/web5-proxy-agent/**"]

- component_id: package-web5-user-agent
name: web5-user-agent
paths: ["packages/web5-user-agent/**"]

coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true # Don't gate PRs based on Codecov passing thresholds
Loading