Skip to content

Commit

Permalink
Compact markdown tables to avoid GitHub comment limit (#412)
Browse files Browse the repository at this point in the history
* Compact markdown tables

* Add notice if action is unable to produce comment within GitHub limits

* rebuild

* Fix npm version in CI

* Rollback npm to 6.12.0

* Downgrade package versions to remain compatibility with node10
  • Loading branch information
ArtiomTr authored Mar 3, 2024
1 parent d438b94 commit 11039f5
Show file tree
Hide file tree
Showing 10 changed files with 1,907 additions and 1,664 deletions.
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ jobs:
with:
node-version: ${{ matrix.node }}

- name: Setup [email protected]
run: npm i -g [email protected]

- name: Install deps and build (with cache)
uses: bahmutov/npm-install@v1

Expand Down
960 changes: 435 additions & 525 deletions dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

2,568 changes: 1,439 additions & 1,129 deletions package-lock.json

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"version": "1.0.0",
"description": "",
"main": "dist/index.js",
"packageManager": "[email protected]",
"scripts": {
"test": "jest",
"test:log-coverage": "jest --coverage",
Expand All @@ -20,6 +21,7 @@
"@actions/core": "^1.10.0",
"@actions/exec": "^1.1.1",
"@actions/github": "^5.0.3",
"@actions/http-client": "^2.0.1",
"fs-extra": "^10.0.0",
"markdown-table": "^2.0.0",
"micromatch": "^4.0.4",
Expand All @@ -29,6 +31,7 @@
"yup": "^0.32.9"
},
"devDependencies": {
"@types/babel__traverse": "^7.14.2",
"@types/fs-extra": "^9.0.11",
"@types/istanbul-lib-coverage": "^2.0.4",
"@types/jest": "^27.0.2",
Expand Down
2 changes: 2 additions & 0 deletions src/format/details/formatCoverageDetailsPart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,8 @@ export const formatCoverageDetailsPart = (
],
{
align: ['c', 'l', 'l', 'l', 'l', 'l'],
stringLength: () => 1,
alignDelimiters: false,
}
),
summary,
Expand Down
3 changes: 2 additions & 1 deletion src/format/strings.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,8 @@
"reportNotFound": "Coverage output file not found. (file \"{{ coveragePath }}\" not found)",
"multiple": "Multiple errors occurred",
"readingCoverageFileFailed": "Failed reading coverage file. (Error: {{ error }})",
"failedGettingCoverage": "Getting code coverage data failed."
"failedGettingCoverage": "Getting code coverage data failed.",
"reportGenerationError": "Action wasn't able to generate report within GitHub comment limit. If you're facing this issue, please let me know by commenting under [this issue](https://github.com/ArtiomTr/jest-coverage-report-action/issues/404)."
},
"detailsHidden": ":warning: Details were not displayed: the report size has exceeded the limit.",
"summaryTitle": "Coverage report {{ dir }}",
Expand Down
14 changes: 14 additions & 0 deletions src/stages/createReport.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,20 @@ export const createReport = (
}),
sha: getSha(),
});

if (templateText.length > GITHUB_MESSAGE_SIZE_LIMIT) {
templateText = insertArgs(template, {
body: insertArgs('> {{ text }}', {
text: i18n('errors.reportGenerationError'),
}),
dir: workingDirectory || '',
tag: getReportTag(options),
title: insertArgs(customTitle || i18n('summaryTitle'), {
dir: workingDirectory ? `for \`${workingDirectory}\`` : '',
}),
sha: getSha(),
});
}
}

return {
Expand Down
Empty file added src/utils/markdownTable.ts
Empty file.
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,19 @@ exports[`formatCoverageDetails should match snapshots 1`] = `
<details><summary>Show new covered files 🐣</summary>
<br/>
| <div title=\\"Status of coverage:&#10; 🟒 - ok&#10; 🟑 - slightly more than threshold&#10; πŸ”΄ - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :------- | :-------- | :---- |
| πŸ”΄ | newFile.ts | 50% | 50% | 50% | 50% |
| <div title=\\"Status of coverage:&#10; 🟒 - ok&#10; 🟑 - slightly more than threshold&#10; πŸ”΄ - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :-: | :- | :- | :- | :- | :- |
| πŸ”΄ | newFile.ts | 50% | 50% | 50% | 50% |
</details>
<details><summary>Show files with reduced coverage πŸ”»</summary>
<br/>
| <div title=\\"Status of coverage:&#10; 🟒 - ok&#10; 🟑 - slightly more than threshold&#10; πŸ”΄ - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- |
| 🟑 | decreased.ts | <div title=\\"Base coverage is: 80%\\">70% (-10% πŸ”»)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% πŸ”»)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% πŸ”»)</div> | <div title=\\"Base coverage is: 90%\\">80% (-10% πŸ”»)</div> |
| <div title=\\"Status of coverage:&#10; 🟒 - ok&#10; 🟑 - slightly more than threshold&#10; πŸ”΄ - under the threshold\\">St.<sup>:grey_question:</sup></div> | File | Statements | Branches | Functions | Lines |
| :-: | :- | :- | :- | :- | :- |
| 🟑 | decreased.ts | <div title=\\"Base coverage is: 80%\\">70% (-10% πŸ”»)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% πŸ”»)</div> | <div title=\\"Base coverage is: 60%\\">50% (-10% πŸ”»)</div> | <div title=\\"Base coverage is: 90%\\">80% (-10% πŸ”»)</div> |
</details>
"
Expand Down

0 comments on commit 11039f5

Please sign in to comment.