Skip to content

Commit

Permalink
:check task now triggers linting, bump gradle to 8.4 (#186)
Browse files Browse the repository at this point in the history
* `:check` task now triggers linting, bump gradle to 8.4

* Removed usage for `dependencyScope`

* Added publishing of build scans.

* Falling back to gradle 8.3 because of DefaultIvyPublicationIdentity error
  • Loading branch information
lamba92 authored and rock3r committed Oct 23, 2023
1 parent bfe969f commit f7270ca
Show file tree
Hide file tree
Showing 6 changed files with 68 additions and 51 deletions.
14 changes: 0 additions & 14 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,8 @@ jobs:
- name: Run :check task
run: ./gradlew check -Psupported.ij.version=${{ matrix.supported-ij-version }} --continue

- name: Merge SARIF reports
# Necessary because upload-sarif only takes up to 15 SARIF files and we have more
run: ./gradlew :mergeSarifReports -Psupported.ij.version=${{ matrix.supported-ij-version }}
if: ${{ always() }}

- uses: github/codeql-action/upload-sarif@v2
if: ${{ always() }}
with:
sarif_file: ${{ github.workspace }}/build/reports/static-analysis.sarif
checkout_path: ${{ github.workspace }}

- name: Upload reports for manual analysis
uses: actions/upload-artifact@v3
if: failure()
with:
name: Static analysis SARIF reports
path: ${{ github.workspace }}/build/reports/*.sarif
retention-days: 7
if-no-files-found: error
21 changes: 12 additions & 9 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
plugins {
alias(libs.plugins.composeDesktop) apply false
}

val sarif: Configuration by configurations.creating {
isCanBeResolved = true
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("sarif"))
}
`jewel-linting`
}

dependencies {
sarif(projects.core)
sarif(projects.samples.standalone)
sarif(projects.intUi.intUiStandalone)
sarif(projects.intUi.intUiDecoratedWindow)
sarif(projects.intUi.intUiCore)
sarif(projects.ideLafBridge)
sarif(projects.ideLafBridge.ideLafBridge232)
sarif(projects.ideLafBridge.ideLafBridge233)
sarif(projects.decoratedWindow)
sarif(projects.samples.idePlugin)
}

tasks {
register<MergeSarifTask>("mergeSarifReports") {
source(sarif)
val mergeSarifReports by registering(MergeSarifTask::class) {
source(configurations.outgoingSarif)
include { it.file.extension == "sarif" }
}
register("check") {
dependsOn(mergeSarifReports)
}
}
20 changes: 20 additions & 0 deletions buildSrc/src/main/kotlin/jewel-linting.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
@file:Suppress("UnstableApiUsage")

plugins {
id("io.gitlab.arturbosch.detekt")
id("org.jmailen.kotlinter")
}

configurations {
val dependencies = register("sarif") {
isCanBeDeclared = true
}
register("outgoingSarif") {
isCanBeConsumed = true
isCanBeResolved = true
extendsFrom(dependencies.get())
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("sarif"))
}
}
}
49 changes: 22 additions & 27 deletions buildSrc/src/main/kotlin/jewel.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
@file:Suppress("UnstableApiUsage")

import io.gitlab.arturbosch.detekt.Detekt
import org.gradle.api.attributes.Usage
import org.jmailen.gradle.kotlinter.tasks.FormatTask
import org.jmailen.gradle.kotlinter.tasks.LintTask

plugins {
id("io.gitlab.arturbosch.detekt")
id("org.jmailen.kotlinter")
id("jewel-linting")
kotlin("jvm")
}

Expand Down Expand Up @@ -49,48 +46,46 @@ detekt {
buildUponDefaultConfig = true
}

val sarif: Configuration by configurations.creating {
isCanBeConsumed = true
attributes {
attribute(Usage.USAGE_ATTRIBUTE, objects.named("sarif"))
}
}
val sarifReport = layout.buildDirectory.file("reports/ktlint-${project.name}.sarif")

tasks {
withType<Detekt> {
detektMain {
val sarifOutputFile = layout.buildDirectory.file("reports/detekt-${project.name}.sarif")
exclude { it.file.absolutePath.startsWith(layout.buildDirectory.asFile.get().absolutePath) }
reports {
sarif.required = true
sarif.outputLocation = sarifOutputFile
}
sarif.outgoing {
artifact(sarifOutputFile) {
builtBy(this@withType)
}
}
}

withType<FormatTask> {
lintKotlinMain {
exclude { it.file.absolutePath.contains("build/generated") }
}

withType<LintTask> {
exclude { it.file.absolutePath.contains("build/generated") }

val sarifReport = layout.buildDirectory.file("reports/ktlint-${project.name}.sarif")
reports = provider {
mapOf(
"plain" to layout.buildDirectory.file("reports/ktlint-${project.name}.txt").get().asFile,
"html" to layout.buildDirectory.file("reports/ktlint-${project.name}.html").get().asFile,
"sarif" to sarifReport.get().asFile
)
}
}
}

sarif.outgoing {
artifact(sarifReport) {
builtBy(this@withType)
}
configurations.named("sarif") {
outgoing {
artifact(tasks.detektMain.flatMap { it.sarifReportFile }) {
builtBy(tasks.detektMain)
}
artifact(sarifReport) {
builtBy(tasks.lintKotlinMain)
}
}
}

fun Task.removeAssembleDependency() {
setDependsOn(dependsOn.filter {
when {
it is Task && it.name == "assemble" -> false
else -> true
}
})
}
3 changes: 2 additions & 1 deletion decorated-window/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@ plugins {
alias(libs.plugins.composeDesktop)
}

private val composeVersion get() = ComposeBuildConfig.composeVersion
private val composeVersion
get() = ComposeBuildConfig.composeVersion

dependencies {
api("org.jetbrains.compose.foundation:foundation-desktop:$composeVersion")
Expand Down
12 changes: 12 additions & 0 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ dependencyResolutionManagement {
}
}

plugins {
id("com.gradle.enterprise") version "3.15.1"
}

include(
":core",
":decorated-window",
Expand All @@ -37,3 +41,11 @@ include(
":int-ui:int-ui-decorated-window",
":int-ui:int-ui-standalone",
)

gradleEnterprise {
buildScan {
publishAlwaysIf(System.getenv("CI") == "true")
termsOfServiceUrl = "https://gradle.com/terms-of-service"
termsOfServiceAgree = "yes"
}
}

0 comments on commit f7270ca

Please sign in to comment.