Skip to content

Commit deb60d1

Browse files
fix: use coverage:paths to rewrite paths in coverage files (#62)
1 parent 518c371 commit deb60d1

File tree

5 files changed

+11
-237
lines changed

5 files changed

+11
-237
lines changed

.github/workflows/sonarcloud.yml

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -96,27 +96,11 @@ jobs:
9696
working-directory: ./timefold-solver-python
9797
run: mvn org.apache.maven.plugins:maven-dependency-plugin:2.8:get -Dartifact=org.jacoco:org.jacoco.agent:0.8.11:jar:runtime -Ddest=target/jacocoagent.jar
9898
- name: Run tox to measure timefold solver python code coverage from Python tests
99-
continue-on-error: true # Sometimes the JVM segfaults on SUCCESSFUL tests with Java 17 (and always with Java 11)
10099
working-directory: ./timefold-solver-python
101100
run: python -m tox -- --cov=timefold --cov-report=xml:target/coverage.xml --cov-config=tox.ini --cov-branch --cov-append --jacoco-agent=./target/jacocoagent.jar
102101
- name: Run tox to measure jpyinterpreter code coverage from Python tests
103-
continue-on-error: true # Sometimes the JVM segfaults on SUCCESSFUL tests with Java 17 (and always with Java 11)
104102
working-directory: ./timefold-solver-python/jpyinterpreter
105103
run: python -m tox -- --cov=jpyinterpreter --cov-report=xml:target/coverage.xml --cov-config=tox.ini --cov-branch --cov-append --jacoco-agent=../target/jacocoagent.jar --jacoco-output=../target/jacoco.exec
106-
# Because we are using JPype, and JPype add it own import hook, we need to use --import-mode=importlib in pytest
107-
# This seems to create an issue in test coverage, where it reports coverage inside the tox virtual environment,
108-
# instead of coverage inside sources. For instance, for a package, it will report:
109-
# package name=".tox.py39.lib.python3.9.site-packages.jpyinterpreter"
110-
# and for a file it will report:
111-
# class name="jvm_setup.py" filename=".tox/py39/lib/python3.9/site-packages/jpyinterpreter/jvm_setup.py"
112-
# We need to convert the package and file names into their true names; i.e. for the example above:
113-
# package name="jpyinterpreter"
114-
# class name="jvm_setup.py" filename="jpyinterpreter/src/main/python/jvm_setup.py"
115-
# fix-coverage-paths.py is a Python script that does the above transformation for us and merge the two
116-
# separate coverage files into one.
117-
- name: Fix Python test coverage paths
118-
working-directory: ./timefold-solver-python
119-
run: python fix-coverage-paths.py
120104
- name: Run SonarCloud analysis
121105
working-directory: ./timefold-solver-python
122106
env:

fix-coverage-paths.py

Lines changed: 0 additions & 220 deletions
This file was deleted.

jpyinterpreter/tox.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ deps =
1515
JPype1>=1.5.0
1616
commands =
1717
pytest --import-mode=importlib {posargs}
18+
19+
[coverage:paths]
20+
source =
21+
src/main/python
22+
**/jpyinterpreter

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
<sonar.sources>src/main/java,src/main/python</sonar.sources>
2121
<sonar.tests>src/test/java,tests</sonar.tests>
2222
<sonar.python.version>3.9,3.10,3.11</sonar.python.version>
23-
<sonar.python.coverage.reportPaths>target/coverage.xml</sonar.python.coverage.reportPaths>
23+
<sonar.python.coverage.reportPaths>target/coverage.xml,jpyinterpreter/target/coverage.xml</sonar.python.coverage.reportPaths>
2424
</properties>
2525

2626
<dependencyManagement>

tox.ini

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,8 @@ deps =
1515
JPype1>=1.5.0
1616
commands =
1717
pytest --import-mode=importlib {posargs} tests
18+
19+
[coverage:paths]
20+
source =
21+
timefold-solver-python-core/src/main/python
22+
**/timefold/solver

0 commit comments

Comments
 (0)