Skip to content

Commit

Permalink
Fix stmts count (#111)
Browse files Browse the repository at this point in the history
* fix: increase stmts counters when using coverage.xml (#109)

* chore: fix typos

* fix: increase the stmts counter

* bump eslint + prettier

* build + format

* 1.1.43

* changelog

Co-authored-by: Ricardo Mendes <[email protected]>
  • Loading branch information
MishaKav and ricardolsmendes authored Jan 23, 2023
1 parent 5acddd9 commit 506b8a2
Show file tree
Hide file tree
Showing 8 changed files with 45 additions and 34 deletions.
11 changes: 10 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,17 @@
# Changelog of the Pytest Coverage Comment

## [Pytest Coverage Comment 1.1.43](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.43)

**Release Date:** 2023-01-23

#### Changes

- Export right `stms` when using `pytest-xml-coverage-path`, thanks to [@ricardolsmendes](https://github.com/ricardolsmendes) for contribution
- Fix some typos in comments

## [Pytest Coverage Comment 1.1.42](https://github.com/MishaKav/pytest-coverage-comment/tree/v1.1.42)

**Release Date:** 2023-03-09
**Release Date:** 2023-01-09

#### Changes

Expand Down
13 changes: 7 additions & 6 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -16975,7 +16975,7 @@ module.exports = { getMultipleReport };
const core = __nccwpck_require__(2186);
const { getPathToFile, getContentFile, getCoverageColor } = __nccwpck_require__(1608);

// return true if "covergae file" include all special words
// return true if "coverage file" include all special words
const isValidCoverageContent = (data) => {
if (!data || !data.length) {
return false;
Expand All @@ -16992,7 +16992,7 @@ const isValidCoverageContent = (data) => {
return wordsToInclude.every((w) => data.includes(w));
};

// return full html coverage report and coverage percenatge
// return full html coverage report and coverage percentage
const getCoverageReport = (options) => {
const { covFile, covXmlFile } = options;

Expand Down Expand Up @@ -17345,7 +17345,7 @@ const getTotalCoverage = (parsedXml) => {
};
};

// return true if "covergae file" include right structure
// return true if "coverage file" include right structure
const isValidCoverageContent = (parsedXml) => {
if (!parsedXml || !parsedXml.packages || !parsedXml.packages.length) {
return false;
Expand Down Expand Up @@ -17455,10 +17455,11 @@ const parseLines = (lines) => {
return { stmts: '0', missing: '', totalMissing: '0' };
}

let stmts = '0';
let stmts = 0;
const missingLines = [];

lines[0].line.forEach((line) => {
stmts++;
const { hits, number } = line['$'];

if (hits === '0') {
Expand All @@ -17482,7 +17483,7 @@ const parseLines = (lines) => {
});

return {
stmts,
stmts: stmts.toString(),
missing: missingText,
totalMissing: missingLines.length.toString(),
};
Expand All @@ -17504,7 +17505,7 @@ const getPathToFile = (pathToFile) => {
return null;
}

// suports absolute path like '/tmp/pytest-coverage.txt'
// supports absolute path like '/tmp/pytest-coverage.txt'
return pathToFile.startsWith('/')
? pathToFile
: `${process.env.GITHUB_WORKSPACE}/${pathToFile}`;
Expand Down
32 changes: 16 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "pytest-coverage-comment",
"version": "1.1.42",
"version": "1.1.43",
"description": "Comments a pull request with the pytest code coverage badge, full report and tests summary",
"author": "Misha Kav",
"license": "MIT",
Expand Down Expand Up @@ -33,8 +33,8 @@
},
"devDependencies": {
"@vercel/ncc": "^0.36.0",
"eslint": "^8.31.0",
"prettier": "^2.8.2"
"eslint": "^8.32.0",
"prettier": "^2.8.3"
},
"prettier": {
"semi": true,
Expand Down
4 changes: 2 additions & 2 deletions src/cli.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ const { getMultipleReport } = require('./multiFiles');
const { getCoverageXmlReport } = require('./parseXml');

/*
Usefull git commands
Useful git commands
git tag -a -m "Export coverage example" v1.1.7 && git push --follow-tags
git tag -d v1.0
git tag -d origin v1.0
Expand All @@ -29,7 +29,7 @@ const getPathToFile = (pathToFile) => {
return null;
}

// suports absolute path like '/tmp/pytest-coverage.txt'
// supports absolute path like '/tmp/pytest-coverage.txt'
return pathToFile.startsWith('/') ? pathToFile : `${__dirname}/${pathToFile}`;
};

Expand Down
4 changes: 2 additions & 2 deletions src/parse.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const core = require('@actions/core');
const { getPathToFile, getContentFile, getCoverageColor } = require('./utils');

// return true if "covergae file" include all special words
// return true if "coverage file" include all special words
const isValidCoverageContent = (data) => {
if (!data || !data.length) {
return false;
Expand All @@ -18,7 +18,7 @@ const isValidCoverageContent = (data) => {
return wordsToInclude.every((w) => data.includes(w));
};

// return full html coverage report and coverage percenatge
// return full html coverage report and coverage percentage
const getCoverageReport = (options) => {
const { covFile, covXmlFile } = options;

Expand Down
7 changes: 4 additions & 3 deletions src/parseXml.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ const getTotalCoverage = (parsedXml) => {
};
};

// return true if "covergae file" include right structure
// return true if "coverage file" include right structure
const isValidCoverageContent = (parsedXml) => {
if (!parsedXml || !parsedXml.packages || !parsedXml.packages.length) {
return false;
Expand Down Expand Up @@ -142,10 +142,11 @@ const parseLines = (lines) => {
return { stmts: '0', missing: '', totalMissing: '0' };
}

let stmts = '0';
let stmts = 0;
const missingLines = [];

lines[0].line.forEach((line) => {
stmts++;
const { hits, number } = line['$'];

if (hits === '0') {
Expand All @@ -169,7 +170,7 @@ const parseLines = (lines) => {
});

return {
stmts,
stmts: stmts.toString(),
missing: missingText,
totalMissing: missingLines.length.toString(),
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const getPathToFile = (pathToFile) => {
return null;
}

// suports absolute path like '/tmp/pytest-coverage.txt'
// supports absolute path like '/tmp/pytest-coverage.txt'
return pathToFile.startsWith('/')
? pathToFile
: `${process.env.GITHUB_WORKSPACE}/${pathToFile}`;
Expand Down

0 comments on commit 506b8a2

Please sign in to comment.