diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index d5416ed..eeb1aed 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -16,7 +16,8 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + # python-version: ["3.8", "3.9", "3.10", "3.11", "3.12"] + python-version: ["3.11"] defaults: run: working-directory: . @@ -44,13 +45,13 @@ jobs: - name: Run unit tests run: | - pytest + pytest --junitxml=junit_pytest_main.xml mv .coverage .coverage_main - name: Run Django integration tests working-directory: ./edtf_django_tests run: | - coverage run manage.py test edtf_integration + pytest edtf_integration/tests.py --ds=edtf_django_tests.settings --junitxml=../junit_pytest_django.xml mv .coverage ../.coverage_django - name: Combine coverage reports @@ -59,11 +60,16 @@ jobs: coverage report --omit="edtf_django_tests/*" coverage xml -o coverage_combined.xml --omit="edtf_django_tests/*" + - name: Combine JUnit XML reports + run: | + python combine_junit.py combined_junit_pytest.xml junit_pytest_main.xml junit_pytest_django.xml + - name: Pytest coverage comment id: coverageComment uses: MishaKav/pytest-coverage-comment@main with: pytest-xml-coverage-path: ./coverage_combined.xml + junitxml-path: ./combined_junit_pytest.xml unique-id-for-comment: ${{ matrix.python-version }} github-token: ${{ secrets.GITHUB_TOKEN }} @@ -71,4 +77,12 @@ 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 }}" diff --git a/.gitignore b/.gitignore index 182cf8b..36df893 100644 --- a/.gitignore +++ b/.gitignore @@ -46,6 +46,10 @@ coverage_combined.xml .coverage_main .coverage_django *,cover +combined_junit_pytest.xml +pytest.xml +junit_pytest_main.xml +junit_pytest_django.xml # Translations *.mo diff --git a/combine_junit.py b/combine_junit.py new file mode 100644 index 0000000..5e3a05b --- /dev/null +++ b/combine_junit.py @@ -0,0 +1,23 @@ +import sys + +from junitparser import JUnitXml + + +def combine_junit_xml(output_file, *input_files): + combined_xml = JUnitXml() + for input_file in input_files: + xml = JUnitXml.fromfile(input_file) + combined_xml.extend(xml) + combined_xml.write(output_file) + + +if __name__ == "__main__": + if len(sys.argv) < 3: + print( + "Usage: python combine_junit_xml.py ... " + ) + sys.exit(1) + + output_file = sys.argv[1] + input_files = sys.argv[2:] + combine_junit_xml(output_file, *input_files) diff --git a/pyproject.toml b/pyproject.toml index 8dea9fd..64579ae 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -38,10 +38,12 @@ classifiers = [ test = [ "django>=4.2,<5.0", "pytest", + "pytest-django", "ruff", "pre-commit", "coverage", - "pytest-cov" + "pytest-cov", + "junitparser", ] [project.urls] @@ -79,7 +81,7 @@ legacy_tox_ini = """ python_files = ["tests.py", "test_*.py", "*_test.py", "*_tests.py"] python_classes = ["Test*", "*Tests"] python_functions = ["test_*"] -addopts = "--ignore=edtf_django_tests/ --cov=edtf --cov-report=xml" +addopts = "--ignore=edtf_django_tests/ --cov=edtf" plugins = ["pytest_cov"] [tool.coverage.run]