Skip to content

Commit 2203941

Browse files
authored
Infrastructure update (#164)
Infrastructure update
1 parent 27a25a0 commit 2203941

File tree

22 files changed

+708
-373
lines changed

22 files changed

+708
-373
lines changed

.github/workflows/build-and-test.yml

+6-6
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,6 @@ name: Build and run tests
22

33
on:
44
push:
5-
branches:
6-
- '*'
7-
- '*/*'
85
pull_request:
96
branches:
107
- develop
@@ -16,8 +13,11 @@ permissions:
1613

1714
jobs:
1815
build:
19-
# Skip duplicate build when pushing to already existing PR (in origin repo)
20-
if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
16+
# Skip duplicate build when pushing to already existing PR
17+
# Note: we decided NOT to skip duplicate builds,
18+
# since we upload test results via 'EnricoMi/publish-unit-test-result-action',
19+
# which requires 'pull_request' trigger for the bot to be able to add a comment to PR.
20+
# if: github.event_name == 'push' || github.event.pull_request.head.repo.full_name != github.repository
2121

2222
name: Build on JDK ${{ matrix.jdk }}
2323

@@ -46,7 +46,7 @@ jobs:
4646
cache-read-only: ${{ github.ref != 'refs/heads/main' && github.ref != 'refs/heads/develop' }}
4747

4848
- name: Build and run tests
49-
run: ./gradlew build --stacktrace
49+
run: ./gradlew build --stacktrace --scan
5050

5151
- name: Publish test results
5252
uses: EnricoMi/publish-unit-test-result-action@v2

.gitignore

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
build
2-
/.idea
3-
/.gradle
1+
.idea/
2+
.gradle/
3+
build/
44
idea-community
5-
/*.db
5+
*.db

build.gradle.kts

+51-68
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,37 @@
11
import org.jetbrains.dokka.gradle.DokkaTaskPartial
22
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
33

4-
val kotlinVersion: String by rootProject
5-
val coroutinesVersion: String by rootProject
6-
val junit5Version: String by project
74
val semVer: String? by project
85
val includeDokka: String? by project
96

107
group = "org.jacodb"
11-
12-
project.version = semVer ?: "1.2-SNAPSHOT"
13-
14-
buildscript {
15-
repositories {
16-
mavenCentral()
17-
maven(url = "https://plugins.gradle.org/m2/")
18-
}
19-
}
8+
version = semVer ?: "1.2-SNAPSHOT"
209

2110
plugins {
22-
val kotlinVersion = "1.7.21"
23-
11+
kotlin("jvm") version Versions.kotlin
12+
kotlin("plugin.allopen") version Versions.kotlin
13+
kotlin("plugin.serialization") version Versions.kotlin apply false
14+
with(Plugins.Dokka) { id(id) version (version) }
15+
with(Plugins.Licenser) { id(id) version (version) }
2416
`java-library`
17+
`java-test-fixtures`
2518
`maven-publish`
2619
signing
27-
`java-test-fixtures`
28-
kotlin("jvm") version kotlinVersion
29-
kotlin("plugin.allopen") version kotlinVersion
30-
id("org.jetbrains.dokka") version "1.7.20"
31-
32-
id("org.cadixdev.licenser") version "0.6.1"
3320
jacoco
3421
}
3522

36-
repositories {
37-
mavenCentral()
38-
}
39-
4023
allprojects {
4124
group = rootProject.group
4225
version = rootProject.version
4326

4427
apply {
45-
plugin("maven-publish")
4628
plugin("kotlin")
4729
plugin("org.jetbrains.kotlin.plugin.allopen")
48-
plugin("org.cadixdev.licenser")
49-
plugin("jacoco")
30+
plugin(Plugins.Dokka.id)
31+
plugin(Plugins.Licenser.id)
32+
plugin("maven-publish")
5033
plugin("signing")
51-
plugin("org.jetbrains.dokka")
34+
plugin("jacoco")
5235
}
5336

5437
repositories {
@@ -60,33 +43,26 @@ allprojects {
6043
}
6144

6245
dependencies {
63-
implementation(group = "org.jetbrains.kotlinx", name = "kotlinx-coroutines-core", version = coroutinesVersion)
46+
// Kotlin
47+
implementation(platform(kotlin("bom")))
48+
implementation(kotlin("stdlib-jdk8"))
6449

65-
implementation(group = "org.jetbrains.kotlin", name = "kotlin-stdlib-jdk8", version = kotlinVersion)
66-
implementation(group = "org.jetbrains.kotlin", name = "kotlin-reflect", version = kotlinVersion)
50+
// JUnit
51+
testImplementation(platform(Libs.junit_bom))
52+
testImplementation(Libs.junit_jupiter)
6753

68-
testImplementation("org.junit.jupiter:junit-jupiter") {
69-
version {
70-
strictly(junit5Version)
71-
}
72-
}
73-
testImplementation(group = "com.google.guava", name = "guava", version = "31.1-jre")
54+
// Test dependencies
55+
testRuntimeOnly(Libs.guava)
7456
}
7557

7658
tasks {
77-
78-
withType(DokkaTaskPartial::class).configureEach {
79-
dokkaSourceSets.configureEach {
80-
includes.from("README.md")
81-
}
82-
}
83-
8459
withType<JavaCompile> {
8560
sourceCompatibility = "1.8"
8661
targetCompatibility = "1.8"
8762
options.encoding = "UTF-8"
8863
options.compilerArgs = options.compilerArgs + "-Xlint:all"
8964
}
65+
9066
withType<KotlinCompile> {
9167
kotlinOptions {
9268
jvmTarget = "1.8"
@@ -99,6 +75,7 @@ allprojects {
9975
allWarningsAsErrors = false
10076
}
10177
}
78+
10279
compileTestKotlin {
10380
kotlinOptions {
10481
jvmTarget = "1.8"
@@ -111,6 +88,15 @@ allprojects {
11188
}
11289
}
11390

91+
withType<Test> {
92+
useJUnitPlatform()
93+
testLogging {
94+
events("passed", "skipped", "failed")
95+
}
96+
finalizedBy(jacocoTestReport) // report is always generated after tests run
97+
jvmArgs = listOf("-Xmx2g", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=heapdump.hprof")
98+
}
99+
114100
jacocoTestReport {
115101
dependsOn(test) // tests are required to run before generating the report
116102
classDirectories.setFrom(files(classDirectories.files.map {
@@ -124,13 +110,10 @@ allprojects {
124110
}
125111
}
126112

127-
withType<Test> {
128-
useJUnitPlatform()
129-
jvmArgs = listOf("-Xmx2g", "-XX:+HeapDumpOnOutOfMemoryError", "-XX:HeapDumpPath=heapdump.hprof")
130-
testLogging {
131-
events("passed", "skipped", "failed")
113+
withType<DokkaTaskPartial> {
114+
dokkaSourceSets.configureEach {
115+
includes.from("README.md")
132116
}
133-
finalizedBy(jacocoTestReport) // report is always generated after tests run
134117
}
135118
}
136119

@@ -145,7 +128,18 @@ allprojects {
145128
}
146129
}
147130

148-
val repoUrl: String? = project.properties["repoUrl"] as? String ?: "https://maven.pkg.github.com/UnitTestBot/jacodb"
131+
tasks.dokkaHtmlMultiModule {
132+
removeChildTasks(
133+
listOf(
134+
project(":jacodb-examples"),
135+
project(":jacodb-cli"),
136+
project(":jacodb-benchmarks")
137+
)
138+
)
139+
}
140+
141+
val repoUrl: String? = project.properties["repoUrl"] as? String
142+
?: "https://maven.pkg.github.com/UnitTestBot/jacodb"
149143

150144
if (!repoUrl.isNullOrEmpty()) {
151145
configure(
@@ -207,22 +201,6 @@ if (!repoUrl.isNullOrEmpty()) {
207201
}
208202
}
209203

210-
configure(listOf(rootProject)) {
211-
tasks {
212-
dokkaHtmlMultiModule {
213-
removeChildTasks(
214-
listOf(
215-
project(":jacodb-examples"),
216-
project(":jacodb-cli"),
217-
project(":jacodb-benchmarks")
218-
)
219-
)
220-
}
221-
}
222-
}
223-
224-
225-
226204
fun MavenPublication.signPublication(project: Project) = with(project) {
227205
signing {
228206
val gpgKey: String? by project
@@ -290,4 +268,9 @@ fun MavenPublication.addPom() {
290268
}
291269
}
292270
}
293-
}
271+
}
272+
273+
tasks.wrapper {
274+
gradleVersion = "8.3"
275+
distributionType = Wrapper.DistributionType.ALL
276+
}

buildSrc/build.gradle.kts

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
plugins {
2+
`kotlin-dsl`
3+
}
4+
5+
repositories {
6+
mavenCentral()
7+
}

buildSrc/settings.gradle.kts

Whitespace-only changes.

0 commit comments

Comments
 (0)