From e0dd58fb862939163cc0da923052d08828c1557a Mon Sep 17 00:00:00 2001
From: sanyu1225 <pan831225@gmail.com>
Date: Thu, 21 Dec 2023 17:52:55 +0800
Subject: [PATCH 1/2] feat: codecov config

---
 .github/workflows/test.yml |  9 +++++--
 codecov.yml                | 51 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 58 insertions(+), 2 deletions(-)
 create mode 100644 codecov.yml

diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index 07888c6d..c56c9bb1 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -34,8 +34,13 @@ jobs:
         id: testWithCache
         run: yarn turbo lint test build --cache-dir=.turbo
         continue-on-error: true
-      
+
+      - name: Upload coverage to Codecov
+        uses: codecov/codecov-action@v3
+        with:
+          flags: UnitTests
+          token: ${{ secrets.CODECOV_TOKEN }}
+
       - name: Try to do again without cache
         if: failure() && steps.testWithCache.outcome == 'failure'
         run: yarn turbo lint test build --force --cache-dir=.turbo
-        
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 00000000..37931f72
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,51 @@
+coverage:
+  status:
+    project:
+      default:
+        target: 80%
+        threshold: 1%
+    patch:
+      default:
+        target: auto
+        threshold: 5%
+
+component_management:
+  default_rules: # default rules that will be inherited by all components
+    statuses:
+      - type: project
+        target: 80%
+      - type: patch
+        target: 80%
+
+  individual_components:
+    - component_id: 'blocto-sdk'
+      paths:
+        - /packages/blocto-sdk/src/
+    - component_id: 'dappauth'
+      paths:
+        - /packages/dappauth/src/
+    - component_id: 'aptos-wallet-adapter-plugin'
+      paths:
+        - /adapters/aptos-wallet-adapter-plugin/src/
+    - component_id: 'connectkit-connector'
+      paths:
+        - /adapters/connectkit-connector/src/
+    - component_id: 'rainbowkit-connector'
+      paths:
+        - /adapters/rainbowkit-connector/src/
+    - component_id: 'wagmi-connector'
+      paths:
+        - /adapters/wagmi-connector/src/
+    - component_id: 'web3-react-connector'
+      paths:
+        - /adapters/web3-react-connector/src/
+    - component_id: 'web3modal-connector'
+      paths:
+        - /adapters/web3modal-connector/src/
+
+comment:
+  layout: 'header, diff, flags, components'
+  behavior: 'default'
+  require_changes: false
+  require_base: no
+  require_head: no

From 4ee0117aeb696928d30cc7a99160f64154df0b43 Mon Sep 17 00:00:00 2001
From: sanyu1225 <pan831225@gmail.com>
Date: Fri, 22 Dec 2023 14:35:03 +0800
Subject: [PATCH 2/2] feat: jest show coverage in console

---
 adapters/aptos-wallet-adapter-plugin/package.json | 2 +-
 adapters/rainbowkit-connector/package.json        | 1 +
 packages/blocto-sdk/package.json                  | 2 +-
 3 files changed, 3 insertions(+), 2 deletions(-)

diff --git a/adapters/aptos-wallet-adapter-plugin/package.json b/adapters/aptos-wallet-adapter-plugin/package.json
index b54036ee..00faba6a 100644
--- a/adapters/aptos-wallet-adapter-plugin/package.json
+++ b/adapters/aptos-wallet-adapter-plugin/package.json
@@ -14,7 +14,7 @@
   },
   "scripts": {
     "build": "tsup src/index.ts --format esm,cjs --dts",
-    "test": "jest",
+    "test": "jest --coverage=true --coverage-reporters=text",
     "lint": "eslint src --ext .ts"
   },
   "dependencies": {
diff --git a/adapters/rainbowkit-connector/package.json b/adapters/rainbowkit-connector/package.json
index 72ee4322..a87a8faf 100644
--- a/adapters/rainbowkit-connector/package.json
+++ b/adapters/rainbowkit-connector/package.json
@@ -30,6 +30,7 @@
   },
   "scripts": {
     "build": "tsup src/index.ts --format esm,cjs --dts",
+    "test": "jest --coverage=true --coverage-reporters=text",
     "lint": "eslint src --ext .ts"
   },
   "dependencies": {
diff --git a/packages/blocto-sdk/package.json b/packages/blocto-sdk/package.json
index 30159fba..1fa5950f 100644
--- a/packages/blocto-sdk/package.json
+++ b/packages/blocto-sdk/package.json
@@ -21,7 +21,7 @@
     "build": "NODE_ENV=production rollup -c",
     "clean": "rimraf dist",
     "lint": "eslint --ext .js,.ts src/",
-    "test": "jest",
+    "test": "jest --coverage=true --coverage-reporters=text",
     "prepublishOnly": "npm-run-all clean build",
     "rollup-watch": "NODE_ENV=development rollup -c rollup.config.dev.js --watch",
     "serve": "live-server --port=7777 --https=dev-cert/index.js dev",