Skip to content
This repository has been archived by the owner on Oct 28, 2021. It is now read-only.

Commit

Permalink
Add Kotlin test (#91)
Browse files Browse the repository at this point in the history
* Add Kotlin test

* Use submodule's path

* Upgrade to upload-artifact v2

* Continue on error

* Port test code from Java to Kotlin

* Upload reports if test fails

* Upload reports if test fails

* Add matrix for modules

* Split a workflow job to two

* Wait the job

* Clean the workflow
  • Loading branch information
nakamura-to authored Sep 13, 2020
1 parent bfe885b commit b095941
Show file tree
Hide file tree
Showing 265 changed files with 4,544 additions and 112 deletions.
133 changes: 91 additions & 42 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,85 @@ on:

jobs:

build:
setup:
if: contains(github.event.head_commit.message, '[skip ci]') == false
name: JDK ${{ matrix.java }}
name: Setup
runs-on: ubuntu-latest

steps:
- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: 8

- name: Cache Gradle wrapper
uses: actions/cache@v2
with:
path: ~/.gradle/wrapper
key: ${{ runner.os }}-gradle-wrapper-${{ hashFiles('**/gradle-wrapper.properties') }}

- name: Cache Gradle packages
uses: actions/cache@v2
with:
path: |
~/.gradle/caches
~/.m2/repository
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle.kts', '**/gradle.properties') }}

- name: Checkout (doma-it)
uses: actions/checkout@v2
with:
path: doma-it

- name: Grant execute permission for gradlew (doma-it)
working-directory: ./doma-it
run: chmod +x gradlew

- name: Check code format (doma-it)
working-directory: ./doma-it
run: ./gradlew spotlessCheck

- name: Checkout (doma)
uses: actions/checkout@v2
with:
repository: domaframework/doma
path: doma

- name: Grant execute permission for gradlew (doma)
working-directory: ./doma
run: chmod +x gradlew

- name: Build and Install (doma)
working-directory: ./doma
run: ./gradlew assemble publishToMavenLocal

- name: Tar Maven Repository
shell: bash
run: tar -czf maven-repository.tgz -C ~ .m2/repository

- name: Persist Maven Repository
uses: actions/upload-artifact@v1
with:
name: maven-repository
path: maven-repository.tgz

- name: Upload reports
if: failure()
uses: actions/upload-artifact@v2
with:
name: reports
path: ./**/build/reports

integration-test:
if: contains(github.event.head_commit.message, '[skip ci]') == false
name: JDK ${{ matrix.java }} and ${{ matrix.module }}
runs-on: ubuntu-latest
needs: setup

strategy:
matrix:
java: [ 8, 11, 14, 15-ea ]
module: [ java, kotlin ]

services:
postgres:
Expand Down Expand Up @@ -53,21 +124,15 @@ jobs:
docker exec mssqlcontainer /opt/mssql-tools/bin/sqlcmd \
-S 127.0.0.1 -U sa -P 'P@ssw0rd' -Q 'CREATE DATABASE doma_it'
- name: Checkout (doma)
uses: actions/checkout@v2
with:
repository: domaframework/doma
path: doma
ref: ${{ github.event.inputs.ref }}

- name: Set up JDK (doma)
uses: actions/setup-java@v1
- name: Download Maven Repository
uses: actions/download-artifact@v1
with:
java-version: 8
name: maven-repository
path: .

- name: Grant execute permission for gradlew (doma)
working-directory: ./doma
run: chmod +x gradlew
- name: Extract Maven Repository
shell: bash
run: tar -xzf maven-repository.tgz -C ~

- name: Cache Gradle wrapper
uses: actions/cache@v2
Expand All @@ -83,69 +148,53 @@ jobs:
~/.m2/repository
key: ${{ runner.os }}-gradle-caches-${{ hashFiles('**/*.gradle.kts', '**/gradle.properties') }}

- name: Build and Install (doma)
working-directory: ./doma
run: ./gradlew assemble publishToMavenLocal

- name: Checkout
uses: actions/checkout@v2
with:
path: doma-it

- name: Grant execute permission for gradlew
working-directory: ./doma-it
run: chmod +x gradlew

- name: Check code format
working-directory: ./doma-it
run: ./gradlew spotlessCheck

- name: Set up JDK
uses: actions/setup-java@v1
with:
java-version: ${{ matrix.java }}

- name: Grant execute permission for gradlew
run: chmod +x gradlew

- name: Build
working-directory: ./doma-it
run: |
./gradlew -v
./gradlew assemble
./gradlew :${{ matrix.module }}:assemble
- name: Test with h2
working-directory: ./doma-it
run: ./gradlew check -x spotlessCheck
run: ./gradlew :${{ matrix.module }}:check -x spotlessCheck
env:
ORG_GRADLE_PROJECT_jdbcUrl: ''
ORG_GRADLE_PROJECT_jdbcUser: ''
ORG_GRADLE_PROJECT_jdbcPassword: ''

- name: Test with postgres
working-directory: ./doma-it
run: ./gradlew check -x spotlessCheck
run: ./gradlew :${{ matrix.module }}:check -x spotlessCheck
env:
ORG_GRADLE_PROJECT_jdbcUrl: jdbc:postgresql://127.0.0.1/doma_it
ORG_GRADLE_PROJECT_jdbcUser: postgres
ORG_GRADLE_PROJECT_jdbcPassword: postgres

- name: Test with mysql
working-directory: ./doma-it
run: ./gradlew check -x spotlessCheck
run: ./gradlew :${{ matrix.module }}:check -x spotlessCheck
env:
ORG_GRADLE_PROJECT_jdbcUrl: jdbc:mysql://127.0.0.1/doma_it
ORG_GRADLE_PROJECT_jdbcUser: root
ORG_GRADLE_PROJECT_jdbcPassword: root

- name: Test with mssql
working-directory: ./doma-it
run: ./gradlew check -x spotlessCheck
run: ./gradlew :${{ matrix.module }}:check -x spotlessCheck
env:
ORG_GRADLE_PROJECT_jdbcUrl: jdbc:sqlserver://127.0.0.1;database=doma_it
ORG_GRADLE_PROJECT_jdbcUser: sa
ORG_GRADLE_PROJECT_jdbcPassword: P@ssw0rd

- name: Upload reports
if: failure()
uses: actions/upload-artifact@v1
uses: actions/upload-artifact@v2
with:
name: jdk${{ matrix.java }}
path: ./doma-it/build/reports
name: jdk${{ matrix.java }}-${{ matrix.module }}
path: ./**/build/reports
124 changes: 55 additions & 69 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,83 +1,69 @@
plugins {
id("java")
id("com.diffplug.eclipse.apt") version "3.24.0"
id("com.diffplug.spotless") version "5.5.1"
id("org.seasar.doma.compile") version "1.1.0"
base
id("com.diffplug.eclipse.apt") version "3.24.0" apply false
id("com.diffplug.spotless") version "5.5.0" apply false
id("org.seasar.doma.compile") version "1.1.0" apply false
kotlin("jvm") version "1.4.10" apply false
kotlin("kapt") version "1.4.10" apply false
}

val domaVersion = project.findProperty("domaVersion") ?: "2.+"
subprojects {
apply(plugin = "java")
apply(plugin = "com.diffplug.eclipse.apt")
apply(plugin = "com.diffplug.spotless")
apply(plugin ="org.seasar.doma.compile")

spotless {
java {
googleJavaFormat("1.7")
}
}

tasks {
val encoding = "UTF-8"

compileJava {
options.encoding = encoding
options.compilerArgs = listOf("-Adoma.domain.converters=org.seasar.doma.it.domain.DomainConverterProvider")
}

compileTestJava {
options.encoding = encoding
options.compilerArgs.addAll(listOf("-proc:none"))
}

jar {
manifest {
attributes(mapOf("Implementation-Title" to project.name, "Implementation-Version" to archiveVersion))
tasks {
named<Test>("test") {
val jdbcUrl: Any by project
val jdbcUser: Any by project
val jdbcPassword: Any by project
systemProperty("url", jdbcUrl)
systemProperty("user", jdbcUser)
systemProperty("password", jdbcPassword)
maxHeapSize = "1g"
useJUnitPlatform()
}

named("build") {
dependsOn("spotlessApply")
}
}

test {
val jdbcUrl: Any by project
val jdbcUser: Any by project
val jdbcPassword: Any by project
systemProperty("url", jdbcUrl)
systemProperty("user", jdbcUser)
systemProperty("password", jdbcPassword)
useJUnitPlatform()
repositories {
mavenCentral()
mavenLocal()
}
}

repositories {
mavenCentral()
mavenLocal()
}

dependencies {
annotationProcessor("org.seasar.doma:doma-processor:${domaVersion}")
implementation("org.seasar.doma:doma-core:${domaVersion}")
testImplementation("org.junit.jupiter:junit-jupiter-api:5.6.2")
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.6.2")
testRuntimeOnly("com.h2database:h2:1.4.200")
testRuntimeOnly("mysql:mysql-connector-java:8.0.21")
testRuntimeOnly("org.postgresql:postgresql:42.2.16")
testRuntimeOnly("com.microsoft.sqlserver:mssql-jdbc:8.4.1.jre8")
}

eclipse {
classpath {
file {
whenMerged {
val classpath = this as org.gradle.plugins.ide.eclipse.model.Classpath
classpath.entries.removeAll {
when (it) {
is org.gradle.plugins.ide.eclipse.model.Output -> it.path == ".apt_generated"
else -> false
dependencies {
"testImplementation"("org.junit.jupiter:junit-jupiter-api:5.6.2")
"testRuntimeOnly"("org.junit.jupiter:junit-jupiter-engine:5.6.2")
"testRuntimeOnly"("com.h2database:h2:1.4.200")
"testRuntimeOnly"("mysql:mysql-connector-java:8.0.21")
"testRuntimeOnly"("org.postgresql:postgresql:42.2.16")
"testRuntimeOnly"("com.microsoft.sqlserver:mssql-jdbc:8.4.1.jre8")
}

configure<org.gradle.plugins.ide.eclipse.model.EclipseModel> {
classpath {
file {
whenMerged {
val classpath = this as org.gradle.plugins.ide.eclipse.model.Classpath
classpath.entries.removeAll {
when (it) {
is org.gradle.plugins.ide.eclipse.model.Output -> it.path == ".apt_generated"
else -> false
}
}
}
}
withXml {
val node = asNode()
node.appendNode("classpathentry", mapOf("kind" to "src", "output" to "bin/main", "path" to ".apt_generated"))
withXml {
val node = asNode()
node.appendNode("classpathentry", mapOf("kind" to "src", "output" to "bin/main", "path" to ".apt_generated"))
}
}
}
jdt {
javaRuntimeName = "JavaSE-1.8"
}
}
jdt {
javaRuntimeName = "JavaSE-1.8"
}
}
}
12 changes: 12 additions & 0 deletions java/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/bin
/target
/build/
/.apt_generated/
/.gradle/
/.settings/
/.project
/.factorypath
/.classpath
.idea
out
.sdkmanrc
30 changes: 30 additions & 0 deletions java/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
plugins {
java
}

val domaVersion = project.findProperty("domaVersion") ?: "2.+"

tasks {
val encoding = "UTF-8"

compileJava {
options.encoding = encoding
options.compilerArgs = listOf("-Adoma.domain.converters=org.seasar.doma.it.domain.DomainConverterProvider")
}

compileTestJava {
options.encoding = encoding
options.compilerArgs.addAll(listOf("-proc:none"))
}
}

spotless {
java {
googleJavaFormat("1.7")
}
}

dependencies {
annotationProcessor("org.seasar.doma:doma-processor:${domaVersion}")
implementation("org.seasar.doma:doma-core:${domaVersion}")
}
File renamed without changes.
12 changes: 12 additions & 0 deletions kotlin/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/bin
/target
/build/
/.apt_generated/
/.gradle/
/.settings/
/.project
/.factorypath
/.classpath
.idea
out
.sdkmanrc
Loading

0 comments on commit b095941

Please sign in to comment.