Skip to content

Update dependabot configuration #2344

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
48 changes: 46 additions & 2 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,49 @@ updates:
patterns:
- "*"
allow:
- dependency-name: "actions/*"
- dependency-name: "redhat-actions/*"
- dependency-type: all
Copy link
Member

Choose a reason for hiding this comment

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

it's probably fine to include all actions to check for the updates since we currently only have the official actions/ and the codeql actions used in the workflows...
For the background, why it was originally limited: the idea was to only allow updates for the explicitly defined trusted sources of actions. So I'll let you decide how you'd like to define that 😃, maybe just

Suggested change
- dependency-type: all
- dependency-name: "actions/*"
- dependency-name: "github/codeql-action/*"

?


- package-ecosystem: "gradle"
directory: "/"
registries:
- gradle-plugin-portal
schedule:
interval: "weekly"
day: "tuesday"
open-pull-requests-limit: 20
groups:
hibernate:
patterns:
- "org.hibernate*"
vertx:
patterns:
- "io.vertx*"
mutiny:
patterns:
- "io.smallrye.reactive*"
# Testcontainers plus the JDBC driver we need for testing
testcontainers:
patterns:
- "org.testcontainers*"
- "com.ibm.db2*"
- "com.microsoft.sqlserver*"
- "org.postgresql*"
- "con.ongres.scram*"
- "com.fasterxml.jackson.core*"
- "com.mysql*"
- "org.mariadb.jdbc*"

ignore:
# Only patches for Hibernate ORM and Vert.x
- dependency-name: "org.hibernate*"
update-types: ["version-update:semver-major", "version-update:semver-minor"]
- dependency-name: "io.vertx*"
update-types: ["version-update:semver-major", "version-update:semver-minor"]

# Dockerfiles in tooling/docker/
- package-ecosystem: "docker"
directory: "/tooling/docker"
schedule:
interval: "weekly"
allow:
- dependency-type: "all"
6 changes: 6 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,12 @@ subprojects {
options.encoding = 'UTF-8'
}

// Configure test tasks for all subprojects
tasks.withType( Test ).configureEach {
// Set the project root for finding Docker files - available to all modules
systemProperty 'hibernate.reactive.project.root', rootProject.projectDir.absolutePath
}

