diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..5a130d3 --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,58 @@ +name: CI Pipeline + +on: + push: + branches: + - main + pull_request: + types: [ opened, synchronize ] + +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + pipeline: + name: Release to maven central + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Set up JDK + uses: actions/setup-java@v4 + with: + distribution: 'temurin' + java-version: 11 + + - name: Gradle setup + uses: gradle/actions/setup-gradle@v3 + + - name: Validate gradle wrapper + uses: gradle/wrapper-validation-action@v2 + + - name: Run unit tests + run: | + ./gradlew test --parallel + + - name: Publish unit test report + uses: EnricoMi/publish-unit-test-result-action/composite@v2.7 + if: always() + with: + files: | + **/build/test-results/**/*.xml + + - name: Run coverage + run: ./gradlew koverXmlReport + + - name: Upload coverage reports to Codecov + uses: codecov/codecov-action@v4.0.1 + with: + token: ${{ secrets.CODECOV_TOKEN }} + slug: yamilmedina/natural-kron + + - name: Cleanup gradle cache + # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions. + # Restoring these files from a GitHub Actions cache might cause problems for future builds. + run: | + rm -f ~/.gradle/caches/modules-2/modules-2.lock + rm -f ~/.gradle/caches/modules-2/gc.properties diff --git a/build.gradle.kts b/build.gradle.kts index 1d5bf6c..cf35f96 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget plugins { alias(libs.plugins.kotlin.jvm) alias(libs.plugins.maven.publish) + alias(libs.plugins.kover) } group = "io.github.yamilmedina" diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 4073993..166732e 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -1,10 +1,12 @@ [versions] kotlin = "1.9.23" maven-publish = "0.28.0" +kover = "0.7.4" [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } maven-publish = { id = "com.vanniktech.maven.publish", version.ref = "maven-publish" } +kover = { id = "org.jetbrains.kotlinx.kover", version.ref = "kover" } [libraries] kotlin-test = { group = "org.jetbrains.kotlin", name = "kotlin-test", version.ref = "kotlin" }