From 7966ef729f80afa38e3f5b87297ce3c89de6ac8d Mon Sep 17 00:00:00 2001 From: gabfssilva Date: Wed, 28 Feb 2024 12:30:28 -0300 Subject: [PATCH] Skip tests inside build --- .github/workflows/build.yml | 15 ++++--- .github/workflows/main.yml | 3 +- .github/workflows/release.yml | 2 + .github/workflows/test-module.yml | 45 ------------------- build.gradle.kts | 29 ++++++++++-- buildSrc/src/main/kotlin/Ext.kt | 3 ++ connectors/format/csv/build.gradle.kts | 13 +++++- .../positional-flat-line/build.gradle.kts | 13 +++++- core/build.gradle.kts | 13 +++++- gradle.properties | 1 - libs.versions.toml | 3 ++ 11 files changed, 76 insertions(+), 64 deletions(-) delete mode 100644 .github/workflows/test-module.yml diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 1e7aa049..868bd545 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,4 +1,4 @@ -name: Build and assembly +name: Build monorepo on: workflow_call: @@ -9,15 +9,18 @@ permissions: jobs: build: - runs-on: ubuntu-latest + runs-on: macos-latest steps: - uses: actions/checkout@v4 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' - - name: Build - uses: gradle/gradle-build-action@v3 - with: - arguments: build -x test + + - name: Set up Gradle + uses: gradle/actions/setup-gradle@v3 + + - name: Build monorepo + run: ./gradlew build -PskipTests=true diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index bb71c458..d75ef10e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -27,12 +27,11 @@ jobs: name: Run all River's modules tests uses: ./.github/workflows/test.yml build: - needs: test name: Build all monorepo uses: ./.github/workflows/build.yml release: name: Release all River's modules to Maven Central - needs: build + needs: [test, build] uses: ./.github/workflows/release.yml secrets: SIGNING_KEY_ID: ${{ secrets.SIGNING_KEY_ID }} diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 77a6a7cc..7e8e1638 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -23,11 +23,13 @@ jobs: runs-on: macos-latest steps: - uses: actions/checkout@v4 + - name: Set up JDK 17 uses: actions/setup-java@v4 with: java-version: '17' distribution: 'temurin' + - name: Assembly uses: gradle/gradle-build-action@v3 with: diff --git a/.github/workflows/test-module.yml b/.github/workflows/test-module.yml deleted file mode 100644 index 871d3995..00000000 --- a/.github/workflows/test-module.yml +++ /dev/null @@ -1,45 +0,0 @@ -name: Run lint and tests - -on: - workflow_call: - inputs: - module: - required: true - type: string - path: - required: true - type: string - containers: - required: false - type: string - runner: - required: false - type: string - default: ubuntu-latest - -jobs: - test: - name: ${{ inputs.module }} module - runs-on: ${{ inputs.runner }} - steps: - - uses: actions/checkout@v4 - - name: Check - run: ls -lh - - name: Setup Docker [macOS only] - if: ${{ inputs.containers && inputs.runner == 'macos-latest' }} - uses: douglascamata/setup-docker-macos-action@v1-alpha - - name: Run docker-compose [if needed] - if: ${{ inputs.containers && inputs.runner == 'macos-latest' }} - run: docker-compose up ${{ inputs.containers }} -d - - name: Run docker-compose [if needed] - if: ${{ inputs.containers && inputs.runner != 'macos-latest' }} - run: docker compose up ${{ inputs.containers }} -d - - name: Set up JDK 17 - uses: actions/setup-java@v4 - with: - java-version: '17' - distribution: 'temurin' - - name: Run tests - uses: gradle/gradle-build-action@v3 - with: - arguments: ${{ inputs.path }}:allTests diff --git a/build.gradle.kts b/build.gradle.kts index d125828e..24b11e21 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -1,7 +1,10 @@ @file:OptIn(ExperimentalKotlinGradlePluginApi::class) +import com.adarshr.gradle.testlogger.TestLoggerExtension +import com.adarshr.gradle.testlogger.theme.ThemeType import org.gradle.api.tasks.testing.logging.TestExceptionFormat import org.jetbrains.dokka.gradle.AbstractDokkaTask +import org.jetbrains.kotlin.cli.common.toBooleanLenient import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi import org.jetbrains.kotlin.gradle.dsl.JvmTarget @@ -13,6 +16,7 @@ plugins { alias(libs.plugins.dokka) alias(libs.plugins.nexus.publish) apply false alias(libs.plugins.os.detector) + alias(libs.plugins.test.logger) apply false `maven-publish` signing @@ -48,6 +52,7 @@ subprojects { apply(plugin = "org.jetbrains.dokka") apply(plugin = "signing") apply(plugin = "com.google.osdetector") + apply(plugin = "com.adarshr.test-logger") version = rootProject.libs.versions.river.get() group = "com.river-kt" @@ -57,13 +62,29 @@ subprojects { google() } + configure { + theme = ThemeType.MOCHA + showExceptions = true + showStackTraces = true + showFullStackTraces = false + showCauses = true + slowThreshold = 10000 + showSummary = true + showSimpleNames = false + showPassed = true + showSkipped = true + showFailed = true + showStandardStreams = false + showPassedStandardStreams = true + showSkippedStandardStreams = true + showFailedStandardStreams = true + logLevel = LogLevel.LIFECYCLE + } + tasks.withType().configureEach { useJUnitPlatform() - testLogging { - showStandardStreams = true - exceptionFormat = TestExceptionFormat.FULL - } + onlyIf { !skipTests() } } tasks.withType(org.jetbrains.kotlin.gradle.tasks.KotlinCompile::class) { diff --git a/buildSrc/src/main/kotlin/Ext.kt b/buildSrc/src/main/kotlin/Ext.kt index 061f6957..c79b78de 100644 --- a/buildSrc/src/main/kotlin/Ext.kt +++ b/buildSrc/src/main/kotlin/Ext.kt @@ -14,3 +14,6 @@ inline fun Project.androidApp(crossinline configure: AppExtension.() -> Unit) { extensions.configure { configure() } } } + +fun Project.skipTests(): Boolean = + "${properties["skipTests"] ?: "false"}".toBooleanStrict() diff --git a/connectors/format/csv/build.gradle.kts b/connectors/format/csv/build.gradle.kts index e533c84f..b51b0f1f 100644 --- a/connectors/format/csv/build.gradle.kts +++ b/connectors/format/csv/build.gradle.kts @@ -9,8 +9,17 @@ kotlin { mingwX64() js(IR) { - browser() - nodejs() + browser { + testTask { + onlyIf { !skipTests() } + } + } + + nodejs { + testTask { + onlyIf { !skipTests() } + } + } } androidTarget { diff --git a/connectors/format/positional-flat-line/build.gradle.kts b/connectors/format/positional-flat-line/build.gradle.kts index 8c1cbce6..6c9088dd 100644 --- a/connectors/format/positional-flat-line/build.gradle.kts +++ b/connectors/format/positional-flat-line/build.gradle.kts @@ -9,8 +9,17 @@ kotlin { mingwX64() js(IR) { - browser() - nodejs() + browser { + testTask { + onlyIf { !skipTests() } + } + } + + nodejs { + testTask { + onlyIf { !skipTests() } + } + } } androidTarget { diff --git a/core/build.gradle.kts b/core/build.gradle.kts index 8c1cbce6..009fa280 100644 --- a/core/build.gradle.kts +++ b/core/build.gradle.kts @@ -9,8 +9,17 @@ kotlin { mingwX64() js(IR) { - browser() - nodejs() + browser { + testTask { + onlyIf { !skipTests() } + } + } + + nodejs { + testTask { + onlyIf { !skipTests() } + } + } } androidTarget { diff --git a/gradle.properties b/gradle.properties index 58d23c99..b3b84626 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx4096M kotlin.mpp.androidSourceSetLayoutVersion=2 -org.gradle.caching=true org.gradle.configureondemand=true diff --git a/libs.versions.toml b/libs.versions.toml index f4d96451..6a5ef8c8 100644 --- a/libs.versions.toml +++ b/libs.versions.toml @@ -39,6 +39,7 @@ os-detector = "1.7.3" android-compile-sdk = "30" desugar-jdk-libs = "2.0.3" mockk = "1.13.9" +test-logger = "4.0.0" [plugins] kotlin-jvm = { id = "org.jetbrains.kotlin.jvm", version.ref = "kotlin" } @@ -56,6 +57,8 @@ nexus-publish = { id = "io.github.gradle-nexus.publish-plugin", version = "1.3.0 os-detector = { id = "com.google.osdetector", version.ref = "os-detector" } +test-logger = { id = "com.adarshr.test-logger", version.ref = "test-logger" } + [libraries] # kotlin coroutines = { module = "org.jetbrains.kotlinx:kotlinx-coroutines-core", version.ref = "coroutines" }