Skip to content

Commit

Permalink
Merge pull request #22 from outfoxx/task/actions-update
Browse files Browse the repository at this point in the history
Simplify actions config and add sonarcloud support
  • Loading branch information
kdubb authored Dec 4, 2022
2 parents daceaba + 7099002 commit 6dabd7d
Show file tree
Hide file tree
Showing 7 changed files with 139 additions and 56 deletions.
48 changes: 7 additions & 41 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,15 +15,19 @@ jobs:
steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: '11'
java-version: '17'
distribution: oracle

- name: Build & Test
uses: burrunan/gradle-cache-action@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
with:
job-id: jdk11-build-test
arguments: check
arguments: check sonar

- name: Upload Reports
uses: actions/upload-artifact@v2
Expand All @@ -34,41 +38,3 @@ jobs:
core/build/reports/
okhttp/build/reports/
jdk/build/reports/
publish:
runs-on: ubuntu-latest

needs: [build-test]

concurrency: ci-${{ github.ref }}

if: github.event.pull_request.merged || github.event_name == 'push'

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
with:
java-version: '11'

- name: Build Artifacts & Documentation
uses: burrunan/gradle-cache-action@v1
with:
job-id: jdk11-build-test
arguments: build dokkaHtmlMultiModule -x test

- name: Publish Maven (Snapshot)
uses: burrunan/gradle-cache-action@v1
with:
job-id: jdk11-build-test
arguments: publishAllPublicationsToMavenCentralRepository
properties: |
ossrhUsername=${{ secrets.OSSRH_USER }}
ossrhPassword=${{ secrets.OSSRH_PASS }}
- name: Publish Documentation
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
clean: false
folder: build/dokka
Original file line number Diff line number Diff line change
@@ -1,30 +1,36 @@
name: Publish
name: Publish Release

on:
push:
tags: [ "[0-9]+.[0-9]+.[0-9]+**" ]

permissions:
contents: write

concurrency:
group: publish-release-${{github.ref_name}}
cancel-in-progress: false

jobs:

publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v1
- uses: actions/setup-java@v3
with:
java-version: '11'

- uses: olegtarasov/[email protected]
id: tagName
java-version: '17'
distribution: oracle

- name: Build Artifacts & Documentation
uses: burrunan/gradle-cache-action@v1
with:
job-id: jdk11-build-test
arguments: build dokkaHtmlMultiModule -x test
properties: |
releaseVersion=${{ steps.tagName.outputs.tag }}
releaseVersion=${{ github.ref_name }}
- name: Publish Release
uses: burrunan/gradle-cache-action@v1
Expand All @@ -36,7 +42,7 @@ jobs:
job-id: jdk11-build-test
arguments: publishRelease -x test
properties: |
releaseVersion=${{ steps.tagName.outputs.tag }}
releaseVersion=${{ github.ref_name }}
ossrhUsername=${{ secrets.OSSRH_USER }}
ossrhPassword=${{ secrets.OSSRH_PASS }}
github.token=${{ secrets.GITHUB_TOKEN }}
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/publish-snapshot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Publish Snapshot

on:
push:
branches: [ main ]

permissions:
contents: write

concurrency:
group: publish-snapshot-${{github.ref_name}}
cancel-in-progress: true

jobs:

publish:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2

- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: oracle

- name: Build Artifacts & Documentation
uses: burrunan/gradle-cache-action@v1
with:
job-id: jdk11-build-test
arguments: build dokkaHtmlMultiModule -x test

- name: Publish Maven Artifacts (Snapshot)
uses: burrunan/gradle-cache-action@v1
with:
job-id: jdk11-build-test
arguments: publishAllPublicationsToMavenCentralRepository
properties: |
ossrhUsername=${{ secrets.OSSRH_USER }}
ossrhPassword=${{ secrets.OSSRH_PASS }}
- name: Publish Documentation
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
clean: false
folder: build/dokka
39 changes: 33 additions & 6 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ plugins {

id("org.jetbrains.dokka")
id("com.github.breadmoirai.github-release")
id("org.sonarqube")


kotlin("jvm") apply (false)
id("org.cadixdev.licenser") apply (false)
Expand Down Expand Up @@ -40,8 +42,7 @@ allprojects {

}


subprojects {
configure(moduleNames.map { project(":sunday-$it") }) {

apply(plugin = "java-library")
apply(plugin = "jacoco")
Expand Down Expand Up @@ -115,11 +116,9 @@ subprojects {
}
}

finalizedBy("jacocoTestReport")
}
reports.junitXml.required.set(true)

tasks.named<JacocoReport>("jacocoTestReport").configure {
dependsOn("test")
finalizedBy("jacocoTestReport")
}


Expand Down Expand Up @@ -277,6 +276,34 @@ subprojects {
onlyIf { !isSnapshot }
}

sonarqube {
properties {
property("sonar.sources", "src/main")
property("sonar.tests", "src/test")
property("sonar.junit.reportPaths", "build/test-results/test")
property("sonar.jacoco.reportPath", "")
property("sonar.jacoco.reportPaths", "")
property(
"sonar.coverage.jacoco.xmlReportPaths",
"$rootDir/code-coverage/build/reports/jacoco/testCoverageReport/testCoverageReport.xml",
)
}
}

}


//
// ANALYSIS
//

sonarqube {
properties {
property("sonar.projectName", "sunday-kt")
property("sonar.projectKey", "outfoxx_sunday-kt")
property("sonar.organization", "outfoxx")
property("sonar.host.url", "https://sonarcloud.io")
}
}

//
Expand Down
34 changes: 34 additions & 0 deletions code-coverage/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@

plugins {
base
id("jacoco-report-aggregation")
}

repositories {
mavenCentral()
}

dependencies {
jacocoAggregation(project(":sunday-core"))
jacocoAggregation(project(":sunday-jdk"))
jacocoAggregation(project(":sunday-okhttp"))
}

reporting {
reports {
create<JacocoCoverageReport>("testCoverageReport") {
testType.set(TestSuiteType.UNIT_TEST)
reportTask {
reports.xml.required.set(true)
}
}
}
}

tasks {

check {
finalizedBy(named<JacocoReport>("testCoverageReport"))
}

}
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ licenserPluginVersion=0.6.1
kotlinterPluginVersion=3.4.4
detektPluginVersion=1.22.0
githubReleasePluginVersion=2.4.1

sonarqubeVersion=3.5.0.2730

slf4jVersion=2.0.4
kotlinCoroutinesVersion=1.6.4
Expand Down
3 changes: 3 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ pluginManagement {
val kotlinterPluginVersion: String by settings
val detektPluginVersion: String by settings
val githubReleasePluginVersion: String by settings
val sonarqubeVersion: String by settings

plugins {
kotlin("jvm") version kotlinPluginVersion
Expand All @@ -20,6 +21,7 @@ pluginManagement {
id("org.jmailen.kotlinter") version kotlinterPluginVersion
id("io.gitlab.arturbosch.detekt") version detektPluginVersion
id("com.github.breadmoirai.github-release") version githubReleasePluginVersion
id("org.sonarqube") version sonarqubeVersion
}

}
Expand All @@ -30,6 +32,7 @@ include(
"core",
"okhttp",
"jdk",
"code-coverage",
)

project(":core").name = "sunday-core"
Expand Down

0 comments on commit 6dabd7d

Please sign in to comment.