diff --git a/.github/workflows/ci-kotlin.yml b/.github/workflows/ci-kotlin.yml new file mode 100644 index 0000000000..f864c2fc7e --- /dev/null +++ b/.github/workflows/ci-kotlin.yml @@ -0,0 +1,36 @@ +name: sqlc kotlin test suite +on: [push, pull_request] +jobs: + + build: + name: Build And Test + runs-on: ubuntu-latest + + services: + postgres: + image: postgres:11 + env: + POSTGRES_USER: postgres + POSTGRES_PASSWORD: postgres + POSTGRES_DB: postgres + ports: + - 5432:5432 + # needed because the postgres container does not provide a healthcheck + options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 + + steps: + - uses: actions/checkout@master + - uses: actions/setup-java@v1 + with: + java-version: 11 + - uses: eskatos/gradle-command-action@v1 + env: + PG_USER: postgres + PG_HOST: localhost + PG_DATABASE: postgres + PG_PASSWORD: postgres + PG_PORT: ${{ job.services.postgres.ports['5432'] }} + with: + build-root-directory: examples/kotlin + wrapper-directory: examples/kotlin + arguments: test --scan diff --git a/examples/kotlin/build.gradle b/examples/kotlin/build.gradle index f20b3ae51a..7f4477e225 100644 --- a/examples/kotlin/build.gradle +++ b/examples/kotlin/build.gradle @@ -25,4 +25,6 @@ compileKotlin { } compileTestKotlin { kotlinOptions.jvmTarget = "1.8" -} \ No newline at end of file +} + +buildScan { termsOfServiceUrl = "https://gradle.com/terms-of-service"; termsOfServiceAgree = "yes" } \ No newline at end of file diff --git a/examples/kotlin/src/test/kotlin/com/example/authors/QueriesImplTest.kt b/examples/kotlin/src/test/kotlin/com/example/authors/QueriesImplTest.kt index 5bb4994848..fb0ce85904 100644 --- a/examples/kotlin/src/test/kotlin/com/example/authors/QueriesImplTest.kt +++ b/examples/kotlin/src/test/kotlin/com/example/authors/QueriesImplTest.kt @@ -18,10 +18,10 @@ class QueriesImplTest { @BeforeEach fun setup() { val user = System.getenv("PG_USER") ?: "postgres" - val port = System.getenv("PG_PORT") ?: "5432" + val pass = System.getenv("PG_PASSWORD") ?: "mysecretpassword" val host = System.getenv("PG_HOST") ?: "127.0.0.1" - val db = System.getenv("PG_DB") ?: "postgres" - val pass = System.getenv("PG_PASS") ?: "postgres" + val port = System.getenv("PG_PORT") ?: "5432" + val db = System.getenv("PG_DATABASE") ?: "dinotest" val url = "jdbc:postgresql://$host:$port/$db?user=$user&password=$pass&sslmode=disable" println("db: $url") diff --git a/internal/endtoend/endtoend_test.go b/internal/endtoend/endtoend_test.go index ac69188b04..abccbc3cc1 100644 --- a/internal/endtoend/endtoend_test.go +++ b/internal/endtoend/endtoend_test.go @@ -58,10 +58,10 @@ func cmpDirectory(t *testing.T, dir string, actual map[string]string) { if file.IsDir() { return nil } - if !strings.HasSuffix(path, ".go") { + if !strings.HasSuffix(path, ".go") && !strings.HasSuffix(path, ".kt") { return nil } - if strings.HasSuffix(path, "_test.go") { + if strings.HasSuffix(path, "_test.go") || strings.Contains(path, "src/test/") { return nil } blob, err := ioutil.ReadFile(path) diff --git a/internal/sqltest/postgres.go b/internal/sqltest/postgres.go index be86df4e65..5a283ac33a 100644 --- a/internal/sqltest/postgres.go +++ b/internal/sqltest/postgres.go @@ -42,6 +42,10 @@ func PostgreSQL(t *testing.T, migrations string) (*sql.DB, func()) { pgUser = "postgres" } + if pgPass == "" { + pgPass = "mysecretpassword" + } + if pgPort == "" { pgPort = "5432" }