Skip to content

Commit 75e9845

Browse files
committed
Add CI and configure code coverage
Signed-off-by: Matt Ramotar <[email protected]>
1 parent 1cf6182 commit 75e9845

File tree

7 files changed

+96
-1
lines changed

7 files changed

+96
-1
lines changed

.codecov.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
coverage:
2+
range: 70..80
3+
round: down
4+
precision: 2
5+
6+
comment:
7+
layout: diff, files
8+
9+
ignore:
10+
- "**/fake"
11+
- "**/commonTest"
12+
- "**/androidTest"
13+
- "**/iOSTest"
14+
- "**/jsTest"
15+
- "**/jvmTest"

.github/workflows/ci.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
branches:
9+
- main
10+
11+
jobs:
12+
build-and-test:
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 30
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
api-level:
19+
- 29
20+
steps:
21+
22+
- name: Checkout
23+
uses: actions/checkout@v3
24+
with:
25+
ref: ${{ github.head_ref || github.ref }}
26+
fetch-depth: 0
27+
persist-credentials: false
28+
29+
- name: Set up JDK 17
30+
uses: actions/setup-java@v4
31+
with:
32+
distribution: 'zulu'
33+
java-version: '17'
34+
35+
- name: Setup Gradle
36+
uses: gradle/gradle-build-action@v2
37+
38+
- name: Grant execute permission for Gradlew
39+
run: chmod +x gradlew
40+
41+
- name: Build and Test with Coverage
42+
run: ./gradlew clean build koverXmlReport --stacktrace
43+
44+
- name: Upload Coverage to Codecov
45+
uses: codecov/codecov-action@v4
46+
with:
47+
token: ${{ secrets.CODECOV_TOKEN }}
48+
files: build/reports/kover/coverage.xml
49+
flags: unittests
50+
name: codecov-umbrella
51+
fail_ci_if_error: true
52+
verbose: true

.gitignore

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,5 +42,12 @@ bin/
4242
### Mac OS ###
4343
.DS_Store
4444

45+
kotlin-js-store/
46+
4547
backend/server/postgres.yaml
46-
**/backend/server/data/*
48+
**/backend/server/data/*
49+
50+
# Ignore coverage reports
51+
**/*/coverage.xml
52+
**/*/build/kover/
53+
**/*/build/reports/kover/

gradle/libs.versions.toml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@ desugar = "2.1.2"
1111
hikaricp = "5.0.1"
1212
jetbrains-compose = "1.6.11"
1313
kotlinx-datetime = "0.6.1"
14+
kover-gradle-plugin = "0.9.0-RC"
1415
ksp = "2.0.21-1.0.25"
1516
kotlin = "2.0.21"
1617
kotlin-inject = "0.7.2"
1718
kotlinx-coroutines = "1.9.0"
1819
kotlinx-serialization = "1.7.3"
20+
kover = "0.9.0-RC"
1921
ktor = "3.0.0"
2022
junit = "4.13.2"
2123
mokkery-gradle = "2.5.1"
@@ -47,6 +49,7 @@ kotlinx-datetime = { module = "org.jetbrains.kotlinx:kotlinx-datetime", version.
4749
kotlinx-serialization-core = { module = "org.jetbrains.kotlinx:kotlinx-serialization-core", version.ref = "kotlinx-serialization" }
4850
kotlinx-serialization-json = { module = "org.jetbrains.kotlinx:kotlinx-serialization-json", version.ref = "kotlinx-serialization" }
4951

52+
kover-gradle-plugin = { module = "org.jetbrains.kotlinx:kover-gradle-plugin", version.ref = "kover-gradle-plugin" }
5053
ktor-core = { module = "io.ktor:ktor-client-core", version.ref = "ktor" }
5154
ktor-negotiation = { module = "io.ktor:ktor-client-content-negotiation", version.ref = "ktor" }
5255
ktor-serialization = { module = "io.ktor:ktor-client-serialization", version.ref = "ktor" }
@@ -104,3 +107,4 @@ ktor = {id = "io.ktor.plugin", version.ref = "ktor"}
104107
sqldelight = { id = "app.cash.sqldelight", version.ref = "sqldelight" }
105108
paparazzi = { id = "app.cash.paparazzi", version.ref = "paparazzi" }
106109
kotlin-plugin-parcelize = { id = "org.jetbrains.kotlin.plugin.parcelize", version.ref = "kotlin" }
110+
kover = {id = "org.jetbrains.kotlinx.kover", version.ref = "kover"}

tooling/plugins/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ dependencies {
1717
compileOnly(libs.android.gradle.plugin)
1818
compileOnly(libs.kotlin.gradle.plugin)
1919
implementation(libs.mokkery.gradle)
20+
implementation(libs.kover.gradle.plugin)
2021
}
2122

2223
gradlePlugin {

tooling/plugins/src/main/kotlin/org/mobilenativefoundation/trails/tooling/plugins/KotlinMultiplatformConventionPlugin.kt

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.mobilenativefoundation.trails.tooling.plugins
22

3+
import kotlinx.kover.gradle.plugin.dsl.KoverProjectExtension
34
import org.gradle.api.Plugin
45
import org.gradle.api.Project
56
import org.gradle.configurationcache.extensions.capitalized
@@ -12,12 +13,14 @@ import org.jetbrains.kotlin.gradle.plugin.KotlinPlatformType
1213
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
1314
import org.mobilenativefoundation.trails.tooling.extensions.configureKotlin
1415
import org.mobilenativefoundation.trails.tooling.extensions.libs
16+
import java.io.File
1517

1618
class KotlinMultiplatformConventionPlugin : Plugin<Project> {
1719
override fun apply(target: Project) = with(target) {
1820
with(pluginManager) {
1921
apply("org.jetbrains.kotlin.multiplatform")
2022
apply("dev.mokkery")
23+
apply("org.jetbrains.kotlinx.kover")
2124
}
2225

2326
version = libs.findVersion("trails")
@@ -78,6 +81,17 @@ class KotlinMultiplatformConventionPlugin : Plugin<Project> {
7881

7982
configureKotlin()
8083
}
84+
85+
extensions.configure<KoverProjectExtension> {
86+
reports {
87+
total {
88+
xml {
89+
onCheck.set(true)
90+
xmlFile.set(target.layout.buildDirectory.file("reports/kover/coverage.xml"))
91+
}
92+
}
93+
}
94+
}
8195
}
8296
}
8397

xplat/lib/repositories/post/impl/build.gradle.kts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import org.gradle.internal.impldep.org.testng.reporters.XMLUtils
2+
13
plugins {
24
id("plugin.trails.android.library")
35
id("plugin.trails.kotlin.multiplatform")

0 commit comments

Comments
 (0)