diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml index ca822e13..3ce9b33a 100644 --- a/.github/workflows/checks.yml +++ b/.github/workflows/checks.yml @@ -16,6 +16,9 @@ jobs: - name: Set up environment uses: ./.github/actions/setup + - name: Build typechain for linting + run: npx hardhat typechain + - name: Run Solidity and Typescript linters run: npm run lint diff --git a/.github/workflows/coverage.yml b/.github/workflows/coverage.yml new file mode 100644 index 00000000..8bf51903 --- /dev/null +++ b/.github/workflows/coverage.yml @@ -0,0 +1,32 @@ +name: solidity-test-coverage + +on: + push: + branches: + - main + workflow_dispatch: + +concurrency: + group: solidity-test-coverage-${{ github.ref }} + cancel-in-progress: true + +jobs: + coverage: + runs-on: ubuntu-latest + steps: + - name: Checkout repository + uses: actions/checkout@v3 + + - name: Set up environment + uses: ./.github/actions/setup + + - name: Generate test coverage + run: npm run coverage + + - name: Upload artifact of tests + if: '!cancelled()' + uses: actions/upload-artifact@v4 + with: + name: solidity-test-coverage + path: ./coverage/ + retention-days: 7 diff --git a/.solcover.js b/.solcover.js index 72ae67cc..f70c3559 100644 --- a/.solcover.js +++ b/.solcover.js @@ -3,6 +3,9 @@ module.exports = { testCommand: 'npm run test', compileCommand: 'npm run compile', configureYulOptimizer: true, + measureStatementCoverage: true, + measureFunctionCoverage: true, + measureBranchCoverage: true, skipFiles: [ 'constants', 'errors', @@ -11,4 +14,9 @@ module.exports = { 'utils', 'Token.sol', ], + istanbulFolder: './coverage', + istanbulReporter: [ + 'html', + 'text' + ] }; diff --git a/hardhat.node.config.ts b/hardhat.node.config.ts index 6bead10f..48e34fcd 100644 --- a/hardhat.node.config.ts +++ b/hardhat.node.config.ts @@ -65,7 +65,7 @@ const config: HardhatUserConfig = { }, }, }, - viaIR: process.env.COVERAGE_REPORT ? false : true, + viaIR: true, }, }, ], diff --git a/package.json b/package.json index 997eb511..b2e898de 100644 --- a/package.json +++ b/package.json @@ -81,7 +81,7 @@ "clean": "hardhat clean", "compile:size": "hardhat size-contracts", "compile": "hardhat compile --config hardhat.node.config.ts", - "coverage": "cross-env COVERAGE_REPORT=true HARDHAT_DEPLOY_FIXTURE=true hardhat coverage --network hardhat --solcoverjs ./.solcover.js --temp artifacts --testfiles './test/**/*.test.ts'", + "coverage": "cross-env SOLIDITY_COVERAGE=true HARDHAT_DEPLOY_FIXTURE=true hardhat coverage --solcoverjs ./.solcover.js --testfiles './test/**/*.test.ts'", "deploy:base_sepolia_dev": "hardhat deploy --network base_sepolia_dev", "deploy:base_sepolia_stable_dev_prod": "hardhat deploy --network base_sepolia_stable_dev_prod", "deploy:base_sepolia_stable_dev_staging": "hardhat deploy --network base_sepolia_stable_dev_staging",