Kaynağa Gözat

Add Foundry tests to coverage (#5098)

Co-authored-by: Hadrien Croubois <hadrien.croubois@gmail.com>
cairo 1 yıl önce
ebeveyn
işleme
ccc110360f
3 değiştirilmiş dosya ile 22 ekleme ve 1 silme
  1. 3 0
      .codecov.yml
  2. 1 1
      package.json
  3. 18 0
      scripts/checks/coverage.sh

+ 3 - 0
.codecov.yml

@@ -10,3 +10,6 @@ coverage:
     project:
       default:
         threshold: 1%
+ignore:
+  - "test"
+  - "contracts/mocks"

+ 1 - 1
package.json

@@ -10,7 +10,7 @@
   "scripts": {
     "compile": "hardhat compile",
     "compile:harnesses": "env SRC=./certora/harnesses hardhat compile",
-    "coverage": "env COVERAGE=true hardhat coverage",
+    "coverage": "scripts/checks/coverage.sh",
     "docs": "npm run prepare-docs && oz-docs",
     "docs:watch": "oz-docs watch contracts docs/templates docs/config.js",
     "prepare": "git config --local core.hooksPath .githooks",

+ 18 - 0
scripts/checks/coverage.sh

@@ -0,0 +1,18 @@
+#!/usr/bin/env bash
+
+set -euo pipefail
+
+export COVERAGE=true
+export FOUNDRY_FUZZ_RUNS=10
+
+# Hardhat coverage
+hardhat coverage
+
+if [ "${CI:-"false"}" == "true" ]; then
+  # Foundry coverage
+  forge coverage --report lcov
+  # Remove zero hits
+  sed -i '/,0/d' lcov.info
+fi
+
+# Reports are then uploaded to Codecov automatically by workflow, and merged.