diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index 2e0cec0..b77e875 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -43,72 +43,12 @@ jobs: - name: Build sqllin-driver run: ./gradlew :sqllin-driver:assemble -PonCICD - - name: Run sqllin-driver macOS X64 Tests - run: ./test_driver_macos.sh - - - name: Run sqllin-driver JVM Unit Tests on macOS X64 - run: ./test_driver_jvm.sh - - name: Build sqllin-dsl run: ./gradlew :sqllin-dsl:assemble -PonCICD - - name: Run sqllin-dsl macOS X64 Tests - run: ./test_dsl_macos.sh - - - name: Run sqllin-dsl JVM Unit Tests on macOS X64 - run: ./test_dsl_jvm.sh - - name: Gradle Cache uses: gradle/gradle-build-action@v2 - - name: AVD Cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-34 - - - name: Create AVD and Generate Snapshot for Caching - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 34 - target: google_apis - arch: x86_64 - profile: pixel_6 - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false - script: echo "Generated AVD snapshot for caching." - - - name: Run Android 14 Instrumented Tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 34 - target: google_apis - arch: x86_64 - profile: pixel_6 - force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: true - script: ./test_android.sh - - - name: Upload sqllin-driver Reports - uses: actions/upload-artifact@v2 - with: - name: Test-Reports - path: sqllin-driver/build/reports - if: failure() - - - name: Upload sqllin-dsl Reports - uses: actions/upload-artifact@v2 - with: - name: Test-Reports - path: sqllin-dsl/build/reports - if: failure() - - name: Publish to MavenCentral run: ./publish_apple_android_jvm.sh @@ -143,35 +83,9 @@ jobs: - name: Build sqllin-driver run: ./gradlew :sqllin-driver:mingwX64MainKlibrary - - name: Run sqllin-driver MinGW X64 Tests - run: ./gradlew :sqllin-driver:cleanMingwX64Test && ./gradlew :sqllin-driver:mingwX64Test --stacktrace - - - name: Run sqllin-driver JVM Unit Tests on MinGW X64 - run: ./gradlew :sqllin-driver:cleanJvmTest && ./gradlew :sqllin-driver:jvmTest --stacktrace - - name: Build sqllin-dsl run: ./gradlew :sqllin-dsl:mingwX64MainKlibrary - - name: Run sqllin-dsl MinGW X64 Tests - run: ./gradlew :sqllin-dsl:cleanMingwX64Test && ./gradlew :sqllin-dsl:mingwX64Test --stacktrace - - - name: Run sqllin-dsl JVM Unit Tests on MinGW X64 - run: ./gradlew :sqllin-dsl:cleanJvmTest && ./gradlew :sqllin-dsl:jvmTest --stacktrace - - - name: Upload sqllin-driver Reports - uses: actions/upload-artifact@v2 - with: - name: Test-Reports - path: sqllin-driver/build/reports - if: failure() - - - name: Upload sqllin-dsl Reports - uses: actions/upload-artifact@v2 - with: - name: Test-Reports - path: sqllin-dsl/build/reports - if: failure() - - name: Publish to MavenCentral run: ./gradlew :sqllin-driver:publishMingwX64PublicationToMavenRepository && ./gradlew :sqllin-dsl:publishMingwX64PublicationToMavenRepository @@ -206,74 +120,14 @@ jobs: - name: Build sqllin-driver run: ./gradlew :sqllin-driver:assemble -PonCICD - - name: Run sqllin-driver Linux X64 Tests - run: ./test_driver_linux.sh - - - name: Run sqllin-driver JVM Unit Tests on Linux X64 - run: ./test_driver_jvm.sh - - name: Build sqllin-processor run: ./gradlew :sqllin-processor:assemble - name: Build sqllin-dsl run: ./gradlew :sqllin-dsl:assemble -PonCICD - - name: Run sqllin-dsl Linux X64 Tests - run: ./test_dsl_linux.sh - - - name: Run sqllin-dsl JVM Unit Tests on Linux X64 - run: ./test_dsl_jvm.sh - - name: Gradle Cache uses: gradle/gradle-build-action@v2 - - name: AVD Cache - uses: actions/cache@v3 - id: avd-cache - with: - path: | - ~/.android/avd/* - ~/.android/adb* - key: avd-26 - - - name: Create AVD and Generate Snapshot for Caching - if: steps.avd-cache.outputs.cache-hit != 'true' - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 26 - target: default - arch: x86_64 - profile: pixel_2 - force-avd-creation: false - emulator-options: -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: false - script: echo "Generated AVD snapshot for caching." - - - name: Run Android 8 Instrumented Tests - uses: reactivecircus/android-emulator-runner@v2 - with: - api-level: 26 - target: default - arch: x86_64 - profile: pixel_2 - force-avd-creation: false - emulator-options: -no-snapshot-save -no-window -gpu swiftshader_indirect -noaudio -no-boot-anim -camera-back none - disable-animations: true - script: ./test_android.sh - - - name: Upload sqllin-driver Reports - uses: actions/upload-artifact@v2 - with: - name: Test-Reports - path: sqllin-driver/build/reports - if: failure() - - - name: Upload sqllin-dsl Reports - uses: actions/upload-artifact@v2 - with: - name: Test-Reports - path: sqllin-dsl/build/reports - if: failure() - - name: Publish to MavenCentral run: ./publish_linux_processor.sh diff --git a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt index 9b42576..acb7ff7 100644 --- a/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt +++ b/sqllin-dsl/src/commonTest/kotlin/com/ctrip/sqllin/dsl/CommonBasicTest.kt @@ -24,6 +24,7 @@ import com.ctrip.sqllin.dsl.sql.clause.OrderByWay.ASC import com.ctrip.sqllin.dsl.sql.clause.OrderByWay.DESC import com.ctrip.sqllin.dsl.sql.statement.SelectStatement import kotlinx.coroutines.Dispatchers +import kotlinx.coroutines.delay import kotlinx.coroutines.launch import kotlinx.coroutines.runBlocking import kotlin.test.assertEquals @@ -374,36 +375,32 @@ class CommonBasicTest(private val path: DatabasePath) { val book1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = 16.96) val book2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = 19.95) launch { - var statement: SelectStatement? = null + lateinit var statement: SelectStatement database suspendedScope { statement = BookTable { table -> table INSERT listOf(book1, book2) table SELECT X } } - - launch { - val book1NewPrice = 18.96 - val book2NewPrice = 21.95 - val newBook1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = book1NewPrice) - val newBook2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = book2NewPrice) - var newResult: SelectStatement? = null - database suspendedScope { - newResult = transaction { - BookTable { table -> - table UPDATE SET { price = book1NewPrice } WHERE (name EQ book1.name AND (price EQ book1.price)) - table UPDATE SET { price = book2NewPrice } WHERE (name EQ book2.name AND (price EQ book2.price)) - table SELECT X - } + assertEquals(true, statement.getResults().any { it == book1 }) + assertEquals(true, statement.getResults().any { it == book2 }) + } + launch { + val book1NewPrice = 18.96 + val book2NewPrice = 21.95 + val newBook1 = Book(name = "The Da Vinci Code", author = "Dan Brown", pages = 454, price = book1NewPrice) + val newBook2 = Book(name = "The Lost Symbol", author = "Dan Brown", pages = 510, price = book2NewPrice) + lateinit var statement: SelectStatement + database suspendedScope { + statement = transaction { + BookTable { table -> + table INSERT listOf(newBook1, newBook2) + table SELECT X } } - - assertEquals(true, newResult!!.getResults().any { it == newBook1 }) - assertEquals(true, newResult!!.getResults().any { it == newBook2 }) } - - assertEquals(true, statement!!.getResults().any { it == book1 }) - assertEquals(true, statement!!.getResults().any { it == book2 }) + assertEquals(true, statement.getResults().any { it == newBook1 }) + assertEquals(true, statement.getResults().any { it == newBook2 }) } } } @@ -441,12 +438,12 @@ class CommonBasicTest(private val path: DatabasePath) { lateinit var selectStatement: SelectStatement // INSERT & SELECT database { - NullTesterTable { table -> + selectStatement = NullTesterTable { table -> table INSERT listOf( NullTester(null, null, null), NullTester(8, "888", 8.8), ) - selectStatement = table SELECT X + table SELECT X } } @@ -467,9 +464,9 @@ class CommonBasicTest(private val path: DatabasePath) { // UPDATE & SELECT database { - NullTesterTable { table -> + selectStatement = NullTesterTable { table -> table UPDATE SET { paramString = null } WHERE (paramDouble EQ 8.8) - selectStatement = table SELECT WHERE (paramInt NEQ null) + table SELECT WHERE (paramInt NEQ null) } } val result1 = selectStatement.getResults().first() @@ -480,9 +477,9 @@ class CommonBasicTest(private val path: DatabasePath) { // DELETE & SELECT database { - NullTesterTable { table -> + selectStatement = NullTesterTable { table -> table DELETE WHERE (paramInt EQ null OR (paramDouble EQ null)) - selectStatement = table SELECT X + table SELECT X } } val result2 = selectStatement.getResults().first()