@@ -5,42 +5,77 @@ name: kmp-socketio build and test.
55
66on :
77 push :
8- branches : [ "main" ]
8+ branches : ["main"]
99 pull_request :
10- branches : [ "main" ]
10+ branches : ["main"]
1111 workflow_call :
1212
1313permissions :
1414 contents : read
1515
1616jobs :
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+ 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+ 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
0 commit comments