Skip to content

Commit

Permalink
feat(cicd): publish jacoco report
Browse files Browse the repository at this point in the history
  • Loading branch information
tchiotludo committed Jun 13, 2024
1 parent 40cf623 commit 27a81a3
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 57 deletions.
14 changes: 13 additions & 1 deletion .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ jobs:
python3 -m pip install virtualenv
echo $GOOGLE_SERVICE_ACCOUNT | base64 -d > ~/.gcp-service-account.json
export GOOGLE_APPLICATION_CREDENTIALS=$HOME/.gcp-service-account.json
./gradlew check jacoco javadoc --no-daemon --priority=normal
./gradlew check javadoc --no-daemon --priority=normal
# Allure check
- name: Auth to Google Cloud
Expand All @@ -139,6 +139,18 @@ jobs:
copyLatest: true
ignoreMissingResults: true

# Jacoco
- name: 'Set up Cloud SDK'
if: ${{ env.GOOGLE_SERVICE_ACCOUNT != 0 }}
uses: 'google-github-actions/setup-gcloud@v2'

- name: 'Copy jacoco files'
if: ${{ env.GOOGLE_SERVICE_ACCOUNT != 0 }}
run: |
mv build/reports/jacoco/testCodeCoverageReport build/reports/jacoco/test/
mv build/reports/jacoco/test/testCodeCoverageReport.xml build/reports/jacoco/jacocoTestReport.xml
gsutil -m rsync -d -r build/reports/jacoco/test/ gs://internal-kestra-host/${{ format('{0}/{1}/{2}', github.repository, env.GITHUB_HEAD_REF_SLUG != '' && env.GITHUB_HEAD_REF_SLUG || github.ref_name, 'jacoco') }}
# report test
- name: Test Report
uses: mikepenz/action-junit-report@v4
Expand Down
103 changes: 47 additions & 56 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,12 @@ subprojects {
showPassedStandardStreams false
showSkippedStandardStreams true
}
}

/**********************************************************************************************************************\
* Allure Reports
**********************************************************************************************************************/
subprojects {
dependencies {
testImplementation platform("io.qameta.allure:allure-bom:2.27.0")
testImplementation "io.qameta.allure:allure-junit5"
Expand All @@ -256,6 +261,48 @@ subprojects {
}
}

/**********************************************************************************************************************\
* Jacoco
**********************************************************************************************************************/
subprojects {
apply plugin: 'jacoco'

test {
finalizedBy jacocoTestReport
}
}

dependencies {
jacocoAggregation subprojects
}

tasks.named('testCodeCoverageReport') {
dependsOn = subprojects.test
}

tasks.named('check') {
dependsOn tasks.named('testCodeCoverageReport', JacocoReport)
}

/**********************************************************************************************************************\
* Sonar
**********************************************************************************************************************/
subprojects {
sonar {
properties {
property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir.parentFile.path/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
}
}
}

sonar {
properties {
property "sonar.projectKey", "kestra-io_kestra"
property "sonar.organization", "kestra-io"
property "sonar.host.url", "https://sonarcloud.io"
}
}

/**********************************************************************************************************************\
* Micronaut
**********************************************************************************************************************/
Expand Down Expand Up @@ -352,62 +399,6 @@ task executableJar(type: Zip) {
archiveClassifier.set(null)
}

/**********************************************************************************************************************\
* Jacoco
**********************************************************************************************************************/
subprojects {
test {
finalizedBy jacocoTestReport
}

jacoco {
toolVersion = "0.8.11"
}

jacocoTestReport {
getAdditionalSourceDirs().setFrom(files(sourceSets.main.allSource.srcDirs))
getSourceDirectories().setFrom(files(sourceSets.main.allSource.srcDirs))
getClassDirectories().setFrom(files(sourceSets.main.output))
reports {
html.required = true
xml.required = true
}
}

sonar {
properties {
property "sonar.coverage.jacoco.xmlReportPaths", "$projectDir.parentFile.path/build/reports/jacoco/testCodeCoverageReport/testCodeCoverageReport.xml"
}
}
}


task jacoco(type: JacocoReport) {
dependsOn = subprojects.test

def javaProject = subprojects.findAll { it.name != 'ui' };

getAdditionalSourceDirs().setFrom(files(javaProject.sourceSets.main.allSource.srcDirs))
getSourceDirectories().setFrom(files(javaProject.sourceSets.main.allSource.srcDirs))
getClassDirectories().setFrom(files(javaProject.sourceSets.main.output))
getExecutionData().setFrom(files(javaProject.jacocoTestReport.executionData))
}

tasks.named('check') {
dependsOn tasks.named('testCodeCoverageReport', JacocoReport)
}

/**********************************************************************************************************************\
* Sonar
**********************************************************************************************************************/
sonar {
properties {
property "sonar.projectKey", "kestra-io_kestra"
property "sonar.organization", "kestra-io"
property "sonar.host.url", "https://sonarcloud.io"
}
}

/**********************************************************************************************************************\
* Standalone
**********************************************************************************************************************/
Expand Down

0 comments on commit 27a81a3

Please sign in to comment.