Skip to content

Commit 31451f4

Browse files
authored
add jacoco report (#5)
* add jacoco report * fix * test * test * fix * create coverage badge * fix json path * fix permission * update deploy
1 parent e480d6c commit 31451f4

File tree

5 files changed

+69
-32
lines changed

5 files changed

+69
-32
lines changed

.github/workflows/test_and_run_demo.yaml

Lines changed: 65 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -5,42 +5,77 @@ name: kmp-socketio build and test.
55

66
on:
77
push:
8-
branches: [ "main" ]
8+
branches: ["main"]
99
pull_request:
10-
branches: [ "main" ]
10+
branches: ["main"]
1111
workflow_call:
1212

1313
permissions:
1414
contents: read
1515

1616
jobs:
1717
build:
18-
strategy:
19-
fail-fast: false
20-
matrix:
21-
include:
22-
- cmd: "${GITHUB_WORKSPACE}/gradlew :kmp-socketio:jvmTest --info"
23-
os: ubuntu-latest
24-
dep: "cd ${GITHUB_WORKSPACE}/kmp-socketio/src/jvmTest/resources/ && npm install"
25-
runs-on: ${{ matrix.os }}
26-
18+
runs-on: ubuntu-latest
19+
permissions:
20+
pull-requests: write
21+
contents: write
22+
id-token: write
2723
steps:
28-
- uses: actions/checkout@v4
29-
with:
30-
submodules: 'recursive'
31-
- uses: actions/setup-java@v4
32-
with:
33-
java-version: '17'
34-
distribution: 'temurin'
35-
cache: 'gradle'
36-
- uses: gradle/actions/setup-gradle@v3
37-
- uses: actions/setup-node@v4
38-
with:
39-
node-version: 14
40-
- if: ${{ matrix.dep }}
41-
run: ${{ matrix.dep }}
42-
- if: ${{ matrix.os == 'windows-latest' }}
43-
shell: cmd
44-
run: ${{ matrix.cmd }}
45-
- if: ${{ matrix.os != 'windows-latest' }}
46-
run: ${{ matrix.cmd }}
24+
- uses: actions/checkout@v4
25+
with:
26+
submodules: "recursive"
27+
- uses: actions/setup-java@v4
28+
with:
29+
java-version: "17"
30+
distribution: "temurin"
31+
cache: "gradle"
32+
- uses: gradle/actions/setup-gradle@v3
33+
- uses: actions/setup-node@v4
34+
with:
35+
node-version: 14
36+
- name: Setup Test Env
37+
run: |
38+
cd kmp-socketio/src/jvmTest/resources/
39+
npm install
40+
- name: Run Jvm tests
41+
run: |
42+
./gradlew :kmp-socketio:jvmTest --info
43+
- name: Gen coverage
44+
run: |
45+
./gradlew koverXmlReport
46+
- name: Add coverage to PR
47+
id: jacoco
48+
uses: madrapps/[email protected]
49+
with:
50+
paths: ${{ github.workspace }}/kmp-socketio/build/reports/kover/report.xml
51+
token: ${{ secrets.GITHUB_TOKEN }}
52+
min-coverage-overall: 80
53+
min-coverage-changed-files: 80
54+
pass-emoji: ":white_check_mark:"
55+
fail-emoji: ":negative_squared_cross_mark:"
56+
- name: Overall coverage check
57+
if: ${{ steps.jacoco.outputs.coverage-overall < 80 || steps.jacoco.outputs.coverage-changed-files < 80 }}
58+
uses: actions/github-script@v7
59+
with:
60+
script: |
61+
core.setFailed("Coverage check failed! overall ${{ steps.jacoco.outputs.coverage-overall }}, diff ${{ steps.jacoco.outputs.coverage-changed-files }}.")
62+
- name: Create coverage summary json
63+
uses: jsdaniell/[email protected]
64+
with:
65+
dir: kmp-socketio/build/reports/kover/
66+
name: "coverage.json"
67+
json: '{"total":{"instructions":{"pct":${{ steps.jacoco.outputs.coverage-overall }} }}}'
68+
- name: Create Coverage Badges
69+
uses: jaywcjlove/coverage-badges-cli@main
70+
with:
71+
style: flat
72+
source: ${{ github.workspace }}/kmp-socketio/build/reports/kover/coverage.json
73+
output: dist/badges.svg
74+
jsonPath: totals.instructions.pct
75+
- name: Deploy
76+
uses: peaceiris/actions-gh-pages@v4
77+
if: ${{ github.ref == 'refs/heads/main' }}
78+
with:
79+
commit_message: ${{ github.event.head_commit.message }}
80+
github_token: ${{ secrets.GITHUB_TOKEN }}
81+
publish_dir: ./dist

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ KMP (pure Kotlin) implementation of SocketIO client.
1212
| `Browser` (Chrome) | 🚀 |
1313
| `Android` | 🚀 |
1414
| `iOS` | 🚀 |
15-
| `MacOS` | 🚀 |
15+
| `macOS` | 🚀 |
1616
| `Windows X64` | 🚀 |
1717
| `Linux X64` | 🔮 |
1818

gradle/libs.versions.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,4 @@ kmp = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" }
4848
versions = "com.github.ben-manes.versions:0.51.0"
4949
versionUpdate = "nl.littlerobots.version-catalog-update:0.8.5"
5050
vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.30.0"
51+
kover = "org.jetbrains.kotlinx.kover:0.9.1"

kmp-socketio/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import com.vanniktech.maven.publish.SonatypeHost
33
plugins {
44
alias(libs.plugins.kmp)
55
alias(libs.plugins.vanniktech.mavenPublish)
6+
alias(libs.plugins.kover)
67
}
78

89
version = Consts.releaseVersion

settings.gradle.kts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ pluginManagement {
66
}
77
}
88
plugins {
9-
id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0"
9+
id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0"
1010
}
1111

1212
dependencyResolutionManagement {

0 commit comments

Comments
 (0)