Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compact markdown tables to avoid GitHub comment limit #412

Merged
merged 6 commits into from
Mar 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading