Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
/gradlew text eol=lf
*.bat text eol=crlf
*.jar binary
19 changes: 19 additions & 0 deletions .github/dependabot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
version: 2
updates:
- package-ecosystem: "gradle"
directory: "/"
open-pull-requests-limit: 10
schedule:
interval: "daily"
groups:
all:
patterns:
- "*"
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "weekly"
groups:
all:
patterns:
- "*"
50 changes: 50 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
name: Build Pipeline

on:
push:
branches: [ "main" ]
tags: [ "v**" ]
pull_request:
branches: [ "main" ]

permissions: write-all

jobs:
build:
timeout-minutes: 30
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up JDK 21
uses: actions/setup-java@v5
with:
cache: 'gradle'
java-version: '21'
distribution: 'temurin'
- name: Setup Gradle to generate and submit dependency graphs
uses: gradle/actions/setup-gradle@v5
with:
dependency-graph: generate-and-submit
- name: Build with Gradle
run: ./gradlew build aggregateTestCodeCoverageReport sonar
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
- name: Set Docker tag
id: tag
run: |
REF_NAME="${GITHUB_HEAD_REF:-$GITHUB_REF_NAME}"
TAG=$(echo "$REF_NAME" | tr '/' '-' | tr '[:upper:]' '[:lower:]')
echo "tag=$TAG" >> "$GITHUB_OUTPUT"
- name: Build Docker image
run: docker build -t ghcr.io/osgp/gxf-publiclighting-message-transformer:${{ steps.tag.outputs.tag }} .
- name: Log in to GitHub Container Registry
if: github.ref == 'refs/heads/main' || github.ref_type == 'tag'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: echo "$GITHUB_TOKEN" | docker login ghcr.io -u ${{ github.actor }} --password-stdin
- name: Push Docker image
if: github.ref == 'refs/heads/main' || github.ref_type == 'tag'
run: docker push ghcr.io/osgp/gxf-publiclighting-message-transformer:${{ steps.tag.outputs.tag }}
29 changes: 29 additions & 0 deletions .github/workflows/gradle-wrapper.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: Automatic Gradle Wrapper Upgrade

on:
workflow_dispatch:
schedule:
- cron: '0 0 * * 0'

permissions: write-all

jobs:
upgradeGradleWrapper:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Set up Git credentials
env:
TOKEN: ${{ secrets.GRADLE_WRAPPER_UPDATE_TOKEN}}
run: |
git config --global user.email "IoTFDP@alliander.com"
git config --global user.name "IOTFDP"
git config --global url."https://unused-username:${TOKEN}@github.com/".insteadOf "https://github.com/"
- name: Setup Gradle
uses: gradle/actions/setup-gradle@v5
- name: Upgrade Gradle Wrapper
run: ./gradlew upgradeGradleWrapperAll --info --stacktrace
env:
WRAPPER_UPGRADE_GIT_TOKEN: ${{ secrets.GRADLE_WRAPPER_UPDATE_TOKEN }}
40 changes: 40 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
HELP.md
.gradle
build/
!gradle/wrapper/gradle-wrapper.jar
!**/src/main/**/build/
!**/src/test/**/build/

### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
bin/
!**/src/main/**/bin/
!**/src/test/**/bin/

### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
out/
!**/src/main/**/out/
!**/src/test/**/out/

### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/

### VS Code ###
.vscode/

### Kotlin ###
.kotlin
7 changes: 7 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
FROM alpine/java:21-jre

WORKDIR /app

COPY build/libs/gxf-publiclighting-message-transformer.jar app.jar

ENTRYPOINT ["java", "-jar", "/app/app.jar"]
159 changes: 159 additions & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -0,0 +1,159 @@
import com.diffplug.gradle.spotless.SpotlessExtension

plugins {
alias(libs.plugins.dependencyManagement)
alias(libs.plugins.gradleWrapperUpgrade)
alias(libs.plugins.jacoco)
alias(libs.plugins.jacocoReportAggregation)
alias(libs.plugins.kotlinSpring)
alias(libs.plugins.kotlinJvm)
alias(libs.plugins.sonarqube)
alias(libs.plugins.spotless)
alias(libs.plugins.springBoot)
alias(libs.plugins.javaTestFixtures)
`jvm-test-suite`
}

group = "org.lfenergy.gxf"
description = "GXF public lighting transformer between protobuf and object messages"

version = System.getenv("GITHUB_REF_NAME")?.replace("/", "-")?.lowercase() ?: "develop"

java { toolchain { languageVersion = JavaLanguageVersion.of(21) } }

