diff --git a/.github/workflows/test_and_run_demo.yaml b/.github/workflows/test_and_run_demo.yaml index 32a08ab..1ad27c0 100644 --- a/.github/workflows/test_and_run_demo.yaml +++ b/.github/workflows/test_and_run_demo.yaml @@ -5,9 +5,9 @@ name: kmp-socketio build and test. on: push: - branches: [ "main" ] + branches: ["main"] pull_request: - branches: [ "main" ] + branches: ["main"] workflow_call: permissions: @@ -15,32 +15,67 @@ permissions: jobs: build: - strategy: - fail-fast: false - matrix: - include: - - cmd: "${GITHUB_WORKSPACE}/gradlew :kmp-socketio:jvmTest --info" - os: ubuntu-latest - dep: "cd ${GITHUB_WORKSPACE}/kmp-socketio/src/jvmTest/resources/ && npm install" - runs-on: ${{ matrix.os }} - + runs-on: ubuntu-latest + permissions: + pull-requests: write + contents: write + id-token: write steps: - - uses: actions/checkout@v4 - with: - submodules: 'recursive' - - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - cache: 'gradle' - - uses: gradle/actions/setup-gradle@v3 - - uses: actions/setup-node@v4 - with: - node-version: 14 - - if: ${{ matrix.dep }} - run: ${{ matrix.dep }} - - if: ${{ matrix.os == 'windows-latest' }} - shell: cmd - run: ${{ matrix.cmd }} - - if: ${{ matrix.os != 'windows-latest' }} - run: ${{ matrix.cmd }} + - uses: actions/checkout@v4 + with: + submodules: "recursive" + - uses: actions/setup-java@v4 + with: + java-version: "17" + distribution: "temurin" + cache: "gradle" + - uses: gradle/actions/setup-gradle@v3 + - uses: actions/setup-node@v4 + with: + node-version: 14 + - name: Setup Test Env + run: | + cd kmp-socketio/src/jvmTest/resources/ + npm install + - name: Run Jvm tests + run: | + ./gradlew :kmp-socketio:jvmTest --info + - name: Gen coverage + run: | + ./gradlew koverXmlReport + - name: Add coverage to PR + id: jacoco + uses: madrapps/jacoco-report@v1.7.1 + with: + paths: ${{ github.workspace }}/kmp-socketio/build/reports/kover/report.xml + token: ${{ secrets.GITHUB_TOKEN }} + min-coverage-overall: 80 + min-coverage-changed-files: 80 + pass-emoji: ":white_check_mark:" + fail-emoji: ":negative_squared_cross_mark:" + - name: Overall coverage check + if: ${{ steps.jacoco.outputs.coverage-overall < 80 || steps.jacoco.outputs.coverage-changed-files < 80 }} + uses: actions/github-script@v7 + with: + script: | + core.setFailed("Coverage check failed! overall ${{ steps.jacoco.outputs.coverage-overall }}, diff ${{ steps.jacoco.outputs.coverage-changed-files }}.") + - name: Create coverage summary json + uses: jsdaniell/create-json@v1.2.3 + with: + dir: kmp-socketio/build/reports/kover/ + name: "coverage.json" + json: '{"total":{"instructions":{"pct":${{ steps.jacoco.outputs.coverage-overall }} }}}' + - name: Create Coverage Badges + uses: jaywcjlove/coverage-badges-cli@main + with: + style: flat + source: ${{ github.workspace }}/kmp-socketio/build/reports/kover/coverage.json + output: dist/badges.svg + jsonPath: totals.instructions.pct + - name: Deploy + uses: peaceiris/actions-gh-pages@v4 + if: ${{ github.ref == 'refs/heads/main' }} + with: + commit_message: ${{ github.event.head_commit.message }} + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./dist diff --git a/README.md b/README.md index a68e542..51daf15 100644 --- a/README.md +++ b/README.md @@ -12,7 +12,7 @@ KMP (pure Kotlin) implementation of SocketIO client. | `Browser` (Chrome) | 🚀 | | `Android` | 🚀 | | `iOS` | 🚀 | -| `MacOS` | 🚀 | +| `macOS` | 🚀 | | `Windows X64` | 🚀 | | `Linux X64` | 🔮 | diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 506110c..63398db 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -48,3 +48,4 @@ kmp = { id = "org.jetbrains.kotlin.multiplatform", version.ref = "kotlin" } versions = "com.github.ben-manes.versions:0.51.0" versionUpdate = "nl.littlerobots.version-catalog-update:0.8.5" vanniktech-mavenPublish = "com.vanniktech.maven.publish:0.30.0" +kover = "org.jetbrains.kotlinx.kover:0.9.1" diff --git a/kmp-socketio/build.gradle.kts b/kmp-socketio/build.gradle.kts index d28bf9b..d5fa511 100644 --- a/kmp-socketio/build.gradle.kts +++ b/kmp-socketio/build.gradle.kts @@ -3,6 +3,7 @@ import com.vanniktech.maven.publish.SonatypeHost plugins { alias(libs.plugins.kmp) alias(libs.plugins.vanniktech.mavenPublish) + alias(libs.plugins.kover) } version = Consts.releaseVersion diff --git a/settings.gradle.kts b/settings.gradle.kts index 17c9a8c..fa19d77 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -6,7 +6,7 @@ pluginManagement { } } plugins { - id("org.gradle.toolchains.foojay-resolver-convention") version "0.8.0" + id("org.gradle.toolchains.foojay-resolver-convention") version "0.9.0" } dependencyResolutionManagement {