From f0caa5132956437b0defdf1dd608376f3f6adf17 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 14 May 2024 15:42:08 +0200 Subject: [PATCH 1/6] Update --- action.yml | 33 ++++++++++++++++++++++++--------- 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/action.yml b/action.yml index 7b6bc63..6ff4e65 100644 --- a/action.yml +++ b/action.yml @@ -61,6 +61,14 @@ inputs: description: Make the code coverage report togglable. required: false default: false + detailed-coverage: + description: | + Whether a table with a detailed coverage report should be added to PR comment. + The table contains the following information per file: + number of code statements, number of statements not covered by any test, + coverage percentage, and line numbers not covered by any test. + required: false + default: true branding: # https://feathericons.com/ icon: "umbrella" @@ -235,17 +243,24 @@ runs: } fi echo -e "## ${{ inputs.coverage-summary-title }}\n" >> .coverage-output.final - if [[ "${{ inputs.togglable-report }}" == "true" ]] + if [[ "${{ inputs.detailed-coverage }}" == "true" ]] then { - echo -e "
\n\n" >> .coverage-output.final + if [[ "${{ inputs.togglable-report }}" == "true" ]] + then { + echo -e "
\n\n" >> .coverage-output.final + } + fi + echo -e "\`\`\`" >> .coverage-output.final + cat .coverage-output >> .coverage-output.final + echo -e "\n\`\`\`\n" >> .coverage-output.final + if [[ "${{ inputs.togglable-report }}" == "true" ]] + then { + echo -e "
\n\n" >> .coverage-output.final + } + fi } - fi - echo -e "\`\`\`" >> .coverage-output.final - cat .coverage-output >> .coverage-output.final - echo -e "\n\`\`\`\n" >> .coverage-output.final - if [[ "${{ inputs.togglable-report }}" == "true" ]] - then { - echo -e "
\n\n" >> .coverage-output.final + else { + echo -e "\n" >> .coverage-output.final } fi if [[ "${{ inputs.diff }}" == "true" && -f .coverage-output.diff ]] From 2a4e4e639fef98f71eb50ac76c60862cd1e6c325 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 14 May 2024 16:04:33 +0200 Subject: [PATCH 2/6] Update readme --- README.md | 47 +++++++++++++++++++++++++++-------------------- 1 file changed, 27 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 6d6a9fb..e3dfed0 100644 --- a/README.md +++ b/README.md @@ -5,18 +5,14 @@ # Code Coverage Report Action ### Description - Action that converts a Cobertura XML report into a markdown report. ### Action Type - Composite ### Author - -Insights Engineering +Inisghts Engineering ### Inputs - * `token`: _Description_: Github token to use to publish the check. @@ -31,7 +27,7 @@ Insights Engineering _Required_: `false` - _Default_: `.` + _Default_: `coverage.xml` * `threshold`: @@ -47,7 +43,7 @@ Insights Engineering _Required_: `false` - _Default_: `true` + _Default_: `True` * `publish`: @@ -55,7 +51,7 @@ Insights Engineering _Required_: `false` - _Default_: `false` + _Default_: `False` * `diff`: @@ -63,7 +59,7 @@ Insights Engineering _Required_: `false` - _Default_: `false` + _Default_: `False` * `diff-branch`: @@ -73,21 +69,21 @@ Insights Engineering _Default_: `main` -* `diff-storage`: +* `storage-subdirectory`: - _Description_: Branch where coverage reports are stored for diff purposes. + _Description_: Subdirectory in the diff-storage branch where the XML reports will be stored. _Required_: `false` - _Default_: `_xml_coverage_reports` + _Default_: `.` -* `storage-subdirectory`: +* `diff-storage`: - _Description_: Subdirectory in the diff-storage branch where the XML reports will be stored. + _Description_: Branch where coverage reports are stored for diff purposes. _Required_: `false` - _Default_: `.` + _Default_: `_xml_coverage_reports` * `coverage-summary-title`: @@ -103,7 +99,7 @@ Insights Engineering _Required_: `false` - _Default_: `false` + _Default_: `False` * `new-uncovered-statements-failure`: @@ -111,7 +107,7 @@ Insights Engineering _Required_: `false` - _Default_: `false` + _Default_: `False` * `pycobertura-exception-failure`: @@ -119,7 +115,7 @@ Insights Engineering _Required_: `false` - _Default_: `true` + _Default_: `True` * `togglable-report`: @@ -127,10 +123,21 @@ Insights Engineering _Required_: `false` - _Default_: `false` + _Default_: `False` -### Outputs +* `detailed-coverage`: + _Description_: Whether a table with a detailed coverage report should be added to PR comment. +The table contains the following information per file: +number of code statements, number of statements not covered by any test, +coverage percentage, and line numbers not covered by any test. + + + _Required_: `false` + + _Default_: `True` + +### Outputs None From b630e46c22db5621759d3c9e36632c9af94a9b5f Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 14 May 2024 16:10:31 +0200 Subject: [PATCH 3/6] Change input name --- README.md | 8 ++++---- action.yml | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/README.md b/README.md index 60285d6..d9ca2b0 100644 --- a/README.md +++ b/README.md @@ -125,17 +125,17 @@ Inisghts Engineering _Default_: `False` -* `detailed-coverage`: +* `exclude-detailed-coverage`: - _Description_: Whether a table with a detailed coverage report should be added to PR comment. -The table contains the following information per file: + _Description_: Whether a detailed coverage report should excluded from the PR comment. +The detailed coverage report contains the following information per file: number of code statements, number of statements not covered by any test, coverage percentage, and line numbers not covered by any test. _Required_: `false` - _Default_: `True` + _Default_: `False` ### Outputs * `summary`: diff --git a/action.yml b/action.yml index 9a768fa..dc54b06 100644 --- a/action.yml +++ b/action.yml @@ -61,14 +61,14 @@ inputs: description: Make the code coverage report togglable. required: false default: false - detailed-coverage: + exclude-detailed-coverage: description: | - Whether a table with a detailed coverage report should be added to PR comment. - The table contains the following information per file: + Whether a detailed coverage report should excluded from the PR comment. + The detailed coverage report contains the following information per file: number of code statements, number of statements not covered by any test, coverage percentage, and line numbers not covered by any test. required: false - default: true + default: false outputs: summary: @@ -248,7 +248,7 @@ runs: } fi echo -e "## ${{ inputs.coverage-summary-title }}\n" >> .coverage-output.final - if [[ "${{ inputs.detailed-coverage }}" == "true" ]] + if [[ "${{ inputs.exclude-detailed-coverage }}" == "false" ]] then { if [[ "${{ inputs.togglable-report }}" == "true" ]] then { @@ -300,7 +300,7 @@ runs: - name: Set as output id: create-output - run: | + run: | EOF=$(dd if=/dev/urandom bs=15 count=1 status=none | base64) echo "summary<<$EOF" >> $GITHUB_OUTPUT echo "$(cat .coverage-output.final)" >> $GITHUB_OUTPUT From a053ccbfa933270ea3d97ed8aebeeb91882f9e17 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 14 May 2024 16:20:48 +0200 Subject: [PATCH 4/6] Add test cases --- .github/workflows/test.yaml | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 631df52..6541adb 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -49,6 +49,24 @@ jobs: diff-branch: main diff-storage: _xml_coverage_reports_2 coverage-summary-title: "Code Coverage Summary (test-python.xml)" + - path: test-no-branch.xml + threshold: 90 + fail: true + publish: true + diff: true + diff-branch: main + diff-storage: _xml_coverage_reports_1 + coverage-summary-title: "Code Coverage Summary (test-no-branch.xml) without detailed coverage" + exclude-detailed-coverage: true + - path: test-missing-lines.xml + threshold: 50 + fail: false + publish: true + diff: false + diff-branch: main + diff-storage: _xml_coverage_reports + coverage-summary-title: "Code Coverage Summary (test-missing-lines.xml) without detailed coverage" + exclude-detailed-coverage: true steps: - name: Checkout Code 🛎 uses: actions/checkout@v4 From 813bb5a1e99a8c716910032005d7f27845e8c0bc Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 14 May 2024 16:29:56 +0200 Subject: [PATCH 5/6] Update test cases --- .github/workflows/test.yaml | 17 ++-- fixtures/test-missing-lines-2.xml | 154 ++++++++++++++++++++++++++++++ fixtures/test-no-branch-2.xml | 70 ++++++++++++++ 3 files changed, 235 insertions(+), 6 deletions(-) create mode 100644 fixtures/test-missing-lines-2.xml create mode 100644 fixtures/test-no-branch-2.xml diff --git a/.github/workflows/test.yaml b/.github/workflows/test.yaml index 6541adb..d786061 100644 --- a/.github/workflows/test.yaml +++ b/.github/workflows/test.yaml @@ -25,14 +25,16 @@ jobs: diff-branch: main diff-storage: _xml_coverage_reports coverage-summary-title: "Code Coverage Summary (test-branch.xml)" + exclude-detailed-coverage: false - path: test-missing-lines.xml threshold: 50 fail: false publish: true diff: false diff-branch: main - diff-storage: _xml_coverage_reports + diff-storage: _xml_coverage_reports_5 coverage-summary-title: "Code Coverage Summary (test-missing-lines.xml)" + exclude-detailed-coverage: false - path: test-no-branch.xml threshold: 90 fail: true @@ -41,6 +43,7 @@ jobs: diff-branch: main diff-storage: _xml_coverage_reports_1 coverage-summary-title: "Code Coverage Summary (test-no-branch.xml)" + exclude-detailed-coverage: false - path: test-python.xml threshold: 90 fail: false @@ -49,22 +52,23 @@ jobs: diff-branch: main diff-storage: _xml_coverage_reports_2 coverage-summary-title: "Code Coverage Summary (test-python.xml)" - - path: test-no-branch.xml + exclude-detailed-coverage: false + - path: test-no-branch-2.xml threshold: 90 fail: true publish: true diff: true diff-branch: main - diff-storage: _xml_coverage_reports_1 + diff-storage: _xml_coverage_reports_3 coverage-summary-title: "Code Coverage Summary (test-no-branch.xml) without detailed coverage" exclude-detailed-coverage: true - - path: test-missing-lines.xml + - path: test-missing-lines-2.xml threshold: 50 fail: false publish: true diff: false diff-branch: main - diff-storage: _xml_coverage_reports + diff-storage: _xml_coverage_reports_4 coverage-summary-title: "Code Coverage Summary (test-missing-lines.xml) without detailed coverage" exclude-detailed-coverage: true steps: @@ -81,4 +85,5 @@ jobs: diff: ${{ matrix.reports.diff }} diff-branch: ${{ matrix.reports.diff-branch }} diff-storage: ${{ matrix.reports.diff-storage }} - coverage-summary-title: ${{ matrix.reports.coverage-summary-title}} + coverage-summary-title: ${{ matrix.reports.coverage-summary-title }} + exclude-detailed-coverage: ${{ matrix.reports.exclude-detailed-coverage }} diff --git a/fixtures/test-missing-lines-2.xml b/fixtures/test-missing-lines-2.xml new file mode 100644 index 0000000..0c1b9a3 --- /dev/null +++ b/fixtures/test-missing-lines-2.xml @@ -0,0 +1,154 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/fixtures/test-no-branch-2.xml b/fixtures/test-no-branch-2.xml new file mode 100644 index 0000000..12354fa --- /dev/null +++ b/fixtures/test-no-branch-2.xml @@ -0,0 +1,70 @@ + + + + + + C:/local/mvn-coverage-example/src/main/java + --source + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + From a6dafaaeefce8cb369118ceb7c53c2e2f2226644 Mon Sep 17 00:00:00 2001 From: Franciszek Walkowiak Date: Tue, 14 May 2024 16:44:55 +0200 Subject: [PATCH 6/6] Typo --- README.md | 2 +- action.yml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d9ca2b0..93429ab 100644 --- a/README.md +++ b/README.md @@ -127,7 +127,7 @@ Inisghts Engineering * `exclude-detailed-coverage`: - _Description_: Whether a detailed coverage report should excluded from the PR comment. + _Description_: Whether a detailed coverage report should be excluded from the PR comment. The detailed coverage report contains the following information per file: number of code statements, number of statements not covered by any test, coverage percentage, and line numbers not covered by any test. diff --git a/action.yml b/action.yml index dc54b06..c38f0d6 100644 --- a/action.yml +++ b/action.yml @@ -63,7 +63,7 @@ inputs: default: false exclude-detailed-coverage: description: | - Whether a detailed coverage report should excluded from the PR comment. + Whether a detailed coverage report should be excluded from the PR comment. The detailed coverage report contains the following information per file: number of code statements, number of statements not covered by any test, coverage percentage, and line numbers not covered by any test.