sonar {
properties {
property("sonar.host.url", "https://sonarcloud.io")
property("sonar.projectKey", "OSGP_gxf-publiclighting-message-transformer")
property("sonar.organization", "gxf")
}
}

wrapperUpgrade {
gradle {
register("gxf-publiclighting-message-transformer") {
repo.set("OSGP/gxf-publiclighting-message-transformer")
baseBranch.set("main")
}
}
}

repositories {
mavenCentral()
maven {
name = "GXFGithubPackages"
url = uri("https://maven.pkg.github.com/osgp/*")
credentials {
username = project.findProperty("github.username") as String? ?: System.getenv("GITHUB_ACTOR")
password = project.findProperty("github.token") as String? ?: System.getenv("GITHUB_TOKEN")
}
}
}

dependencies {
developmentOnly(libs.springBootCompose)
developmentOnly(libs.springBootDevtools)

implementation("org.lfenergy.gxf:gxf-publiclighting-contracts-internal")

implementation(libs.kotlinLoggingJvm)
implementation(libs.kotlinReflect)
implementation(libs.pooledJms)
implementation(libs.protobufKotlin)
implementation(libs.springBootStarterActuator)
implementation(libs.springBootStarterArtemis)
implementation(libs.springModulithStarterCore)

runtimeOnly(libs.springModulithActuator)
runtimeOnly(libs.springModulithObservability)

annotationProcessor(libs.springBootConfigurationProcessor)

testFixturesImplementation(libs.protobufKotlin)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Still not sure about the amount of additional setup the external integrationTest folder causes. More gradle config, testFixtures, additional dependencies etc. with no real gain.

testFixturesImplementation("org.lfenergy.gxf:gxf-publiclighting-contracts-internal")

testImplementation(testFixtures(project))

testImplementation(libs.assertJ)
testImplementation(libs.kotlinJunit)
testImplementation(libs.mockkJvm)
testImplementation(libs.mockkSpring)
testImplementation(libs.springBootStarterTest)
testImplementation(libs.springModulithStarterTest)

testRuntimeOnly(libs.junitLauncher)
}

dependencyManagement {
imports {
mavenBom("org.springframework.modulith:spring-modulith-bom:${libs.versions.springModulith.get()}")
}
}

kotlin { compilerOptions { freeCompilerArgs.addAll("-Xjsr305=strict") } }

extensions.configure<SpotlessExtension> {
kotlin {
target("src/**/*.kt")
ktlint("1.6.0")

licenseHeaderFile(file("./spotless/license-header-template.kt"))
}
}

tasks.withType<Test> { useJUnitPlatform() }

tasks.named<Jar>("bootJar") { archiveFileName.set("gxf-publiclighting-message-transformer.jar") }

testing {
suites {
val integrationTest by registering(JvmTestSuite::class) {
useJUnitJupiter()
dependencies {
implementation(project())
implementation(testFixtures(project()))

implementation("org.lfenergy.gxf:gxf-publiclighting-contracts-internal")

implementation(libs.assertJ)
implementation(libs.awaitility)
implementation(libs.pooledJms)
implementation(libs.protobufKotlin)
implementation(libs.springBootStarterArtemis)
implementation(libs.springBootStarterTest)
implementation(libs.springBootTestcontainers)
implementation(libs.testContainers)
implementation(libs.testContainersJUnit)
implementation(libs.testContainersArtemis)
}
targets { all { testTask.configure { shouldRunAfter("test") } } }
}
}

// Make `check` run integration tests
tasks.named("check") { dependsOn("integrationTest") }

// Jacoco code coverage report of unit and integration tests
tasks.register<JacocoReport>("aggregateTestCodeCoverageReport") {
description = "Generates code coverage report for all tests."
group = "Verification"
dependsOn("test", "integrationTest")

executionData(
fileTree(layout.buildDirectory.dir("jacoco")) {
include("test.exec", "test/*.exec", "*.exec")
},
)
sourceSets(sourceSets["main"])
reports {
xml.required.set(true)
html.required.set(true)
}
// filter out generated classes if needed:
classDirectories.setFrom(
classDirectories.files.map {
fileTree(it) { exclude("**/generated/**") }
},
)
}
}
12 changes: 12 additions & 0 deletions compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
services:
artemis:
image: 'apache/activemq-artemis:latest'
container_name: artemis-container.gxf-publiclighting-message-transformer
environment:
- ARTEMIS_USERNAME=artemis
- ARTEMIS_PASSWORD=artemis
- ARTEMIS_MIN_MEMORY=512M
- ARTEMIS_MAX_MEMORY=512M
ports:
- '61616:61616'
- '58161:8161'
Loading
Loading