if ( !gradle.ext.javaToolchainEnabled ) {
sourceCompatibility = JavaVersion.toVersion( gradle.ext.baselineJavaVersion )
targetCompatibility = JavaVersion.toVersion( gradle.ext.baselineJavaVersion )
Expand Down
2 changes: 1 addition & 1 deletion gradle/libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jbossLoggingAnnotationVersion = "3.0.4.Final"
jbossLoggingVersion = "3.6.1.Final"
junitVersion = "5.11.3"
log4jVersion = "2.20.0"
testcontainersVersion = "1.21.0"
testcontainersVersion = "1.21.3"
vertxSqlClientVersion = "5.0.0"
vertxWebVersion= "5.0.0"
vertxWebClientVersion = "5.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,13 @@
import jakarta.persistence.metamodel.EntityType;

import static java.util.concurrent.TimeUnit.MINUTES;
import static org.junit.jupiter.api.Assertions.*;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.junit.jupiter.api.Assertions.assertFalse;
import static org.junit.jupiter.api.Assertions.assertNotEquals;
import static org.junit.jupiter.api.Assertions.assertNotNull;
import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertTrue;
import static org.junit.jupiter.api.Assertions.fail;

@Timeout(value = 10, timeUnit = MINUTES)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import org.testcontainers.containers.CockroachContainer;
import org.testcontainers.containers.Container;

import static org.hibernate.reactive.containers.DockerImage.imageName;
import static org.hibernate.reactive.containers.DockerImage.fromDockerfile;

class CockroachDBDatabase extends PostgreSQLDatabase {

Expand All @@ -25,7 +25,7 @@ class CockroachDBDatabase extends PostgreSQLDatabase {
* TIP: To reuse the same containers across multiple runs, set `testcontainers.reuse.enable=true` in a file located
* at `$HOME/.testcontainers.properties` (create the file if it does not exist).
*/
public static final CockroachContainer cockroachDb = new CockroachContainer( imageName( "cockroachdb/cockroach", "v24.3.13" ) )
public static final CockroachContainer cockroachDb = new CockroachContainer( fromDockerfile( "cockroachdb" ) )
// Username, password and database are not supported by test container at the moment
// Testcontainers will use a database named 'postgres' and the 'root' user
.withReuse( true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.testcontainers.containers.Db2Container;

import static org.hibernate.reactive.containers.DockerImage.imageName;
import static org.hibernate.reactive.containers.DockerImage.fromDockerfile;

class DB2Database implements TestableDatabase {

Expand Down Expand Up @@ -87,7 +87,7 @@ class DB2Database implements TestableDatabase {
* TIP: To reuse the same containers across multiple runs, set `testcontainers.reuse.enable=true` in a file located
* at `$HOME/.testcontainers.properties` (create the file if it does not exist).
*/
static final Db2Container db2 = new Db2Container( imageName( "icr.io", "db2_community/db2", "12.1.0.0" ) )
static final Db2Container db2 = new Db2Container( fromDockerfile( "db2" ) )
.withUsername( DatabaseConfiguration.USERNAME )
.withPassword( DatabaseConfiguration.PASSWORD )
.withDatabaseName( DatabaseConfiguration.DB_NAME )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,17 @@
*/
package org.hibernate.reactive.containers;

import java.io.FileNotFoundException;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.List;

import org.testcontainers.utility.DockerImageName;


/**
* A utility class with methods to generate {@link DockerImageName} for testcontainers.
* A utility class with methods to generate a {@link DockerImageName} for Testcontainers.
* <p>
* Testcontainers might not work if the image required is available in multiple different registries (for example when
* using podman instead of docker).
Expand All @@ -17,15 +24,103 @@
*/
public final class DockerImage {

public static final String DEFAULT_REGISTRY = "docker.io";
/**
* The absolute path of the project root that we have set in Gradle.
*/
private static final String PROJECT_ROOT = System.getProperty( "hibernate.reactive.project.root" );

/**
* The path to the directory containing all the Dockerfile files
*/
private static final Path DOCKERFILE_DIR_PATH = Path.of( PROJECT_ROOT ).resolve( "tooling" ).resolve( "docker" );

public static DockerImageName imageName(String image, String version) {
return imageName( DEFAULT_REGISTRY, image, version );
/**
* Extract the image name and version from the first FROM instruction in the Dockerfile.
* Note that everything else is ignored.
*/
public static DockerImageName fromDockerfile(String databaseName) {
try {
final ImageInformation imageInformation = readFromInstruction( databaseName.toLowerCase() );
return imageName( imageInformation.getRegistry(), imageInformation.getImage(), imageInformation.getVersion() );
}
catch (IOException e) {
throw new RuntimeException( e );
}
}

public static DockerImageName imageName(String registry, String image, String version) {
return DockerImageName
.parse( registry + "/" + image + ":" + version )
.asCompatibleSubstituteFor( image );
}

private static class ImageInformation {
private final String registry;
private final String image;
private final String version;

public ImageInformation(String fullImageInfo) {
// FullImageInfo pattern: <registry>/<image>:<version>
// For example: "docker.io/cockroachdb/cockroach:v24.3.13" becomes registry = "docker.io", image = "cockroachdb/cockroach", version = "v24.3.13"
final int registryEndPos = fullImageInfo.indexOf( '/' );
final int imageEndPos = fullImageInfo.lastIndexOf( ':' );
this.registry = fullImageInfo.substring( 0, registryEndPos );
this.image = fullImageInfo.substring( registryEndPos + 1, imageEndPos );
this.version = fullImageInfo.substring( imageEndPos + 1 );
}

public String getRegistry() {
return registry;
}

public String getImage() {
return image;
}

public String getVersion() {
return version;
}

@Override
public String toString() {
return registry + "/" + image + ":" + version;
}
}

private static Path dockerFilePath(String database) {
// Get project root from system property set by Gradle, with fallback
return DOCKERFILE_DIR_PATH.resolve( database.toLowerCase() + ".Dockerfile" );
}

private static ImageInformation readFromInstruction(String database) throws IOException {
return readFromInstruction( dockerFilePath( database ) );
}

/**
* Read a Dockerfile and extract the first FROM instruction.
*
* @param dockerfilePath path to the Dockerfile
* @return the first FROM instruction found, or empty if none found
* @throws IOException if the file cannot be read
*/
private static ImageInformation readFromInstruction(Path dockerfilePath) throws IOException {
if ( !Files.exists( dockerfilePath ) ) {
throw new FileNotFoundException( "Dockerfile not found: " + dockerfilePath );
}

List<String> lines = Files.readAllLines( dockerfilePath );
for ( String line : lines ) {
// Skip comments and empty lines
String trimmedLine = line.trim();
if ( trimmedLine.isEmpty() || trimmedLine.startsWith( "#" ) ) {
continue;
}

if ( trimmedLine.startsWith( "FROM " ) ) {
return new ImageInformation( trimmedLine.substring( "FROM ".length() ) );
}
}

throw new IOException( " Missing FROM instruction in " + dockerfilePath );
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

import org.testcontainers.containers.MSSQLServerContainer;

import static org.hibernate.reactive.containers.DockerImage.imageName;
import static org.hibernate.reactive.containers.DockerImage.fromDockerfile;

/**
* The JDBC driver syntax is:
Expand Down Expand Up @@ -96,7 +96,7 @@ class MSSQLServerDatabase implements TestableDatabase {
* TIP: To reuse the same containers across multiple runs, set `testcontainers.reuse.enable=true` in a file located
* at `$HOME/.testcontainers.properties` (create the file if it does not exist).
*/
public static final MSSQLServerContainer<?> mssqlserver = new MSSQLServerContainer<>( imageName( "mcr.microsoft.com", "mssql/server", "2022-latest" ) )
public static final MSSQLServerContainer<?> mssqlserver = new MSSQLServerContainer<>( fromDockerfile( "sqlserver" ) )
.acceptLicense()
.withPassword( PASSWORD )
.withReuse( true );
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

import org.testcontainers.containers.MariaDBContainer;

import static org.hibernate.reactive.containers.DockerImage.imageName;
import static org.hibernate.reactive.containers.DockerImage.fromDockerfile;

class MariaDatabase extends MySQLDatabase {

Expand All @@ -36,7 +36,7 @@ class MariaDatabase extends MySQLDatabase {
* TIP: To reuse the same containers across multiple runs, set `testcontainers.reuse.enable=true` in a file located
* at `$HOME/.testcontainers.properties` (create the file if it does not exist).
*/
public static final MariaDBContainer<?> maria = new MariaDBContainer<>( imageName( "mariadb", "11.7.2" ) )
public static final MariaDBContainer<?> maria = new MariaDBContainer<>( fromDockerfile( "maria" ) )
.withUsername( DatabaseConfiguration.USERNAME )
.withPassword( DatabaseConfiguration.PASSWORD )
.withDatabaseName( DatabaseConfiguration.DB_NAME )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
package org.hibernate.reactive.containers;

import static org.hibernate.reactive.containers.DockerImage.imageName;
import static org.hibernate.reactive.containers.DockerImage.fromDockerfile;

import java.io.Serializable;
import java.math.BigDecimal;
Expand Down Expand Up @@ -87,7 +87,7 @@ class MySQLDatabase implements TestableDatabase {
* TIP: To reuse the same containers across multiple runs, set `testcontainers.reuse.enable=true` in a file located
* at `$HOME/.testcontainers.properties` (create the file if it does not exist).
*/
public static final MySQLContainer<?> mysql = new MySQLContainer<>( imageName( "mysql", "9.2.0") )
public static final MySQLContainer<?> mysql = new MySQLContainer<>( fromDockerfile( "mysql" ) )
.withUsername( DatabaseConfiguration.USERNAME )
.withPassword( DatabaseConfiguration.PASSWORD )
.withDatabaseName( DatabaseConfiguration.DB_NAME )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@

import org.testcontainers.containers.OracleContainer;

import static org.hibernate.reactive.containers.DockerImage.imageName;
import static org.hibernate.reactive.containers.DockerImage.fromDockerfile;

/**
* Connection string for Oracle thin should be something like:
Expand Down Expand Up @@ -88,9 +88,7 @@ class OracleDatabase implements TestableDatabase {
}
}

public static final OracleContainer oracle = new OracleContainer(
imageName( "gvenzl/oracle-free", "23-slim-faststart" )
.asCompatibleSubstituteFor( "gvenzl/oracle-xe" ) )
public static final OracleContainer oracle = new OracleContainer( fromDockerfile( "oracle" ).asCompatibleSubstituteFor( "gvenzl/oracle-xe" ) )
.withUsername( DatabaseConfiguration.USERNAME )
.withPassword( DatabaseConfiguration.PASSWORD )
.withDatabaseName( DatabaseConfiguration.DB_NAME )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@
*/
package org.hibernate.reactive.containers;

import static org.hibernate.reactive.containers.DockerImage.imageName;

import java.io.Serializable;
import java.math.BigDecimal;
import java.math.BigInteger;
Expand All @@ -30,9 +28,11 @@

import org.testcontainers.containers.PostgreSQLContainer;

import static org.hibernate.reactive.containers.DockerImage.fromDockerfile;

class PostgreSQLDatabase implements TestableDatabase {

public static PostgreSQLDatabase INSTANCE = new PostgreSQLDatabase();
public static final PostgreSQLDatabase INSTANCE = new PostgreSQLDatabase();

private static Map<Class<?>, String> expectedDBTypeForClass = new HashMap<>();

Expand Down Expand Up @@ -87,7 +87,7 @@ class PostgreSQLDatabase implements TestableDatabase {
* TIP: To reuse the same containers across multiple runs, set `testcontainers.reuse.enable=true` in a file located
* at `$HOME/.testcontainers.properties` (create the file if it does not exist).
*/
public static final PostgreSQLContainer<?> postgresql = new PostgreSQLContainer<>( imageName( "postgres", "17.5" ) )
public static final PostgreSQLContainer<?> postgresql = new PostgreSQLContainer<>( fromDockerfile( "postgresql" ) )
.withUsername( DatabaseConfiguration.USERNAME )
.withPassword( DatabaseConfiguration.PASSWORD )
.withDatabaseName( DatabaseConfiguration.DB_NAME )
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,7 @@ public abstract class BaseReactiveIT {
// These properties are in DatabaseConfiguration in core
public static final boolean USE_DOCKER = Boolean.getBoolean( "docker" );

public static final DockerImageName IMAGE_NAME = DockerImageName
.parse( "docker.io/postgres:17.5" )
.asCompatibleSubstituteFor( "postgres" );
public static final DockerImageName IMAGE_NAME = DockerImage.fromDockerfile( "postgresql" );

public static final String USERNAME = "hreact";
public static final String PASSWORD = "hreact";
Expand Down
Loading
Loading