From b161116a5f372cb758e9e936005f340a01dd612c Mon Sep 17 00:00:00 2001 From: Go Kudo Date: Thu, 22 Aug 2024 21:48:27 +0000 Subject: [PATCH] [ci skip] remove coverage comment --- .github/workflows/coverage.yaml | 104 -------------------------------- 1 file changed, 104 deletions(-) diff --git a/.github/workflows/coverage.yaml b/.github/workflows/coverage.yaml index 97db172..89ca889 100644 --- a/.github/workflows/coverage.yaml +++ b/.github/workflows/coverage.yaml @@ -63,107 +63,3 @@ jobs: with: github-token: ${{ secrets.GITHUB_TOKEN }} config: .github/octocov.yml - - name: Review for PR - if: github.event_name == 'pull_request' - uses: actions/github-script@v7 - with: - github-token: ${{ secrets.GITHUB_TOKEN }} - script: | - const fs = require('fs'); - - function parseLcovInfo(filename) { - const content = fs.readFileSync(filename, 'utf8'); - const lines = content.split('\n'); - const uncoveredLines = {}; - let currentFile = ''; - - for (const line of lines) { - if (line.startsWith('SF:')) { - currentFile = line.slice(3).trim(); - } else if (line.startsWith('DA:')) { - const [lineNo, hits] = line.slice(3).trim().split(',').map(Number); - if (hits === 0) { - if (!uncoveredLines[currentFile]) { - uncoveredLines[currentFile] = []; - } - uncoveredLines[currentFile].push(lineNo); - } - } - } - - return uncoveredLines; - } - - function groupConsecutiveLines(lines) { - if (lines.length === 0) return []; - - lines.sort((a, b) => a - b); - const groups = []; - let currentGroup = [lines[0]]; - - for (let i = 1; i < lines.length; i++) { - if (lines[i] === lines[i-1] + 1) { - currentGroup.push(lines[i]); - } else { - groups.push(currentGroup); - currentGroup = [lines[i]]; - } - } - groups.push(currentGroup); - - return groups; - } - - async function createReviewForUncoveredLines(github, context, uncoveredLines) { - const { owner, repo } = context.repo; - const pull_number = context.payload.pull_request.number; - - const { data: files } = await github.rest.pulls.listFiles({ - owner, - repo, - pull_number, - }); - - const comments = []; - for (const file of files) { - const filename = file.filename; - if (uncoveredLines['/' + filename]) { - const groups = groupConsecutiveLines(uncoveredLines['/' + filename]); - for (const group of groups) { - const startLine = group[0]; - const endLine = group[group.length - 1]; - const commentBody = 'These lines are not covered by tests.'; - const comment = { - path: filename, - body: commentBody, - line: startLine, - side: 'RIGHT', - }; - if (startLine !== endLine) { - comment.start_line = startLine; - comment.line = endLine; - } - comments.push(comment); - } - } - } - - if (comments.length > 0) { - await github.rest.pulls.createReview({ - owner, - repo, - pull_number, - commit_id: context.payload.pull_request.head.sha, - body: 'Review for uncovered lines', - event: 'COMMENT', - comments, - }); - } - } - - try { - const uncoveredLines = parseLcovInfo('lcov.info'); - await createReviewForUncoveredLines(github, context, uncoveredLines); - } catch (error) { - core.setFailed(`Action failed with error: ${error}`); - }