Skip to content

Commit

Permalink
Merge pull request #2 from ContinuIT-nl/bug/publish
Browse files Browse the repository at this point in the history
Bug/publish
  • Loading branch information
ritsaert authored Dec 31, 2024
2 parents dc17b8b + 2aea7d6 commit 34d9a96
Show file tree
Hide file tree
Showing 7 changed files with 47 additions and 27 deletions.
2 changes: 1 addition & 1 deletion src/testReportConfig.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { z } from 'npm:zod';
import { z } from 'zod';

const defaultOKColor = '#2EBE4E';
const defaultFailedColor = '#900';
Expand Down
2 changes: 1 addition & 1 deletion src/testReportData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ function createLcovSummary(lcov: LcovFile[]): LcovSummary {
type Failure = {
message: string;
file: string;
type: 'junit' | 'lcov' | 'write';
type: 'junit' | 'lcov' | 'write' | 'coverage' | 'test';
};

export type GetTestReportDataResult = {
Expand Down
32 changes: 28 additions & 4 deletions src/testReportToManifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +22,35 @@ const convertTestresultsToManifest = (data: GetTestReportDataResult) => {
// todo: add test for following 2 lines
const coverage_color = levels.find((level) => level.threshold <= coverage)?.color ?? '#555';

const minimal = config.limits?.coverage_percentage_minimal ?? 0;
const coverage_status = coverage >= minimal ? 'ok' : 'failed';
const limits = config.limits ?? {
test_percentage_failed: 0,
test_percentage_disabled: 0,
coverage_percentage_minimal: 0,
};

if (coverage < limits.coverage_percentage_minimal) {
failures.push({
type: 'coverage',
message: `Coverage is below the minimal threshold of ${limits.coverage_percentage_minimal}%`,
file: '',
});
}

if (test_failed > limits.test_percentage_failed * 0.01 * test_total) {
failures.push({
type: 'junit',
message: `Test failed is above the limit of ${limits.test_percentage_failed}%`,
file: '',
});
}

// todo: process limits and add to failures
if (test_skipped > limits.test_percentage_disabled * 0.01 * test_total) {
failures.push({
type: 'test',
message: `Test skipped is above the limit of ${limits.test_percentage_disabled}%`,
file: '',
});
}

return {
// Source
Expand Down Expand Up @@ -54,7 +79,6 @@ const convertTestresultsToManifest = (data: GetTestReportDataResult) => {
coverage_branches_hit: lcovSummary.branchesHit,
coverage_branches_percentage: percentageNoZero(lcovSummary.branchesHit, lcovSummary.branchesFound),
coverage_percentage,
coverage_status,
coverage_color,
// Code coverage details
coverage_details: lcovDatas.map((file) => ({
Expand Down
3 changes: 0 additions & 3 deletions test_data/deno_success/testreport.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,6 @@
"junit": ["test_data/deno_success/junit.xml"],
"coverage": ["test_data/deno_success/cov.lcov"]
},
"limits": {
"coverage_percentage_minimal": 80
},
"manifest": {
"output": "test_output/deno_success/results.json"
},
Expand Down
2 changes: 1 addition & 1 deletion test_results/coverage_badge.svg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 13 additions & 14 deletions test_results/test_results.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,14 +135,13 @@
"state": "PASSED"
}
],
"coverage_lines_total": 792,
"coverage_lines_hit": 791,
"coverage_lines_percentage": "99.9%",
"coverage_branches_total": 128,
"coverage_branches_hit": 127,
"coverage_branches_percentage": "99.2%",
"coverage_percentage": "99.2%",
"coverage_status": "ok",
"coverage_lines_total": 815,
"coverage_lines_hit": 815,
"coverage_lines_percentage": "100.0%",
"coverage_branches_total": 129,
"coverage_branches_hit": 129,
"coverage_branches_percentage": "100.0%",
"coverage_percentage": "100.0%",
"coverage_color": "#2EBE4E",
"coverage_details": [
{
Expand Down Expand Up @@ -201,12 +200,12 @@
},
{
"name": "testReportToManifest.ts",
"lines_total": 59,
"lines_hit": 58,
"lines_percentage": "98.3%",
"branches_total": 22,
"branches_hit": 21,
"branches_percentage": "95.5%"
"lines_total": 82,
"lines_hit": 82,
"lines_percentage": "100.0%",
"branches_total": 23,
"branches_hit": 23,
"branches_percentage": "100.0%"
},
{
"name": "testReportToMarkdown.ts",
Expand Down
6 changes: 3 additions & 3 deletions test_results/test_results.md
Original file line number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 +18,7 @@ Results from `./testreport.json` contains 5 testsuites with 25 tests:

| ☰ Lines | ᛘ Branches |
| ------: | ---------: |
| 99.9% | 99.2% |
| 100.0% | 100.0% |

<details>
<summary>Detailed Test Results</summary>
Expand Down Expand Up @@ -64,7 +64,7 @@ Results from `./testreport.json` contains 5 testsuites with 25 tests:
| `testReportConfig.ts` | 100.0% | N/A |
| `testReportData.ts` | 100.0% | 100.0% |
| `testReportToBadges.ts` | 100.0% | N/A |
| `testReportToManifest.ts` | 98.3% | 95.5% |
| `testReportToManifest.ts` | 100.0% | 100.0% |
| `testReportToMarkdown.ts` | 100.0% | 100.0% |
| `createBadgeSvg.ts` | 100.0% | 100.0% |
| `junit_parser.ts` | 100.0% | N/A |
Expand Down

0 comments on commit 34d9a96

Please sign in to comment.