Skip to content

Commit

Permalink
Merge branch 'develop'
Browse files Browse the repository at this point in the history
  • Loading branch information
bobeal committed Jan 2, 2024
2 parents 6eaf5c3 + f54f1c1 commit cf0a24d
Show file tree
Hide file tree
Showing 77 changed files with 287 additions and 220 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/anchore.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,17 @@ jobs:
steps:
- name: Checkout project
uses: actions/checkout@v4
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
- name: Assemble project
uses: gradle/gradle-build-action@v2
with:
arguments: assemble
- name: Upload jars artifacts
uses: actions/upload-artifact@v3
uses: actions/upload-artifact@v4
with:
name: jars
path: |
Expand All @@ -37,7 +37,7 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Download jars artifacts
uses: actions/download-artifact@v3
uses: actions/download-artifact@v4
with:
name: jars
path: build
Expand Down Expand Up @@ -90,19 +90,19 @@ jobs:
image: "localbuild/subscription-service:latest-scan"
severity-cutoff: critical
- name: Upload Anchore scan SARIF report for API Gateway
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: ${{ steps.scan-api-gateway.outputs.sarif }}
category: anchore-api-gateway
- name: Upload Anchore scan SARIF report for Search Service
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: ${{ steps.scan-search-service.outputs.sarif }}
category: anchore-search-service
- name: Upload Anchore scan SARIF report for Subscription Service
uses: github/codeql-action/upload-sarif@v2
uses: github/codeql-action/upload-sarif@v3
if: always()
with:
sarif_file: ${{ steps.scan-subscription-service.outputs.sarif }}
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,11 @@ jobs:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'
cache: 'gradle'
- name: Cache SonarCloud packages
uses: actions/cache@v3
Expand Down
10 changes: 5 additions & 5 deletions .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@ jobs:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set up JDK 17
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
distribution: 'temurin'
java-version: '17'
java-version: '21'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -53,7 +53,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, Go, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v2
uses: github/codeql-action/autobuild@v3

# ℹ️ Command-line programs to run using the OS shell.
# 📚 See https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#jobsjob_idstepsrun
Expand All @@ -66,6 +66,6 @@ jobs:
# ./location_of_script_within_repo/buildscript.sh

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
2 changes: 1 addition & 1 deletion .sdkmanrc
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# Enable auto-env through the sdkman_auto_env config
# Add key=value pairs of SDKs to use below
java=17.0.8-tem
java=21-tem
2 changes: 1 addition & 1 deletion Jenkinsfile
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
pipeline {
agent any
tools {
jdk 'JDK 17'
jdk 'JDK 21'
}
environment {
EGM_CI_DH = credentials('egm-ci-dh')
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ The version number is obtained during the build process by using the `version` i
### Developing on a service

Requirements:
* Java 17 (we recommend using [sdkman!](https://sdkman.io/) to install and manage versions of the JDK)
* Java 21 (we recommend using [sdkman!](https://sdkman.io/) to install and manage versions of the JDK)

To develop on a specific service, you can use the provided `docker-compose.yml` file inside each service's directory, for instance:

Expand Down
4 changes: 2 additions & 2 deletions api-gateway/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# You can build a Docker image of the module with the following command:
# docker build --build-arg JAR_FILE=build/libs/api-gateway-{version}.jar -t stellio-api-gateway:{version} .
FROM eclipse-temurin:17-jre as builder
FROM eclipse-temurin:21-jre as builder
WORKDIR application
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:17-jre
FROM eclipse-temurin:21-jre
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
Expand Down
8 changes: 6 additions & 2 deletions api-gateway/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,13 @@ plugins {

dependencies {
implementation("org.springframework.cloud:spring-cloud-starter-gateway")
implementation("org.zalando:logbook-spring-boot-webflux-autoconfigure:3.6.0")
implementation("org.zalando:logbook-spring-boot-webflux-autoconfigure:3.7.2")

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.3")
// https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#test_framework_implementation_dependencies
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.4")
}

springBoot {
Expand Down
27 changes: 13 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import com.google.cloud.tools.jib.gradle.PlatformParameters
import io.gitlab.arturbosch.detekt.Detekt
import io.gitlab.arturbosch.detekt.DetektCreateBaselineTask
Expand All @@ -11,21 +10,21 @@ buildscript {
}
}

extra["springCloudVersion"] = "2022.0.2"
extra["springCloudVersion"] = "2023.0.0"

plugins {
// https://docs.spring.io/spring-boot/docs/current/gradle-plugin/reference/htmlsingle/#reacting-to-other-plugins.java
java
`kotlin-dsl`
// only apply the plugin in the subprojects requiring it because it expects a Spring Boot app
// and the shared lib is obviously not one
id("org.springframework.boot") version "3.1.5" apply false
id("org.springframework.boot") version "3.2.1" apply false
id("io.spring.dependency-management") version "1.1.4" apply false
id("org.graalvm.buildtools.native") version "0.9.28"
kotlin("jvm") version "1.9.21" apply false
kotlin("plugin.spring") version "1.9.21" apply false
kotlin("jvm") version "1.9.22" apply false
kotlin("plugin.spring") version "1.9.22" apply false
id("com.google.cloud.tools.jib") version "3.4.0" apply false
id("io.gitlab.arturbosch.detekt") version "1.23.3" apply false
id("io.gitlab.arturbosch.detekt") version "1.23.4" apply false
id("org.sonarqube") version "4.4.1.3373"
jacoco
}
Expand All @@ -42,7 +41,7 @@ subprojects {
apply(plugin = "io.gitlab.arturbosch.detekt")
apply(plugin = "jacoco")

java.sourceCompatibility = JavaVersion.VERSION_17
java.sourceCompatibility = JavaVersion.VERSION_21

the<DependencyManagementExtension>().apply {
imports {
Expand Down Expand Up @@ -72,7 +71,7 @@ subprojects {

annotationProcessor("org.springframework.boot:spring-boot-configuration-processor")

runtimeOnly("de.siegmar:logback-gelf:5.0.0")
runtimeOnly("de.siegmar:logback-gelf:5.0.1")
runtimeOnly("io.micrometer:micrometer-registry-prometheus")

testImplementation("org.springframework.boot:spring-boot-starter-test") {
Expand All @@ -87,8 +86,8 @@ subprojects {

tasks.withType<KotlinCompile> {
kotlinOptions {
freeCompilerArgs = listOf("-Xjsr305=strict", "-opt-in=kotlin.RequiresOptIn")
jvmTarget = "${JavaVersion.VERSION_17}"
freeCompilerArgs = listOf("-Xjsr305=strict")
jvmTarget = "${JavaVersion.VERSION_21}"
}
}
tasks.withType<Test> {
Expand All @@ -103,7 +102,7 @@ subprojects {
configurations.matching { it.name == "detekt" }.all {
resolutionStrategy.eachDependency {
if (requested.group == "org.jetbrains.kotlin") {
useVersion("1.9.10")
useVersion("1.9.21")
}
}
}
Expand All @@ -127,7 +126,7 @@ subprojects {

// see https://docs.gradle.org/current/userguide/jacoco_plugin.html for configuration instructions
jacoco {
toolVersion = "0.8.7"
toolVersion = "0.8.9"
}
tasks.test {
finalizedBy(tasks.jacocoTestReport) // report is always generated after tests run
Expand All @@ -140,7 +139,7 @@ subprojects {
}
}

project.ext.set("jibFromImage", "eclipse-temurin:17-jre")
project.ext.set("jibFromImage", "eclipse-temurin:21-jre")
project.ext.set(
"jibFromPlatforms",
listOf(
Expand All @@ -164,7 +163,7 @@ subprojects {
NGSI-LD is an Open API and data model specification for context management published by ETSI.
""".trimIndent(),
"org.opencontainers.image.source" to "https://github.com/stellio-hub/stellio-context-broker",
"com.java.version" to "${JavaVersion.VERSION_17}"
"com.java.version" to "${JavaVersion.VERSION_21}"
)
)
}
Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.0.2-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.4-bin.zip
networkTimeout=10000
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
4 changes: 2 additions & 2 deletions search-service/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# You can build a Docker image of the module with the following command:
# docker build --build-arg JAR_FILE=build/libs/search-service-{version}.jar -t stellio-search-service:{version} .
FROM eclipse-temurin:17-jre as builder
FROM eclipse-temurin:21-jre as builder
WORKDIR application
ARG JAR_FILE=build/libs/*.jar
COPY ${JAR_FILE} application.jar
RUN java -Djarmode=layertools -jar application.jar extract

FROM eclipse-temurin:17-jre
FROM eclipse-temurin:21-jre
WORKDIR application
COPY --from=builder application/dependencies/ ./
COPY --from=builder application/spring-boot-loader/ ./
Expand Down
5 changes: 4 additions & 1 deletion search-service/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ dependencies {
implementation("org.json:json:20231013")
implementation(project(":shared"))

detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.3")
detektPlugins("io.gitlab.arturbosch.detekt:detekt-formatting:1.23.4")

developmentOnly("org.springframework.boot:spring-boot-devtools")

Expand All @@ -33,6 +33,9 @@ dependencies {
testImplementation("org.testcontainers:kafka")
testImplementation("org.testcontainers:r2dbc")
testImplementation(testFixtures(project(":shared")))
// https://docs.gradle.org/8.4/userguide/upgrading_version_8.html#test_framework_implementation_dependencies
testImplementation("org.springframework.boot:spring-boot-starter-test")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
}

defaultTasks("bootRun")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package com.egm.stellio.search.config
import org.springframework.context.annotation.Configuration
import org.springframework.http.codec.ServerCodecConfigurer
import org.springframework.web.reactive.config.EnableWebFlux
import org.springframework.web.reactive.config.PathMatchConfigurer
import org.springframework.web.reactive.config.WebFluxConfigurer

@Configuration
Expand All @@ -14,8 +13,4 @@ class WebConfig(private val searchProperties: SearchProperties) : WebFluxConfigu
configurer.defaultCodecs().enableLoggingRequestDetails(true)
configurer.defaultCodecs().maxInMemorySize(searchProperties.payloadMaxBodySize)
}

override fun configurePathMatching(configurer: PathMatchConfigurer) {
configurer.setUseTrailingSlashMatch(true)
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package com.egm.stellio.search.model

import java.time.Duration
import java.time.Period
import java.time.temporal.TemporalAmount

data class TemporalEntitiesQuery(
val entitiesQuery: EntitiesQuery,
val temporalQuery: TemporalQuery,
Expand All @@ -10,4 +14,16 @@ data class TemporalEntitiesQuery(
fun isAggregatedWithDefinedDuration(): Boolean =
withAggregatedValues &&
(temporalQuery.aggrPeriodDuration != null && temporalQuery.aggrPeriodDuration != "PT0S")

fun computeAggrPeriodDuration(): TemporalAmount {
val splitted = temporalQuery.aggrPeriodDuration!!.split("T")
return if (splitted.size == 1) // has only date-based fields
Period.parse(temporalQuery.aggrPeriodDuration)
else {
val duration = Duration.parse("PT" + splitted[1])
if ("P" == splitted[0]) // has only time-based fields
duration
else Period.parse(splitted[0]).plus(duration)
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ data class UpdateResult(
updated = this.updated.plus(other.updated),
notUpdated = this.notUpdated.plus(other.notUpdated)
)

@JsonIgnore
fun hasSuccessfulUpdate(): Boolean =
this.updated.isNotEmpty()
}

val EMPTY_UPDATE_RESULT: UpdateResult = UpdateResult(emptyList(), emptyList())
Expand Down Expand Up @@ -48,7 +52,8 @@ data class UpdateAttributeResult(
this.updateOperationResult in listOf(
UpdateOperationResult.APPENDED,
UpdateOperationResult.REPLACED,
UpdateOperationResult.UPDATED
UpdateOperationResult.UPDATED,
UpdateOperationResult.IGNORED
)
}

Expand All @@ -62,9 +67,6 @@ enum class UpdateOperationResult {
fun isSuccessResult(): Boolean = listOf(APPENDED, REPLACED, UPDATED).contains(this)
}

fun UpdateResult.hasSuccessfulUpdate(): Boolean =
this.updated.isNotEmpty()

fun updateResultFromDetailedResult(updateStatuses: List<UpdateAttributeResult>): UpdateResult {
val updated = updateStatuses.filter { it.isSuccessfullyUpdated() }
.map { UpdatedDetails(it.attributeName, it.datasetId, it.updateOperationResult) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ScopeService(
)
.bind("entity_id", entityId)
.bind("time_property", timeproperty.name)
.oneToResult { toZonedDateTime(it["first"]) }
.oneToResult { toOptionalZonedDateTime(it["first"]) }
.getOrNull()

private fun Json.replaceScopeValue(newScopeValue: Any): Map<String, Any> =
Expand Down
Loading

0 comments on commit cf0a24d

Please sign in to comment.