-
Notifications
You must be signed in to change notification settings - Fork 297
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
Development
: Execute tests only for changed modules on non-default branchs
#10036
Open
ole-ve
wants to merge
69
commits into
develop
Choose a base branch
from
chore/ci-test-changed-modules
base: develop
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 68 commits
Commits
Show all changes
69 commits
Select commit
Hold shift + click to select a range
30a887e
Add dashboard for endpoint monitoring
ole-ve f584586
Update dashboard
ole-ve 1acbe40
Make number of top endpoints a variable
ole-ve c9732aa
Debug: Append something to job summary
ole-ve 0bb5333
Append per-module coverage to job summary (hardcoded module)
ole-ve c273d60
Temporarily add current branch to push triggering branches
ole-ve c2d0dfc
draft for module coverage
ole-ve 48a4396
Extract jacoco gradle config from build.gradle to jacoco.gradle
ole-ve 2e4d796
Only test changed modules
ole-ve 739f60a
Parse and append per-module coverage results
ole-ve fd39101
Temporarily remove codacy coverage report upload
ole-ve 5a409be
Upload whole build coverage report directory
ole-ve 9e7d3cf
Temporarily fix tested modules
ole-ve 5083184
temporarily add ArchitectureTest to have at least one test
ole-ve 27b68ba
fix GH variable name of default branch
ole-ve d2a6f33
clone default branch if not running for the base branch
ole-ve 5cbeac4
prefix branch name to compare with "origin/"
ole-ve f7e1408
remove null tasks from dependant list
ole-ve 49c151f
correctly type testedModules as ArrayList
ole-ve e3def21
(temporarily) directly set TEST_MODULE_TAGS instead of evaluating wit…
ole-ve 43b65eb
Add logging on executed test tags
ole-ve 476c792
quote TEST_MODULE_TAGS
ole-ve 786d172
log gradle command
ole-ve b31f0c8
Revert "log gradle command"
ole-ve 2fd5936
split into includeModules and includeTags
ole-ve f394c70
change buildagent thresholds to match module-only results
ole-ve e022592
Move basePath from jacoco.gradle to build.gradle
ole-ve 7dd9730
ensure module-specific jacoco task runs after "rootTask"
ole-ve 98227e8
add comment on including junit tags logic
ole-ve c860849
create jacoco report for full Artemis bundle also when testing specif…
ole-ve 6453837
remove debugging step from pipeline
ole-ve 9c4348f
adapt expected number of server starts
ole-ve 42b9f88
use finalizedBy instead of mustRunAfter
ole-ve 39f568d
make report paths explicit
ole-ve d67a9b4
adjust per-module covered instruction threshold for fileupload
ole-ve e15e05f
remove hardcoded TEST_MODULE_TAGS from test pipeline
ole-ve 78f77a5
move jacoco-parser to .ci-dir and rename to execute.py
ole-ve ad657cf
move jacoco.gradle to gradle-dir
ole-ve cfc2f38
move changed-modules.sh to .dir directory
ole-ve 8b6aa0c
fix logic of number of server starts script
ole-ve 1f54c61
update isolated coverage threshold per module
ole-ve be4da5e
move generate_code_cov_table to subfolder
ole-ve 49ddd27
move get_changed_modules.sh to supporting scripts
ole-ve 46280fe
move parse_module_coverage to supporting scripts
ole-ve 1cad26f
add documentation to get_changed_modules.sh
ole-ve bfd2c8d
use test filters instead of "include" to ensure test results are crea…
ole-ve 6e0baa5
println for missing coverage message
ole-ve 5ab2996
add info on return type of get_changed_modules.sh
ole-ve 7fd0ad0
refactor: separate concerns in parse_module_coverage.py
ole-ve 2a2b8d7
rename get_changed_modules.sh to test_changed_modules.sh
ole-ve 5de1c8a
Revert "rename get_changed_modules.sh to test_changed_modules.sh"
ole-ve 9de9c3a
fix issues with parse_module_coverage.py
ole-ve 4cdb0fa
remove branch input validation
ole-ve e1748af
generate full reports when no input modules specified
ole-ve 240aef1
change message to be more explicit about skipping coverage verification
ole-ve b1042a4
add debugging
ole-ve e668fb9
Revert "add debugging"
ole-ve 3cdfda7
log command
ole-ve 42d0b82
move test module tags further into the command
ole-ve 53ca8d0
add stacktrace logging
ole-ve 20a43df
explicitly run all or only-specific tests
ole-ve ce82e2e
remove unused file
ole-ve 4ccaa0a
fix module name in error message
ole-ve 7d3cc92
remove fixed branch
ole-ve 8c58a39
change upload artifact path
ole-ve dbe638e
add codacy step again
ole-ve 830d2bd
fix jacoco report output location for aggregated report
ole-ve 7e59059
rename jacocoCoverageReport.xml to jacocoTestReport.xml
ole-ve 631e229
include tests into determination of changed modules
ole-ve File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,217 @@ | ||
ext { | ||
AggregatedCoverageThresholds = [ | ||
"INSTRUCTION": 0.900, | ||
"CLASS": 10 | ||
]; | ||
// (Isolated) thresholds when executing each module on its own | ||
ModuleCoverageThresholds = [ | ||
"assessment" : [ | ||
"INSTRUCTION": 0.774, | ||
"CLASS": 9 | ||
], | ||
"athena" : [ | ||
"INSTRUCTION": 0.863, | ||
"CLASS": 2 | ||
], | ||
"atlas" : [ | ||
"INSTRUCTION": 0.846, | ||
"CLASS": 13 | ||
], | ||
"buildagent" : [ | ||
"INSTRUCTION": 0.304, | ||
"CLASS": 13 | ||
], | ||
"communication": [ | ||
"INSTRUCTION": 0.893, | ||
"CLASS": 7 | ||
], | ||
"core" : [ | ||
"INSTRUCTION": 0.658, | ||
"CLASS": 69 | ||
], | ||
"exam" : [ | ||
"INSTRUCTION": 0.914, | ||
"CLASS": 1 | ||
], | ||
"exercise" : [ | ||
"INSTRUCTION": 0.649, | ||
"CLASS": 9 | ||
], | ||
"fileupload" : [ | ||
"INSTRUCTION": 0.944, | ||
"CLASS": 0 | ||
], | ||
"iris" : [ | ||
"INSTRUCTION": 0.706, | ||
"CLASS": 22 | ||
], | ||
"lecture" : [ | ||
"INSTRUCTION": 0.867, | ||
"CLASS": 0 | ||
], | ||
"lti" : [ | ||
"INSTRUCTION": 0.770, | ||
"CLASS": 3 | ||
], | ||
"modeling" : [ | ||
"INSTRUCTION": 0.892, | ||
"CLASS": 2 | ||
], | ||
"plagiarism" : [ | ||
"INSTRUCTION": 0.770, | ||
"CLASS": 1 | ||
], | ||
"programming" : [ | ||
"INSTRUCTION": 0.861, | ||
"CLASS": 13 | ||
], | ||
"quiz" : [ | ||
"INSTRUCTION": 0.785, | ||
"CLASS": 6 | ||
], | ||
"text" : [ | ||
"INSTRUCTION": 0.847, | ||
"CLASS": 0 | ||
], | ||
"tutorialgroup": [ | ||
"INSTRUCTION": 0.915, | ||
"CLASS": 0 | ||
], | ||
] | ||
// If no explicit modules defined -> generate reports and validate for each module | ||
reportedModules = includedModules.size() == 0 | ||
? ModuleCoverageThresholds.collect {element -> element.key} | ||
: includedModules as ArrayList | ||
|
||
// we want to ignore some generated files in the domain folders | ||
ignoredDirectories = [ | ||
"**/$BasePath/**/domain/**/*_*", | ||
"**/$BasePath/core/config/migration/entries/**", | ||
"**/gradle-wrapper.jar/**" | ||
] | ||
} | ||
|
||
jacoco { | ||
toolVersion = "0.8.12" | ||
} | ||
|
||
jacocoTestReport { | ||
// For the aggregated report | ||
reports { | ||
xml.required = true | ||
xml.outputLocation = file("build/reports/jacoco/test/jacocoTestReport.xml") | ||
html.required = true | ||
html.outputLocation = file("build/reports/jacoco/test/html") | ||
} | ||
|
||
finalizedBy reportedModules | ||
.collect { module -> registerJacocoReportTask(module as String, jacocoTestReport) } | ||
.findAll { task -> task != null} | ||
} | ||
|
||
jacocoTestCoverageVerification { | ||
// Only run full coverage when no specific modules set | ||
enabled = reportedModules.size() == 0 | ||
|
||
def minInstructionCoveredRatio = AggregatedCoverageThresholds["INSTRUCTION"] as double | ||
def maxNumberUncoveredClasses = AggregatedCoverageThresholds["CLASS"] as int | ||
applyVerificationRule(jacocoTestCoverageVerification, minInstructionCoveredRatio, maxNumberUncoveredClasses) | ||
|
||
finalizedBy reportedModules | ||
.collect { module -> registerJacocoTestCoverageVerification(module as String, jacocoTestCoverageVerification) } | ||
.findAll { task -> task != null} | ||
} | ||
check.dependsOn jacocoTestCoverageVerification | ||
|
||
/** | ||
* Registers a JacocoReport task based on the provided parameters. | ||
* | ||
* @param moduleName The module name to include in the report. | ||
* @param rootTask The root JacocoReport root task. | ||
* @return The configured JacocoReport task. | ||
*/ | ||
private JacocoReport registerJacocoReportTask(String moduleName, JacocoReport rootTask) { | ||
def taskName = "jacocoCoverageReport-$moduleName" | ||
|
||
JacocoReport task = project.tasks.register(taskName, JacocoReport).get() | ||
task.description = "Generates JaCoCo coverage report for $moduleName" | ||
|
||
prepareJacocoReportTask(task, moduleName, rootTask) | ||
|
||
task.reports { | ||
xml.required = true | ||
xml.outputLocation = file("build/reports/jacoco/$moduleName/jacocoTestReport.xml") | ||
html.required = true | ||
html.outputLocation = file("build/reports/jacoco/$moduleName/html") | ||
} | ||
|
||
return task | ||
} | ||
|
||
/** | ||
* Registers a JacocoCoverageVerification task based on the provided parameters. | ||
* | ||
* @param moduleName The module name to validate rules for. | ||
* @param rootTask The root JacocoCoverageVerification task. | ||
* @return The configured JacocoCoverageVerification task. | ||
*/ | ||
private JacocoCoverageVerification registerJacocoTestCoverageVerification(String moduleName, JacocoCoverageVerification rootTask) { | ||
def taskName = "jacocoTestCoverageVerification-$moduleName" | ||
|
||
def thresholds = ModuleCoverageThresholds[moduleName] | ||
if (thresholds == null) { | ||
println "No coverage thresholds defined for module '$moduleName'. Skipping verification..." | ||
return null | ||
} | ||
def minInstructionCoveredRatio = thresholds["INSTRUCTION"] as double | ||
def maxNumberUncoveredClasses = thresholds["CLASS"] as int | ||
|
||
JacocoCoverageVerification task = project.tasks.register(taskName, JacocoCoverageVerification).get() | ||
task.description = "Validates JaCoCo coverage for vioalations for $moduleName" | ||
|
||
prepareJacocoReportTask(task, moduleName, rootTask) | ||
applyVerificationRule(task, minInstructionCoveredRatio, maxNumberUncoveredClasses) | ||
|
||
return task | ||
} | ||
|
||
/** | ||
* Prepares a Jacoco report task (report & verification) to match a specific | ||
* @param task that is modified | ||
* @param moduleName of the module. | ||
* @param rootTask the JacocoReportBase root task | ||
*/ | ||
private void prepareJacocoReportTask(JacocoReportBase task, String moduleName, JacocoReportBase rootTask) { | ||
task.group = "Reporting" | ||
task.executionData = project.fileTree("${project.layout.buildDirectory.get()}/jacoco") { | ||
include "test.exec" | ||
} | ||
|
||
def modulePath = "$BasePath/$moduleName/**/*.class" | ||
task.sourceDirectories.setFrom(project.files("src/main/java/$modulePath")) | ||
task.classDirectories.setFrom( | ||
files(rootTask.classDirectories.files.collect { classDir -> | ||
project.fileTree(classDir) { | ||
includes=[modulePath] | ||
excludes=ignoredDirectories | ||
} | ||
}) | ||
) | ||
} | ||
|
||
private static void applyVerificationRule(JacocoCoverageVerification task, double minInstructionCoveredRatio, int maxNumberUncoveredClasses) { | ||
task.violationRules { | ||
rule { | ||
limit { | ||
counter = "INSTRUCTION" | ||
value = "COVEREDRATIO" | ||
minimum = minInstructionCoveredRatio | ||
} | ||
limit { | ||
counter = "CLASS" | ||
value = "MISSEDCOUNT" | ||
maximum = maxNumberUncoveredClasses | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prevent path traversal vulnerability
The module path construction should validate the module name to prevent path traversal.
📝 Committable suggestion