Repository: OpenZeppelin/cairo-contracts (language: python)

Issue:
Measure test coverage
**🧐 Motivation**
Having clear test coverage is critical to know the quality of our codebase 

**📝 Details**
With the migration to starknet foundry we gained a lot of things, but lost the ability to measure test coverage. Now that [cairo-coverage](https://github.com/software-mansion/cairo-coverage) is available we should look and see if it is mature enough to be integrated into the codebase.
This should be included as part of the CI and coverage reports uploaded to Codecov.




Discussion / hints:
Blocked by #1135 - we need to upgrade our starknet foundry version

Fix patch:
diff --git a/Scarb.toml b/Scarb.toml
index f1e2bda24..1ac32290d 100644
--- a/Scarb.toml
+++ b/Scarb.toml
@@ -74,3 +74,8 @@ sort-module-level-items = true
 
 [tool]
 fmt.workspace = true
+
+[profile.dev.cairo]
+unstable-add-statements-functions-debug-info = true
+unstable-add-statements-code-locations-debug-info = true
+inlining-strategy= "avoid"
diff --git a/codecov.yml b/codecov.yml
new file mode 100644
index 000000000..dacdbb20d
--- /dev/null
+++ b/codecov.yml
@@ -0,0 +1,30 @@
+comment:
+  layout: "diff, files, header, footer"
+  behavior: default
+
+coverage:
+  # The value range where you want the value to be green
+  # Hold ourselves to a high bar.
+  range: 90..100
+  status:
+    project:
+      coverage:
+        # Use the coverage from the base commit (pull request base) coverage to compare against.
+        # Once we have a baseline we can be more strict.
+        target: auto
+        threshold: 2%
+    patch:
+      default:
+        # Require new code to have 90%+ coverage.
+        target: 90%
+        threshold: 2%
+
+ignore:
+  - "**/tests/**"
+  - "docs/"
+  - "scripts/"
+  - "packages/test_common/"
+
+github_checks:
+  annotations: false
+  
\ No newline at end of file


Test patch:
diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml
index f9924e6f1..e540ab03d 100644
--- a/.github/workflows/test.yml
+++ b/.github/workflows/test.yml
@@ -1,38 +1,57 @@
 name: Lint and test
+# This workflow runs linting and tests on all pull requests and pushes to the main branch.
+# It includes Markdown linting, Cairo formatting checks, running tests with coverage,
+# and uploading the coverage report to Codecov.
 
 on:
   pull_request:
   push:
     branches:
-    - main
+      - main
 
 jobs:
   lint_and_test:
     name: Lint and test
     runs-on: ubuntu-latest
     steps:
-    - uses: actions/checkout@v4
-    - name: Extract scarb version
-      run: |
-        SCARB_VERSION=$(grep 'scarb-version = ' Scarb.toml | sed 's/scarb-version = "\(.*\)"/\1/')
-        echo "SCARB_VERSION=$SCARB_VERSION" >> "$GITHUB_ENV"
-    - uses: software-mansion/setup-scarb@v1
-      with:
-        scarb-version: ${{ env.SCARB_VERSION }}
-    - name: Extract foundry version
-      run: |
-        FOUNDRY_VERSION=$(grep 'snforge_std = ' Scarb.toml | sed 's/snforge_std = "\(.*\)"/\1/')
-        echo "FOUNDRY_VERSION=$FOUNDRY_VERSION" >> "$GITHUB_ENV"
-    - uses: foundry-rs/setup-snfoundry@v3
-      with:
-        starknet-foundry-version: ${{ env.FOUNDRY_VERSION }}
-    - name: Markdown lint
-      uses: DavidAnson/markdownlint-cli2-action@db43aef879112c3119a410d69f66701e0d530809 # v16
-      with:
-        globs: |
-          *.md
-          !PULL_REQUEST_TEMPLATE.md
-    - name: Cairo lint
-      run: scarb fmt --check --workspace
-    - name: Cairo test
-      run: snforge test --workspace
+      - uses: actions/checkout@v4
+
+      - name: Extract scarb version
+        run: |
+          SCARB_VERSION=$(grep 'scarb-version = ' Scarb.toml | sed 's/scarb-version = "\(.*\)"/\1/')
+          echo "SCARB_VERSION=$SCARB_VERSION" >> "$GITHUB_ENV"
+
+      - uses: software-mansion/setup-scarb@v1
+        with:
+          scarb-version: ${{ env.SCARB_VERSION }}
+
+      - name: Extract foundry version
+        run: |
+          FOUNDRY_VERSION=$(grep 'snforge_std = ' Scarb.toml | sed 's/snforge_std = "\(.*\)"/\1/')
+          echo "FOUNDRY_VERSION=$FOUNDRY_VERSION" >> "$GITHUB_ENV"
+
+      - uses: foundry-rs/setup-snfoundry@v3
+        with:
+          starknet-foundry-version: ${{ env.FOUNDRY_VERSION }}
+
+      - name: Install cairo-coverage
+        run: curl -L https://raw.githubusercontent.com/software-mansion/cairo-coverage/main/scripts/install.sh | sh
+
+      - name: Markdown lint
+        uses: DavidAnson/markdownlint-cli2-action@db43aef879112c3119a410d69f66701e0d530809 # v16
+        with:
+          globs: |
+            *.md
+            !PULL_REQUEST_TEMPLATE.md
+
+      - name: Cairo lint
+        run: scarb fmt --check --workspace
+
+      - name: Run tests and generate coverage report
+        run: snforge test --workspace --coverage
+
+      - name: Upload coverage to Codecov
+        uses: codecov/codecov-action@v4
+        with:
+          file: ./coverage.lcov
+          token: ${{ secrets.CODECOV_TOKEN }}