Skip to content

Commit

Permalink
ci: codecov (#161)
Browse files Browse the repository at this point in the history
* chore: change lcov path

* ci: add codecov

* style: fix linting
  • Loading branch information
superical authored Apr 1, 2024
1 parent 5ed53a9 commit cc68286
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
19 changes: 19 additions & 0 deletions .github/workflows/tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
- run: sudo apt-get install -y lcov
- run: npm ci --no-fund --no-audit
- run: npm run test:coverage
- uses: actions/upload-artifact@v3
with:
name: test-coverage
path: ./coverage/lcov.info

test-build:
name: Test Build
Expand All @@ -30,3 +34,18 @@ jobs:
- uses: foundry-rs/foundry-toolchain@v1
- run: npm ci --no-fund --no-audit --ignore-scripts
- run: npm run build

coverage:
name: Test Coverage
needs: [run-tests]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Download coverage
uses: actions/download-artifact@v3
with:
name: test-coverage
- uses: codecov/codecov-action@v3
with:
fail_ci_if_error: true
verbose: true
11 changes: 6 additions & 5 deletions bin/coverage.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,29 @@

set -e

forge coverage --report lcov
mkdir -p coverage
forge coverage --report lcov -r coverage/lcov.info

# Exclude coverage
# Forge doesn't support libraries yet: https://github.com/foundry-rs/foundry/issues/2567
lcov \
--ignore-errors unused,unused \
--rc branch_coverage=1 \
--remove lcov.info \
--output-file lcov.info \
--remove coverage/lcov.info \
--output-file coverage/lcov.info \
"node_modules/*" "script/*" "test/*" "src/libraries/*"

# Generate summary
lcov \
--rc branch_coverage=1 \
--list lcov.info
--list coverage/lcov.info

# Generate HTML report
if [ "$FOUNDRY_PROFILE" != "ci" ]; then
genhtml \
--rc branch_coverage=1 \
--output-directory coverage \
lcov.info
coverage/lcov.info

echo "Coverage report generated at coverage/index.html"
fi
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"scripts": {
"build": "forge build",
"build:hh": "hardhat clean && hardhat compile --no-typechain",
"clean": "rm -rf cache out .build coverage lcov.info artifacts",
"clean": "rm -rf cache out .build coverage artifacts",
"semantic-release": "semantic-release",
"lint": "npm run lint:sol && npm run prettier:check",
"lint:sol": "npx solhint {script,src,test}/**/*.sol",
Expand Down

0 comments on commit cc68286

Please sign in to comment.