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

Code Coverage #54

Merged
merged 13 commits into from
May 24, 2024
Merged

Code Coverage #54

merged 13 commits into from
May 24, 2024

Conversation

ColeDCrawford
Copy link
Contributor

@ColeDCrawford ColeDCrawford commented May 22, 2024

The ci.yml updates add a commit to PRs. I tested this locally using act as best I could, but ran into an issue that I think will resolve when running on the real runner (undefined head).

The new workflow adds a badge to the readme based on coverage for Python 3.12.

This PR also removes some unnecessary files.

Closes #53

The ci.yml updates add a commit to PRs. I tested this locally using `act` as best I could, but ran into an issue that I think will resolve when running on the real runner (undefined head). We'll see how it works when the workflows actually run ...
The new workflow adds a badge to the readme based on coverage for Python 3.12.
@ColeDCrawford ColeDCrawford marked this pull request as draft May 22, 2024 22:41
@ColeDCrawford
Copy link
Contributor Author

@aweakley I might not have enough permissions for this to run (need to be able to modify comments on the PR)

@aweakley
Copy link
Member

I've made some changes on https://github.com/ixc/python-edtf/tree/53_coverage_ci_check which amounts to this. I think if we want to include those other items in the printed report we need to add junit-xml, but the comments I'm getting on the commits (eg. f262199 ) work well (especially by email).

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index fb06083..d5416ed 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -1,10 +1,12 @@
 name: CI
 
 on:
-    workflow_dispatch:
     pull_request:
+    push:
+    workflow_dispatch:
 
 permissions:
+  checks: write
   contents: write
   pull-requests: write
 
@@ -58,6 +60,7 @@ jobs:
                 coverage xml -o coverage_combined.xml --omit="edtf_django_tests/*"
 
             - name: Pytest coverage comment
+              id: coverageComment
               uses: MishaKav/pytest-coverage-comment@main
               with:
                 pytest-xml-coverage-path: ./coverage_combined.xml
@@ -68,12 +71,4 @@ jobs:
               run: |
                 echo "Coverage Percentage - ${{ steps.coverageComment.outputs.coverage }}"
                 echo "Coverage Color - ${{ steps.coverageComment.outputs.color }}"
-                echo "Coverage Html - ${{ steps.coverageComment.outputs.coverageHtml }}"
-                echo "Summary Report - ${{ steps.coverageComment.outputs.summaryReport }}"
                 echo "Coverage Warnings - ${{ steps.coverageComment.outputs.warnings }}"
-                echo "Coverage Errors - ${{ steps.coverageComment.outputs.errors }}"
-                echo "Coverage Failures - ${{ steps.coverageComment.outputs.failures }}"
-                echo "Coverage Skipped - ${{ steps.coverageComment.outputs.skipped }}"
-                echo "Coverage Tests - ${{ steps.coverageComment.outputs.tests }}"
-                echo "Coverage Time - ${{ steps.coverageComment.outputs.time }}"
-                echo "Not Success Test Info - ${{ steps.coverageComment.outputs.notSuccessTestInfo }}"

- Switch to using pytest-django to run the Django tests, as that has JUnit support. Add Django settings as a flag rather than in pyproject.toml because defining it there makes the normal pytest run fail since it can't find the module.
- Adds a simple script using junitparser to combine the two JUnit XML files.
```
File read successfully "/home/runner/work/python-edtf/python-edtf/./combined_junit_pytest.xml"
Warning: Your comment is too long (maximum is 65536 characters), coverage report will not be added.
Warning: Try add: "--cov-report=term-missing:skip-covered", or add "hide-report: true", or add "report-only-changed-files: true", or switch to "multiple-files" mode
```
@ColeDCrawford
Copy link
Contributor Author

@aweakley I rebased in your changes, added JUnit XML outputs, and tried adding back the JUnit stats. I was getting an error because the comments were too long and modified the coverage report to use the --cov-report=term-missing:skip-covered flag.

I think this is still failing because it is a fork: see MishaKav/pytest-coverage-comment#68. Not sure if you can tweak these permissions: MishaKav/pytest-coverage-comment#68 (comment). Otherwise you could try another branch off of this to see if the tests pass and then merge either that branch or this PR - I think the fork aspect is making this a bit of a headache.

@ColeDCrawford ColeDCrawford marked this pull request as ready for review May 23, 2024 15:54
@aweakley
Copy link
Member

It's got that permission already:
image

I've made another branch, but I'm getting the same-looking error, although I can see the output above now:

https://github.com/ixc/python-edtf/actions/runs/9217035942/job/25358362828#step:12:25

image

@aweakley
Copy link
Member

Ah 7e15e89 fixes it. I'll merge 53a_coverage_with_junit

@aweakley aweakley merged commit 6771172 into ixc:v5 May 24, 2024
0 of 10 checks passed
@aweakley
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants