diff --git a/.github/workflows/gradle.yml b/.github/workflows/gradle.yml
index caae039..766846d 100644
--- a/.github/workflows/gradle.yml
+++ b/.github/workflows/gradle.yml
@@ -1,23 +1,76 @@
-name: CI
+name: Tests
on:
push:
- branches: [ action, master ]
+ branches:
+ - 'master'
pull_request:
- branches: [ action, master ]
+ branches:
+ - 'master'
jobs:
- build:
-
+ test:
runs-on: ubuntu-latest
steps:
- - uses: actions/checkout@v2
- - name: Set up JDK 11
- uses: actions/setup-java@v1
- with:
- java-version: 11
- - uses: eskatos/gradle-command-action@v1
- with:
- gradle-version: 6.8
- arguments: test
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+
+ - name: Cache Gradle packages
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ ${{ runner.os }}-gradle-
+
+ - name: Build
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: '7.1'
+ arguments: build -x test -x ktlintKotlinScriptCheck -x ktlintTestSourceSetCheck -x ktlintMainSourceSetCheck
+ - name: Cleanup Gradle Cache
+ # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
+ # Restoring these files from a GitHub Actions cache might cause problems for future builds.
+ run: |
+ rm -f ~/.gradle/caches/modules-2/modules-2.lock
+ rm -f ~/.gradle/caches/modules-2/gc.properties
+
+ - name: Lint
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: '7.1'
+ arguments: ktlintCheck
+
+ - name: Test
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: '7.1'
+ arguments: test
+
+ - name: Coverage
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: '7.1'
+ arguments: jacocoTestReport
+
+ - name: Cache SonarCloud packages
+ uses: actions/cache@v1
+ with:
+ path: ~/.sonar/cache
+ key: ${{ runner.os }}-sonar
+ restore-keys: ${{ runner.os }}-sonar
+
+ - name: Push analyse to sonarqube
+ uses: eskatos/gradle-command-action@v1
+ env:
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} # Needed to get PR information, if any
+ SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
+ with:
+ gradle-version: '7.1'
+ arguments: sonarqube --info
diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml
new file mode 100644
index 0000000..2e6f2c5
--- /dev/null
+++ b/.github/workflows/publish.yml
@@ -0,0 +1,53 @@
+name: Publish
+
+on:
+ release:
+ types: [ published ]
+
+jobs:
+ publish:
+ runs-on: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v2
+ - name: Set up JDK 11
+ uses: actions/setup-java@v1
+ with:
+ java-version: 11
+
+ - name: Cache Gradle packages
+ uses: actions/cache@v2
+ with:
+ path: |
+ ~/.gradle/caches
+ ~/.gradle/wrapper
+ key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }}
+ restore-keys: |
+ ${{ runner.os }}-gradle-
+
+ - name: Build
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: '7.1'
+ arguments: build -x test -x ktlintKotlinScriptCheck -x ktlintTestSourceSetCheck -x ktlintMainSourceSetCheck
+ - name: Cleanup Gradle Cache
+ # Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
+ # Restoring these files from a GitHub Actions cache might cause problems for future builds.
+ run: |
+ rm -f ~/.gradle/caches/modules-2/modules-2.lock
+ rm -f ~/.gradle/caches/modules-2/gc.properties
+
+ - name: Test
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: '7.1'
+ arguments: test
+
+ - name: Publish
+ uses: eskatos/gradle-command-action@v1
+ with:
+ gradle-version: '7.1'
+ arguments: publish
+ env:
+ GITHUB_ACTOR: ${{ secrets.GITHUB_ACTOR }}
+ GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
diff --git a/.idea/.gitignore b/.idea/.gitignore
index 3ad53bc..f50cf27 100644
--- a/.idea/.gitignore
+++ b/.idea/.gitignore
@@ -5,6 +5,5 @@
/dataSources.local.xml
/compiler.xml
/uiDesigner.xml
-/dataSources.xml
/sonarlint/
/jarRepositories.xml
\ No newline at end of file
diff --git a/.idea/codeStyles/Project.xml b/.idea/codeStyles/Project.xml
index 877b662..85e6648 100644
--- a/.idea/codeStyles/Project.xml
+++ b/.idea/codeStyles/Project.xml
@@ -17,15 +17,7 @@
-
-
-
-
-
-
-
-
-
+
diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
new file mode 100644
index 0000000..7b7cef8
--- /dev/null
+++ b/.idea/dataSources.xml
@@ -0,0 +1,12 @@
+
+
+
+
+ postgresql
+ true
+ org.postgresql.Driver
+ jdbc:postgresql://localhost:5555/json_test
+ $ProjectFileDir$
+
+
+
\ No newline at end of file
diff --git a/build.gradle.kts b/build.gradle.kts
index 6907ff4..f483389 100644
--- a/build.gradle.kts
+++ b/build.gradle.kts
@@ -4,15 +4,16 @@ plugins {
jacoco
id("maven-publish")
- kotlin("jvm") version "1.4.30"
+ kotlin("jvm") version "1.5.10"
id("org.jlleitschuh.gradle.ktlint") version "10.0.0"
id("org.owasp.dependencycheck") version "6.1.1"
id("fr.coppernic.versioning") version "3.2.1"
id("com.avast.gradle.docker-compose") version "0.14.0"
+ id("org.sonarqube") version "+"
}
-group = "com.github.flecomte"
+group = "io.github.flecomte"
version = versioning.info.tag
repositories {
@@ -44,13 +45,24 @@ tasks.test {
finalizedBy(tasks.ktlintCheck)
}
+tasks.jacocoTestReport {
+ dependsOn(tasks.test)
+ reports {
+ xml.required.set(true)
+ }
+}
+
+tasks.sonarqube.configure {
+ dependsOn(tasks.jacocoTestReport)
+}
+
tasks.publishToMavenLocal {
dependsOn(tasks.test)
}
dependencies {
- implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8")
- implementation("org.jetbrains.kotlin:kotlin-reflect:1.4.31")
+ implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.5.20")
+ implementation("org.jetbrains.kotlin:kotlin-reflect:1.5.20")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin:2.12.1")
implementation("com.fasterxml.jackson.datatype:jackson-datatype-joda:2.12.1")
implementation("com.github.jasync-sql:jasync-postgresql:1.1.7")
@@ -61,7 +73,7 @@ dependencies {
testImplementation("ch.qos.logback:logback-core:1.2.3")
testImplementation("io.mockk:mockk:1.10.6")
testImplementation("org.junit.jupiter:junit-jupiter:5.7.1")
- testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.4.30")
+ testImplementation("org.jetbrains.kotlin:kotlin-test-junit:1.5.20")
testImplementation("org.amshove.kluent:kluent:1.65")
}
@@ -97,3 +109,13 @@ publishing {
}
}
}
+
+tasks.withType().configureEach {
+ onlyIf {
+ versioning.info.run {
+ !dirty && tag != null && tag.matches("""[0-9]+\.[0-9]+\.[0-9]+""".toRegex())
+ }
+ }
+
+ dependsOn(tasks.test)
+}
diff --git a/docker-compose.yml b/docker-compose.yml
index 09dc326..0e8ea03 100644
--- a/docker-compose.yml
+++ b/docker-compose.yml
@@ -1,6 +1,6 @@
# To execute this docker-compose yml file use docker-compose -f up
# Add the "-d" flag at the end for detached execution
-version: '3.7'
+version: '3.8'
services:
db:
container_name: postgres_json
diff --git a/docker/postgresql/Dockerfile b/docker/postgresql/Dockerfile
index f315eb7..feacb49 100644
--- a/docker/postgresql/Dockerfile
+++ b/docker/postgresql/Dockerfile
@@ -1,4 +1,4 @@
-FROM postgres:11
+FROM postgres:13
COPY postgresql.conf /tmp/postgresql.conf
COPY extension.sh /docker-entrypoint-initdb.d/000-extension.sh
diff --git a/docker/postgresql/postgresql.conf b/docker/postgresql/postgresql.conf
index fd24ea8..1cb589f 100644
--- a/docker/postgresql/postgresql.conf
+++ b/docker/postgresql/postgresql.conf
@@ -664,5 +664,3 @@ log_rotation_size = 100MB
#------------------------------------------------------------------------------
# Add settings for extensions here
-
-zdb.default_elasticsearch_url = 'http://elasticsearch:9200/'
diff --git a/gradle.properties b/gradle.properties
index ebfce39..f75a70a 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -1,2 +1,8 @@
kotlin.code.style=official
-kotlin_version=1.3.31
\ No newline at end of file
+kotlin_version=1.5.10
+systemProp.sonar.host.url=https://sonarcloud.io
+systemProp.sonar.projectKey=postgres-json
+systemProp.sonar.projectName=PostgresJson
+systemProp.sonar.organization=flecomte
+systemProp.sonar.java.coveragePlugin=jacoco
+systemProp.sonar.coverage.jacoco.xmlReportPaths=build/reports/jacoco/test/jacocoTestReport.xml
\ No newline at end of file
diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties
index bcb8631..1281863 100644
--- a/gradle/wrapper/gradle-wrapper.properties
+++ b/gradle/wrapper/gradle-wrapper.properties
@@ -1,4 +1,4 @@
-distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
+distributionUrl=https\://services.gradle.org/distributions/gradle-7.1-bin.zip
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStorePath=wrapper/dists
diff --git a/src/main/kotlin/fr/postgresjson/connexion/Requester.kt b/src/main/kotlin/fr/postgresjson/connexion/Requester.kt
index 303d5e8..e3d502e 100644
--- a/src/main/kotlin/fr/postgresjson/connexion/Requester.kt
+++ b/src/main/kotlin/fr/postgresjson/connexion/Requester.kt
@@ -80,9 +80,9 @@ class Requester(
constructor(
host: String = "localhost",
port: Int = 5432,
- database: String = "dc-project",
- username: String = "dc-project",
- password: String = "dc-project",
+ database: String,
+ username: String,
+ password: String,
queriesDirectory: URI? = null,
functionsDirectory: URI? = null
) : this(