Skip to content
This repository was archived by the owner on Sep 24, 2025. It is now read-only.

Commit fc2910b

Browse files
author
Tue Ton
committed
generate jacoco and checkstyle reports
1 parent b8adcf7 commit fc2910b

File tree

4 files changed

+499
-18
lines changed

4 files changed

+499
-18
lines changed

.github/workflows/ci-build.yml

Lines changed: 50 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ on:
1010

1111
jobs:
1212
build_linux:
13-
name: Build and test in Linux environment
13+
name: Build and unit test in Linux environment
1414
runs-on: ubuntu-latest
1515
strategy:
1616
matrix:
@@ -43,17 +43,37 @@ jobs:
4343
- name: Grant execute permission for gradlew
4444
run: chmod +x gradlew
4545

46-
- name: Build all artefacts
46+
- name: Build all artifacts
4747
run: ./gradlew --no-daemon buildAll
4848

49+
- name: Archive build artifacts (built in linux and by Java 8 only)
50+
if: ${{ matrix.java-version == 8 }}
51+
uses: actions/upload-artifact@v1
52+
with:
53+
name: build-artifacts-linux-java${{ matrix.java-version }}
54+
path: build\distributions
55+
4956
- name: Run unit tests, excluding the Ldap*Test classes
5057
run: ./gradlew --no-daemon test -PexcludeTests=**/Ldap*Test.class
5158

59+
- name: Archive test reports, excluding the Ldap*Test classes
60+
uses: actions/upload-artifact@v1
61+
with:
62+
name: test-reports-no-LdapTests-linux-java${{ matrix.java-version }}
63+
path: build\reports\tests
64+
5265
- name: Run only the Ldap*Test unit tests
5366
run: ./gradlew --no-daemon test --tests *Ldap*Test
5467

68+
- name: Archive test report for the Ldap*Test
69+
uses: actions/upload-artifact@v1
70+
with:
71+
name: test-report-for-LdapTests-linux-java${{ matrix.java-version }}
72+
path: build\reports\tests
73+
74+
5575
build_windows:
56-
name: Build and test in Windows environment
76+
name: Build and unit test in Windows environment
5777
runs-on: windows-latest
5878
strategy:
5979
matrix:
@@ -83,12 +103,38 @@ jobs:
83103
java -version
84104
javac -version
85105
86-
- name: Build all artefacts
106+
- name: Build all artifacts
87107
run: .\gradlew.bat --no-daemon buildAll
88108

89109
- name: Run unit tests, excluding the LdapPublicKeyManagerTest class
90110
run: .\gradlew.bat --no-daemon test -PexcludeTests=**/LdapPublicKeyManagerTest.class
91111

112+
- name: Archive test reports, excluding LdapPublicKeyManagerTest
113+
uses: actions/upload-artifact@v1
114+
with:
115+
name: test-reports-no-LdapPublicKeyManagerTest-windows-java${{ matrix.java-version }}
116+
path: build\reports\tests
117+
118+
- name: Archive code coverage reports, excluding LdapPublicKeyManagerTest
119+
if: ${{ matrix.java-version == 8 }}
120+
uses: actions/upload-artifact@v1
121+
with:
122+
name: code-coverage-reports-windows-java${{ matrix.java-version }}
123+
path: build\reports\jacoco
124+
92125
- name: Run only the LdapPublicKeyManagerTest unit test class
93126
run: .\gradlew.bat --no-daemon test --tests *LdapPublicKeyManagerTest
94127

128+
- name: Archive test report for LdapPublicKeyManagerTest
129+
uses: actions/upload-artifact@v1
130+
with:
131+
name: test-report-for-LdapPublicKeyManagerTest-windows-java${{ matrix.java-version }}
132+
path: build\reports\tests
133+
134+
- name: Archive code coverage report for LdapPublicKeyManagerTest
135+
if: ${{ matrix.java-version == 8 }}
136+
uses: actions/upload-artifact@v1
137+
with:
138+
name: code-coverage-report-for-LdapPublicKeyManagerTest-windows-java${{ matrix.java-version }}
139+
path: build\reports\jacoco
140+

