From 26e4363bf9a881cebf94d22a31c0cf4d7fdba886 Mon Sep 17 00:00:00 2001 From: ChuhanJin <60994121+ChuhanJin@users.noreply.github.com> Date: Fri, 17 Mar 2023 18:20:07 +0800 Subject: [PATCH] Build(contracts): add coverage report in /contracts (#373) Co-authored-by: vincent <419436363@qq.com> Co-authored-by: HAOYUatHZ <37070449+HAOYUatHZ@users.noreply.github.com> --- .github/workflows/contracts.yaml | 35 +++++++++++++++++--------------- 1 file changed, 19 insertions(+), 16 deletions(-) diff --git a/.github/workflows/contracts.yaml b/.github/workflows/contracts.yaml index 477a2e1c79..afd14bf742 100644 --- a/.github/workflows/contracts.yaml +++ b/.github/workflows/contracts.yaml @@ -2,26 +2,10 @@ name: Contracts on: push: - branches: - - master - - main - - prod - - release/* - - staging - - develop - - alpha paths: - 'contracts/**' - '.github/workflows/contracts.yaml' pull_request: - branches: - - master - - main - - prod - - release/* - - staging - - develop - - alpha paths: - 'contracts/**' - '.github/workflows/contracts.yaml' @@ -44,6 +28,9 @@ jobs: uses: foundry-rs/foundry-toolchain@v1 with: version: nightly + + - name: Setup LCOV + uses: hrishikesh-kadam/setup-lcov@v1 - name: Install Node.js 14 uses: actions/setup-node@v2 @@ -80,6 +67,22 @@ jobs: - name: Run foundry tests run: forge test -vvv + - name: Run foundry coverage + run : forge coverage --report lcov + + - name : Prune coverage + run : lcov --remove ./lcov.info -o ./lcov.info.pruned 'src/mocks/*' 'src/test/*' 'scripts/*' 'node_modules/*' 'lib/*' + + - name: Report code coverage + uses: zgosalvez/github-actions-report-lcov@v3 + with: + coverage-files: contracts/lcov.info.pruned + minimum-coverage: 0 + artifact-name: code-coverage-report + github-token: ${{ secrets.GITHUB_TOKEN }} + working-directory: contracts + update-comment: true + hardhat: runs-on: ubuntu-latest