From 882f4c3b4f659efa943042da1bca31c6f74c9690 Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Tue, 17 Sep 2024 15:17:58 -0400 Subject: [PATCH 01/11] add coverage step --- .github/workflows/test.yml | 61 ++++++++++++++++++++++---------------- Scarb.toml | 5 ++++ 2 files changed, 40 insertions(+), 26 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index f9924e6f1..881e38dfd 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -1,38 +1,47 @@ 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 + workflow_dispatch: 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: 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 }} 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" From a27db053de45f785889ea5e71373484fec115a23 Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Tue, 17 Sep 2024 15:21:49 -0400 Subject: [PATCH 02/11] add trigger for test --- .github/workflows/test.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 881e38dfd..205b9137e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,6 +8,7 @@ on: push: branches: - main + - coverage workflow_dispatch: jobs: From 6d80aea82c25688f9f7f603259ce22c0487b036a Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Tue, 17 Sep 2024 15:38:54 -0400 Subject: [PATCH 03/11] install cairo coverage --- .github/workflows/test.yml | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 205b9137e..a8f69a039 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,30 +17,41 @@ jobs: 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: 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: From c1698f36f77235e52c076403c60a8de6be9a76bc Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Tue, 17 Sep 2024 16:03:05 -0400 Subject: [PATCH 04/11] remove workflow dispatch trigger --- .github/workflows/test.yml | 2 -- 1 file changed, 2 deletions(-) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index a8f69a039..e540ab03d 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -8,8 +8,6 @@ on: push: branches: - main - - coverage - workflow_dispatch: jobs: lint_and_test: From e552905483464dc34c5913f518e028ec9f27c81d Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Thu, 19 Sep 2024 10:34:57 -0400 Subject: [PATCH 05/11] add codecov.yml --- .codecov.yml | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) create mode 100644 .codecov.yml diff --git a/.codecov.yml b/.codecov.yml new file mode 100644 index 000000000..fd62ac80f --- /dev/null +++ b/.codecov.yml @@ -0,0 +1,26 @@ +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/" + +github_checks: + annotations: false \ No newline at end of file From 0f6d5b2de09c62f2873c2d028b961797c7cf5e07 Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Thu, 19 Sep 2024 10:42:56 -0400 Subject: [PATCH 06/11] update ignore list --- .codecov.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index fd62ac80f..4d9b49abd 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -21,6 +21,8 @@ coverage: ignore: - "**/tests/" + - "docs/" + - "scripts/" github_checks: annotations: false \ No newline at end of file From dd4aea634fa35658dd6806f14ad981152641fea2 Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Thu, 19 Sep 2024 10:49:36 -0400 Subject: [PATCH 07/11] rename codecov --- .codecov.yml => codecov.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .codecov.yml => codecov.yml (100%) diff --git a/.codecov.yml b/codecov.yml similarity index 100% rename from .codecov.yml rename to codecov.yml From dbe9d67a8b527ae8d645b371c52ccd298a39a077 Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Thu, 19 Sep 2024 13:07:59 -0400 Subject: [PATCH 08/11] Update codecov.yml Co-authored-by: Eric Nordelo --- codecov.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 4d9b49abd..75b9ccf66 100644 --- a/codecov.yml +++ b/codecov.yml @@ -25,4 +25,5 @@ ignore: - "scripts/" github_checks: - annotations: false \ No newline at end of file + annotations: false + \ No newline at end of file From cc1c3a5bc2fe46d9b45cdb562749a68f1e70d490 Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Thu, 19 Sep 2024 15:43:23 -0400 Subject: [PATCH 09/11] update ignore path --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 4d9b49abd..24f5d799b 100644 --- a/codecov.yml +++ b/codecov.yml @@ -20,7 +20,7 @@ coverage: threshold: 2% ignore: - - "**/tests/" + - "**/tests/**/*" - "docs/" - "scripts/" From eb626b927455dbccd840e7dc144fe6b051713120 Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Thu, 19 Sep 2024 16:49:13 -0400 Subject: [PATCH 10/11] update regex path --- codecov.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/codecov.yml b/codecov.yml index 222730175..69af9dfee 100644 --- a/codecov.yml +++ b/codecov.yml @@ -20,7 +20,7 @@ coverage: threshold: 2% ignore: - - "**/tests/**/*" + - "**/tests/**" - "docs/" - "scripts/" From ec7fc8ea7bf52deae49642d559ac2933fc57cf5b Mon Sep 17 00:00:00 2001 From: Gustavo Gonzalez Date: Fri, 20 Sep 2024 09:51:17 -0400 Subject: [PATCH 11/11] ignore test common --- codecov.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/codecov.yml b/codecov.yml index 69af9dfee..dacdbb20d 100644 --- a/codecov.yml +++ b/codecov.yml @@ -23,6 +23,7 @@ ignore: - "**/tests/**" - "docs/" - "scripts/" + - "packages/test_common/" github_checks: annotations: false