Skip to content

Commit 9aade15

Browse files
authored
skip errors of coverage reports (#10028)
1 parent dc20baf commit 9aade15

File tree

1 file changed

+9
-7
lines changed

1 file changed

+9
-7
lines changed

buildSrc/src/main/groovy/airbyte-python.gradle

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,16 @@ class Helpers {
3232
if (project.file(testFilesDirectory).exists()) {
3333

3434
project.projectDir.toPath().resolve(testFilesDirectory).traverse(type: FileType.FILES, nameFilter: ~/(^test_.*|.*_test)\.py$/) { file ->
35-
project.task("_${taskName}Coverage", type: PythonTask, dependsOn: taskDependencies) {
35+
project.task("_${taskName}Coverage", type: PythonTask) {
3636
module = "coverage"
37-
command = "run --rcfile=${project.rootProject.file('tools/python/.coveragerc').absolutePath} -m pytest -s ${testFilesDirectory}"
37+
command = "run --data-file=${testFilesDirectory}/.coverage.${taskName} --rcfile=${project.rootProject.file('tools/python/.coveragerc').absolutePath} -m pytest -s ${testFilesDirectory}"
3838
}
39-
project.task(taskName, type: PythonTask, dependsOn: taskDependencies) {
40-
module = "coverage"
41-
// command = "run --rcfile=${project.rootProject.file('tools/python/.coveragerc').absolutePath} -m pytest -s ${testFilesDirectory}"
42-
command = "report --rcfile=${project.rootProject.file('tools/python/.coveragerc').absolutePath}"
39+
// generation of coverage report is optional and we should skip it if tests are empty
40+
project.task(taskName, type: Exec, dependsOn: taskDependencies) {
41+
commandLine = ".venv/bin/python"
42+
args "-m", "coverage", "report", "--data-file=${testFilesDirectory}/.coverage.${taskName}", "--rcfile=${project.rootProject.file('tools/python/.coveragerc').absolutePath}"
4343
dependsOn project.tasks.findByName("_${taskName}Coverage")
44+
setIgnoreExitValue true
4445

4546
}
4647
// If a file is found, terminate the traversal, thus causing this task to be declared at most once
@@ -76,9 +77,10 @@ class AirbytePythonPlugin implements Plugin<Project> {
7677
pip 'isort:5.6.4'
7778
pip 'pytest:6.1.2'
7879
pip 'pip:21.1.3'
79-
pip 'coverage[toml]:6.2'
80+
pip 'coverage[toml]:6.3.1'
8081
}
8182

83+
8284
project.task('isortFormat', type: PythonTask) {
8385
module = "isort"
8486
command = ". --settings-file ${project.rootProject.file('tools/python/.isort.cfg').absolutePath}"

0 commit comments

Comments
 (0)