diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index a938faeeee..4e6bddb298 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -132,11 +132,23 @@ jobs: path-to-lcov: ./contracts/zero-ex/lcov.info - name: Check coverage threshold - uses: VeryGoodOpenSource/very_good_coverage@v2 + uses: actions/github-script@v9 with: - path: ./contracts/zero-ex/lcov.info - min_coverage: 6.98 - exclude: '**/tests' + script: | + const fs = require('fs'); + const MIN_COVERAGE = 6.98; + const lcov = fs.readFileSync('./contracts/zero-ex/lcov.info', 'utf8'); + let linesFound = 0; + let linesHit = 0; + for (const line of lcov.split('\n')) { + if (line.startsWith('LF:')) linesFound += Number(line.slice(3)); + else if (line.startsWith('LH:')) linesHit += Number(line.slice(3)); + } + const coverage = linesFound ? (100 * linesHit) / linesFound : 0; + core.info(`Line coverage: ${coverage.toFixed(2)}% (min ${MIN_COVERAGE}%)`); + if (coverage < MIN_COVERAGE) { + core.setFailed(`Coverage ${coverage.toFixed(2)}% is below the ${MIN_COVERAGE}% threshold`); + } - name: Run Forge build on governance contracts working-directory: ./contracts/governance