Skip to content

Commit

Permalink
Support matrix with individual comments (#50)
Browse files Browse the repository at this point in the history
* bump all dev packages

* add to readme `unique-id-for-comment`

* add `unique-id-for-comment` + build

* changelog

* 1.0.21
  • Loading branch information
MishaKav authored Dec 2, 2022
1 parent 411fdd4 commit 131d9dc
Show file tree
Hide file tree
Showing 8 changed files with 144 additions and 122 deletions.
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,13 @@
# Changelog of the Jest Coverage Comment

## [Jest Coverage Comment 1.0.21](https://github.com/MishaKav/jest-coverage-comment/tree/v1.0.21)

**Release Date:** 2022-12-03

#### Changes

- Support matrix with individual comments. When you run in a matrix, and you want that every job will post a comment, you can use the `unique-id-for-comment: ${{ matrix.node-version }}`. This will post a comment for every job, and will update them on every run.

## [Jest Coverage Comment 1.0.20](https://github.com/MishaKav/jest-coverage-comment/tree/v1.0.20)

**Release Date:** 2022-10-31
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ You can add this action to your GitHub workflow for Ubuntu runners (e.g. `runs-o
| `report-only-changed-files` | | false | Show in report only changed files for this commit, and not all files |
| `multiple-files` | | '' | You can pass array of `json-summary.json` files and generate single comment with table of results<br/>Single line should look like `Title1, ./path/to/json-summary.json` |
| `multiple-junitxml-files` | | '' | You can pass array of `junit.xml` files and generate single comment with table of results<br/>Single line should look like `Title1, ./path/to/junit.xml` |
| `unique-id-for-comment` | | '' | When running in a matrix, pass the matrix value, so each comment will be updated its own comment `unique-id-for-comment: ${{ matrix.node-version }}` |

## Output Variables

Expand Down
5 changes: 5 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,11 @@ inputs:
default: ''
required: false

unique-id-for-comment:
description: 'When running in a matrix, pass the matrix value, so each comment will be updated its own comment'
default: ''
required: false

outputs:
coverage:
description: 'Value indicating the coverage percentage of your report based on Jest, example 78'
Expand Down
8 changes: 6 additions & 2 deletions dist/index.js

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

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

210 changes: 105 additions & 105 deletions package-lock.json

Large diffs are not rendered by default.

20 changes: 10 additions & 10 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "jest-coverage-comment",
"version": "1.0.20",
"version": "1.0.21",
"description": "Comments a pull request or commit with the jest code coverage badge, full report and tests summary",
"author": "Misha Kav <[email protected]>",
"license": "MIT",
Expand Down Expand Up @@ -36,20 +36,20 @@
"xml2js": "^0.4.23"
},
"devDependencies": {
"@types/jest": "^29.2.1",
"@types/node": "^18.11.8",
"@types/jest": "^29.2.3",
"@types/node": "^18.11.10",
"@types/xml2js": "^0.4.11",
"@typescript-eslint/parser": "^5.42.0",
"@typescript-eslint/parser": "^5.45.0",
"@vercel/ncc": "^0.34.0",
"babel-plugin-rewire": "^1.2.0",
"eslint": "^8.26.0",
"eslint": "^8.28.0",
"eslint-import-resolver-typescript": "^3.5.2",
"eslint-plugin-github": "^4.4.0",
"eslint-plugin-jest": "^27.1.3",
"jest-junit": "^14.0.1",
"prettier": "^2.7.1",
"eslint-plugin-github": "^4.4.1",
"eslint-plugin-jest": "^27.1.6",
"jest-junit": "^15.0.0",
"prettier": "^2.8.0",
"ts-jest": "^29.0.3",
"ts-node": "^10.9.1",
"typescript": "^4.8.4"
"typescript": "^4.9.3"
}
}
12 changes: 8 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,18 @@ async function main(): Promise<void> {
})
const multipleJunitFiles = core.getMultilineInput(
'multiple-junitxml-files',
{
required: false,
}
{ required: false }
)
const uniqueIdForComment = core.getInput('unique-id-for-comment', {
required: false,
})

const { repo, owner } = context.repo
const { eventName, payload } = context
const watermark = `<!-- Jest Coverage Comment: ${context.job} -->\n`
const watermarkUniqueId = uniqueIdForComment
? `| ${uniqueIdForComment} `
: ''
const watermark = `<!-- Jest Coverage Comment: ${context.job} ${watermarkUniqueId}-->\n`
let finalHtml = ''

const options: Options = {
Expand Down

0 comments on commit 131d9dc

Please sign in to comment.