Skip to content

Commit 11039f5

Browse files
authored
Compact markdown tables to avoid GitHub comment limit (#412)
* 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
1 parent d438b94 commit 11039f5

File tree

10 files changed

+1907
-1664
lines changed

10 files changed

+1907
-1664
lines changed

β€Ž.github/workflows/ci.ymlβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,9 @@ jobs:
2121
with:
2222
node-version: ${{ matrix.node }}
2323

24+
- name: Setup [email protected]
25+
run: npm i -g [email protected]
26+
2427
- name: Install deps and build (with cache)
2528
uses: bahmutov/npm-install@v1
2629

β€Ždist/index.jsβ€Ž

Lines changed: 435 additions & 525 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Ždist/index.js.mapβ€Ž

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage-lock.jsonβ€Ž

Lines changed: 1439 additions & 1129 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

β€Žpackage.jsonβ€Ž

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"version": "1.0.0",
55
"description": "",
66
"main": "dist/index.js",
7+
"packageManager": "[email protected]",
78
"scripts": {
89
"test": "jest",
910
"test:log-coverage": "jest --coverage",
@@ -20,6 +21,7 @@
2021
"@actions/core": "^1.10.0",
2122
"@actions/exec": "^1.1.1",
2223
"@actions/github": "^5.0.3",
24+
"@actions/http-client": "^2.0.1",
2325
"fs-extra": "^10.0.0",
2426
"markdown-table": "^2.0.0",
2527
"micromatch": "^4.0.4",
@@ -29,6 +31,7 @@
2931
"yup": "^0.32.9"
3032
},
3133
"devDependencies": {
34+
"@types/babel__traverse": "^7.14.2",
3235
"@types/fs-extra": "^9.0.11",
3336
"@types/istanbul-lib-coverage": "^2.0.4",
3437
"@types/jest": "^27.0.2",

β€Žsrc/format/details/formatCoverageDetailsPart.tsβ€Ž

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ export const formatCoverageDetailsPart = (
4040
],
4141
{
4242
align: ['c', 'l', 'l', 'l', 'l', 'l'],
43+
stringLength: () => 1,
44+
alignDelimiters: false,
4345
}
4446
),
4547
summary,

β€Žsrc/format/strings.jsonβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,8 @@
103103
"reportNotFound": "Coverage output file not found. (file \"{{ coveragePath }}\" not found)",
104104
"multiple": "Multiple errors occurred",
105105
"readingCoverageFileFailed": "Failed reading coverage file. (Error: {{ error }})",
106-
"failedGettingCoverage": "Getting code coverage data failed."
106+
"failedGettingCoverage": "Getting code coverage data failed.",
107+
"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)."
107108
},
108109
"detailsHidden": ":warning: Details were not displayed: the report size has exceeded the limit.",
109110
"summaryTitle": "Coverage report {{ dir }}",

β€Žsrc/stages/createReport.tsβ€Ž

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,20 @@ export const createReport = (
7979
}),
8080
sha: getSha(),
8181
});
82+
83+
if (templateText.length > GITHUB_MESSAGE_SIZE_LIMIT) {
84+
templateText = insertArgs(template, {
85+
body: insertArgs('> {{ text }}', {
86+
text: i18n('errors.reportGenerationError'),
87+
}),
88+
dir: workingDirectory || '',
89+
tag: getReportTag(options),
90+
title: insertArgs(customTitle || i18n('summaryTitle'), {
91+
dir: workingDirectory ? `for \`${workingDirectory}\`` : '',
92+
}),
93+
sha: getSha(),
94+
});
95+
}
8296
}
8397

8498
return {

β€Žsrc/utils/markdownTable.tsβ€Ž

Whitespace-only changes.

β€Žtests/format/details/__snapshots__/formatCoverageDetails.test.ts.snapβ€Ž

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,19 @@ exports[`formatCoverageDetails should match snapshots 1`] = `
55
<details><summary>Show new covered files 🐣</summary>
66
<br/>
77
8-
| <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 |
9-
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :--------- | :--------- | :------- | :-------- | :---- |
10-
| πŸ”΄ | newFile.ts | 50% | 50% | 50% | 50% |
8+
| <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 |
9+
| :-: | :- | :- | :- | :- | :- |
10+
| πŸ”΄ | newFile.ts | 50% | 50% | 50% | 50% |
1111
1212
</details>
1313
1414
1515
<details><summary>Show files with reduced coverage πŸ”»</summary>
1616
<br/>
1717
18-
| <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 |
19-
| :----------------------------------------------------------------------------------------------------------------------------------------------------: | :----------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- | :----------------------------------------------------- |
20-
| 🟑 | 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> |
18+
| <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 |
19+
| :-: | :- | :- | :- | :- | :- |
20+
| 🟑 | 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> |
2121
2222
</details>
2323
"

0 commit comments

Comments
Β (0)