Skip to content

Commit d636b0f

Browse files
authored
kotlin CI (#2)
1 parent 5a3c154 commit d636b0f

File tree

5 files changed

+48
-6
lines changed

5 files changed

+48
-6
lines changed

.github/workflows/ci-kotlin.yml

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: sqlc kotlin test suite
2+
on: [push, pull_request]
3+
jobs:
4+
5+
build:
6+
name: Build And Test
7+
runs-on: ubuntu-latest
8+
9+
services:
10+
postgres:
11+
image: postgres:11
12+
env:
13+
POSTGRES_USER: postgres
14+
POSTGRES_PASSWORD: postgres
15+
POSTGRES_DB: postgres
16+
ports:
17+
- 5432:5432
18+
# needed because the postgres container does not provide a healthcheck
19+
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
20+
21+
steps:
22+
- uses: actions/checkout@master
23+
- uses: actions/setup-java@v1
24+
with:
25+
java-version: 11
26+
- uses: eskatos/gradle-command-action@v1
27+
env:
28+
PG_USER: postgres
29+
PG_HOST: localhost
30+
PG_DATABASE: postgres
31+
PG_PASSWORD: postgres
32+
PG_PORT: ${{ job.services.postgres.ports['5432'] }}
33+
with:
34+
build-root-directory: examples/kotlin
35+
wrapper-directory: examples/kotlin
36+
arguments: test --scan

examples/kotlin/build.gradle

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,6 @@ compileKotlin {
2525
}
2626
compileTestKotlin {
2727
kotlinOptions.jvmTarget = "1.8"
28-
}
28+
}
29+
30+
buildScan { termsOfServiceUrl = "https://gradle.com/terms-of-service"; termsOfServiceAgree = "yes" }

examples/kotlin/src/test/kotlin/com/example/authors/QueriesImplTest.kt

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,10 @@ class QueriesImplTest {
1818
@BeforeEach
1919
fun setup() {
2020
val user = System.getenv("PG_USER") ?: "postgres"
21-
val port = System.getenv("PG_PORT") ?: "5432"
21+
val pass = System.getenv("PG_PASSWORD") ?: "mysecretpassword"
2222
val host = System.getenv("PG_HOST") ?: "127.0.0.1"
23-
val db = System.getenv("PG_DB") ?: "postgres"
24-
val pass = System.getenv("PG_PASS") ?: "postgres"
23+
val port = System.getenv("PG_PORT") ?: "5432"
24+
val db = System.getenv("PG_DATABASE") ?: "dinotest"
2525
val url = "jdbc:postgresql://$host:$port/$db?user=$user&password=$pass&sslmode=disable"
2626
println("db: $url")
2727

internal/endtoend/endtoend_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,10 +58,10 @@ func cmpDirectory(t *testing.T, dir string, actual map[string]string) {
5858
if file.IsDir() {
5959
return nil
6060
}
61-
if !strings.HasSuffix(path, ".go") {
61+
if !strings.HasSuffix(path, ".go") && !strings.HasSuffix(path, ".kt") {
6262
return nil
6363
}
64-
if strings.HasSuffix(path, "_test.go") {
64+
if strings.HasSuffix(path, "_test.go") || strings.Contains(path, "src/test/") {
6565
return nil
6666
}
6767
blob, err := ioutil.ReadFile(path)

internal/sqltest/postgres.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ func PostgreSQL(t *testing.T, migrations string) (*sql.DB, func()) {
4242
pgUser = "postgres"
4343
}
4444

45+
if pgPass == "" {
46+
pgPass = "mysecretpassword"
47+
}
48+
4549
if pgPort == "" {
4650
pgPort = "5432"
4751
}

0 commit comments

Comments
 (0)