build.gradle

Lines changed: 52 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ group = 'com.gitblit'
1212
version = '1.9.2-SNAPSHOT'
1313
description = 'Gitblit'
1414

15-
//compiles build artefacts to
16-
//run under Java 1.8 and later versions
17-
sourceCompatibility = JavaVersion.VERSION_1_8
18-
targetCompatibility = JavaVersion.VERSION_1_8
15+
java {
16+
//compiles build artifacts to
17+
//run under Java 1.8 and later versions
18+
sourceCompatibility = JavaVersion.VERSION_1_8
19+
targetCompatibility = JavaVersion.VERSION_1_8
20+
}
1921

2022
ext {
2123
// Project Metadata
@@ -107,10 +109,19 @@ sourceSets {
107109
}
108110

109111
test {
110-
//Dynamic exclude some unit tests through property defined in the command line
112+
//Dynamically exclude some unit tests through a property defined at runtime
111113
if (project.hasProperty('excludeTests')) {
112114
exclude project.property('excludeTests')
113115
}
116+
finalizedBy jacocoTestReport //generate JaCoCo code coverage report after unit test run
117+
}
118+
119+
jacocoTestReport {
120+
//code coverage reports will be generated in the default build/reports/jacoco directory
121+
reports {
122+
xml.enabled true
123+
html.enabled true
124+
}
114125
}
115126

116127
task copyToRunDir(type: Copy) {
@@ -248,12 +259,42 @@ dependencies {
248259

249260
checkstyle {
250261
configFile = file('src/main/config/checkstyle.xml')
251-
ignoreFailures = true
252262
//sourceSets = [sourceSets.main, sourceSets.test]
253-
//showViolations = true
254-
//reportsDir = file("$project.buildDir/checkstyleReports")
255-
dependencies {
256-
checkstyle 'com.puppycrawl.tools:checkstyle:8.20'
263+
ignoreFailures = true
264+
showViolations = true
265+
toolVersion = '8.32'
266+
}
267+
tasks.withType(Checkstyle) {
268+
//disable the default HTML reporting (but leave the XML reporting on);
269+
//instead, HTML reports are produced by the custom task checkstyleHtmlReports below
270+
reports.html.enabled false
271+
}
272+
273+
task checkstyleHtmlReports {
274+
description = 'Run checkstyle tasks and generate their HTML reports'
275+
group = 'verification'
276+
277+
//depends on checkstyle tasks as specified by checkstyle.sourceSets property
278+
dependsOn {
279+
project.tasks.withType(Checkstyle).matching { task ->
280+
checkstyle.sourceSets.any { sourceSet ->
281+
task.name.equalsIgnoreCase('checkstyle'+sourceSet.name)
282+
}
283+
}
284+
}
285+
doLast {
286+
//generate HTML reports from all checkstyle tasks' XML reports
287+
//to be in the default build/reports/checkstyle directory
288+
//and separately in each sourceSet's subdirectory
289+
checkstyle.sourceSets.each { sourceSet ->
290+
ant.xslt(
291+
style: 'src/main/config/checkstyle-frames-errors.xsl',
292+
in: "${checkstyle.reportsDir}/${sourceSet.name}.xml",
293+
out: "${checkstyle.reportsDir}/${sourceSet.name}.html") {
294+
param (name: 'output.dir',
295+
expression: "${checkstyle.reportsDir}/${sourceSet.name}")
296+
}
297+
}
257298
}
258299
}
259300

@@ -682,8 +723,7 @@ task jarGitblitApiClasses(type: Jar) {
682723
'Implementation-Version': version,
683724
'Created-By': 'Gradle ' + getGradle().getGradleVersion(),
684725
'Build-Date': snapshotDate,
685-
'Build-Jdk': System.getProperty('java.version'),
686-
//'Main-Class': 'com.gitblit.client.GitblitClient'
726+
'Build-Jdk': System.getProperty('java.version')
687727
)
688728
}
689729

0 commit comments

Comments
 (0)