Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use gradle-oci for container images in tests #31

Merged
merged 5 commits into from
Oct 14, 2024
Merged
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
8 changes: 3 additions & 5 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,8 @@ jobs:
java-version: 11
- name: Setup Gradle
uses: gradle/actions/setup-gradle@d156388eb19639ec20ade50009f3d199ce1e2808 # v4
- name: Login to Docker Hub
uses: docker/login-action@9780b0c442fbb1117ed29e0efdff1e18412f7567 # v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}
- name: Check
run: ./gradlew check
env:
ORG_GRADLE_PROJECT_dockerHubUsername: ${{ secrets.DOCKER_USERNAME }}
ORG_GRADLE_PROJECT_dockerHubPassword: ${{ secrets.DOCKER_TOKEN }}
17 changes: 15 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ plugins {
alias(libs.plugins.hivemq.extension)
alias(libs.plugins.protobuf)
alias(libs.plugins.defaults)
alias(libs.plugins.oci)
alias(libs.plugins.license)
idea
}
Expand All @@ -12,8 +13,6 @@ description = "HiveMQ Sparkplug Extension - an extension to monitor sparkplug da
hivemqExtension {
name = "HiveMQ Sparkplug Extension"
author = "HiveMQ"
priority = 0
startPriority = 1000
sdkVersion = libs.versions.hivemq.extensionSdk

resources {
Expand All @@ -33,6 +32,14 @@ protobuf {
}
}

oci {
registries {
dockerHub {
optionalCredentials()
}
}
}

@Suppress("UnstableApiUsage")
testing {
suites {
Expand All @@ -50,9 +57,15 @@ testing {
dependencies {
implementation(libs.testcontainers.junitJupiter)
implementation(libs.testcontainers.hivemq)
implementation(libs.gradleOci.junitJupiter)
implementation(libs.hivemq.mqttClient)
runtimeOnly(libs.logback.classic)
}
oci.of(this) {
imageDependencies {
runtime("hivemq:hivemq4:4.5.3").tag("latest")
}
}
}
}
}
Expand Down
7 changes: 5 additions & 2 deletions gradle/libs.versions.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
[versions]
commonsLang = "3.8.1"
dropwizard-metrics-influxdb = "1.3.4"
gradleOci-junitJupiter = "0.6.0"
hivemq-extensionSdk = "4.5.3"
hivemq-mqttClient = "1.3.3"
junit-jupiter = "5.10.0"
Expand All @@ -13,6 +14,7 @@ wiremock = "3.2.0"
[libraries]
commonsLang = { module = "org.apache.commons:commons-lang3", version.ref = "commonsLang" }
dropwizard-metrics-influxdb = { module = "com.izettle:dropwizard-metrics-influxdb", version.ref = "dropwizard-metrics-influxdb" }
gradleOci-junitJupiter = { module = "io.github.sgtsilvio:gradle-oci-junit-jupiter", version.ref = "gradleOci-junitJupiter" }
hivemq-mqttClient = { module = "com.hivemq:hivemq-mqtt-client", version.ref = "hivemq-mqttClient" }
logback-classic = { module = "ch.qos.logback:logback-classic", version.ref = "logback" }
mockito = { module = "org.mockito:mockito-core", version.ref = "mockito" }
Expand All @@ -22,7 +24,8 @@ testcontainers-junitJupiter = { module = "org.testcontainers:junit-jupiter", ver
wiremock = { module = "org.wiremock:wiremock", version.ref = "wiremock" }

[plugins]
hivemq-extension = { id = "com.hivemq.extension", version = "3.1.0" }
protobuf = { id = "com.google.protobuf", version = "0.9.2" }
defaults = { id = "io.github.sgtsilvio.gradle.defaults", version = "0.2.0" }
hivemq-extension = { id = "com.hivemq.extension", version = "3.2.0" }
license = { id = "com.github.hierynomus.license", version = "0.16.1" }
oci = { id = "io.github.sgtsilvio.gradle.oci", version = "0.16.0" }
protobuf = { id = "com.google.protobuf", version = "0.9.2" }
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,14 @@
import com.hivemq.client.mqtt.mqtt5.Mqtt5Client;
import com.hivemq.client.mqtt.mqtt5.message.disconnect.Mqtt5DisconnectReasonCode;
import com.hivemq.client.mqtt.mqtt5.message.publish.Mqtt5Publish;
import io.github.sgtsilvio.gradle.oci.junit.jupiter.OciImages;
import org.jetbrains.annotations.NotNull;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.Timeout;
import org.slf4j.event.Level;
import org.testcontainers.hivemq.HiveMQContainer;
import org.testcontainers.junit.jupiter.Container;
import org.testcontainers.junit.jupiter.Testcontainers;
import org.testcontainers.utility.DockerImageName;
import org.testcontainers.utility.MountableFile;

import java.nio.charset.StandardCharsets;
Expand All @@ -40,7 +40,7 @@ class SparkplugBInterceptorIT {

@Container
final @NotNull HiveMQContainer container =
new HiveMQContainer(DockerImageName.parse("hivemq/hivemq4").withTag("4.5.3"))
new HiveMQContainer(OciImages.getImageName("hivemq/hivemq4"))
.withExtension(MountableFile.forClasspathResource("hivemq-sparkplug-extension"))
.waitForExtension("HiveMQ Sparkplug Extension")
.withLogLevel(Level.TRACE);
Expand Down