Skip to content

Commit

Permalink
Test against multiple Java versions (#8988)
Browse files Browse the repository at this point in the history
  • Loading branch information
eddumelendez authored Dec 5, 2024
1 parent 1eeeba8 commit d21ea3c
Show file tree
Hide file tree
Showing 35 changed files with 118 additions and 83 deletions.
7 changes: 7 additions & 0 deletions .github/actions/setup-build/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,16 @@
name: Set up Build
description: Sets up Build
inputs:
java-version:
description: 'The Java version to set up'
required: true
default: '17'
runs:
using: "composite"
steps:
- uses: ./.github/actions/setup-java
with:
java-version: ${{ inputs.java-version }}
- name: Clear existing docker image cache
shell: bash
run: docker image prune -af
Expand Down
7 changes: 6 additions & 1 deletion .github/actions/setup-java/action.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,14 @@
name: Set up Java
description: Sets up Java version
inputs:
java-version:
description: 'The Java version to set up'
required: true
default: '17'
runs:
using: "composite"
steps:
- uses: actions/setup-java@v4
with:
java-version: '8'
java-version: ${{ inputs.java-version }}
distribution: temurin
2 changes: 1 addition & 1 deletion .github/settings.yml
Original file line number Diff line number Diff line change
Expand Up @@ -400,7 +400,7 @@ branches:
# Required. Require branches to be up to date before merging.
strict: true
# Required. The list of status checks to require in order to merge into this branch
contexts: ["core", "check_docs_examples (:docs:examples:check)", "in-docker_test", "ci/circleci: minimal_core", "test"]
contexts: ["core (17)", "core (21)", "check_docs_examples (:docs:examples:check)", "in-docker_test", "ci/circleci: minimal_core", "test"]
# Required. Enforce all configured restrictions for administrators. Set to true to enforce required status checks for repository administrators. Set to null to disable.
enforce_admins: false
# Prevent merge commits from being pushed to matching branches
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-docker-wormhole.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,5 +53,5 @@ jobs:
-v "$PWD:$PWD" \
-w "$PWD" \
-e AUTO_APPLY_GIT_HOOKS=false \
openjdk:8-jdk-alpine \
eclipse-temurin:17-jdk-alpine \
./gradlew --no-daemon --continue --scan testcontainers:test --tests '*GenericContainerRuleTest'
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,14 @@ jobs:
runs-on: ubuntu-22.04
permissions:
checks: write
strategy:
matrix:
java: [ '17', '21' ]
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/setup-build
with:
java-version: ${{ matrix.java }}
- name: Build and test with Gradle
run: |
./gradlew :testcontainers:check --no-daemon --continue --scan
Expand Down
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=8.0.372-tem
java=17.0.12-tem
19 changes: 14 additions & 5 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ plugins {
id 'io.franzbecker.gradle-lombok' version '5.0.0'
id 'com.gradleup.shadow' version '8.3.0'
id 'me.champeau.gradle.japicmp' version '0.4.3' apply false
id 'com.diffplug.spotless' version '6.13.0' apply false
id 'com.diffplug.spotless' version '6.22.0' apply false
}

apply from: "$rootDir/gradle/ci-support.gradle"
Expand All @@ -26,6 +26,7 @@ captainHook {
}

subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'idea'
apply plugin: 'io.franzbecker.gradle-lombok'
Expand All @@ -35,9 +36,17 @@ subprojects {

group = "org.testcontainers"

sourceCompatibility = 1.8
targetCompatibility = 1.8
compileJava.options.encoding = 'UTF-8'
java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

tasks.withType(JavaCompile) {
options.release.set(8)
options.encoding = 'UTF-8'
}

compileTestJava.options.encoding = 'UTF-8'
javadoc.options.encoding = 'UTF-8'

Expand Down Expand Up @@ -126,7 +135,7 @@ subprojects {
}

checkstyle {
toolVersion = "9.3"
toolVersion = "10.12.4"
configFile = rootProject.file('config/checkstyle/checkstyle.xml')
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

interface DockerCompose {
String ENV_PROJECT_NAME = "COMPOSE_PROJECT_NAME";

String ENV_COMPOSE_FILE = "COMPOSE_FILE";

DockerCompose withCommand(String cmd);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

public interface Transferable {
int DEFAULT_FILE_MODE = 0100644;

int DEFAULT_DIR_MODE = 040755;

static Transferable of(String string) {
Expand Down
5 changes: 5 additions & 0 deletions core/src/test/java/org/testcontainers/TestImages.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,14 @@

public interface TestImages {
DockerImageName REDIS_IMAGE = DockerImageName.parse("redis:6-alpine");

DockerImageName RABBITMQ_IMAGE = DockerImageName.parse("rabbitmq:3.7.25");

DockerImageName MONGODB_IMAGE = DockerImageName.parse("mongo:4.4");

DockerImageName ALPINE_IMAGE = DockerImageName.parse("alpine:3.17");

DockerImageName DOCKER_REGISTRY_IMAGE = DockerImageName.parse("registry:2.7.0");

DockerImageName TINY_IMAGE = DockerImageName.parse("alpine:3.17");
}
4 changes: 2 additions & 2 deletions examples/build.gradle
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
// empty build.gradle for dependabot
plugins {
id 'com.diffplug.spotless' version '6.13.0' apply false
id 'com.diffplug.spotless' version '6.22.0' apply false
}

apply from: "$rootDir/../gradle/ci-support.gradle"
Expand All @@ -25,7 +25,7 @@ subprojects {
}

checkstyle {
toolVersion = "9.3"
toolVersion = "10.12.4"
configFile = rootProject.file('../config/checkstyle/checkstyle.xml')
}
}
Binary file modified examples/gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=9d926787066a081739e8200858338b4a69e837c3a821a33aca9db09dd4a41026
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
distributionSha256Sum=d725d707bfabd4dfdc958c624003b3c80accc03f7037b5122c4b1d0ef15cecab
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions examples/gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions examples/gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,6 @@

public interface LinkedContainerTestImages {
DockerImageName POSTGRES_TEST_IMAGE = DockerImageName.parse("postgres:9.6.12");

DockerImageName REDMINE_TEST_IMAGE = DockerImageName.parse("redmine:3.3.2");
}
2 changes: 1 addition & 1 deletion gradle/spotless.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,6 @@ spotless {
}
groovyGradle {
target '**/*.groovy'
greclipse('4.19.0')
greclipse('4.19')
}
}
Binary file modified gradle/wrapper/gradle-wrapper.jar
Binary file not shown.
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionSha256Sum=c16d517b50dd28b3f5838f0e844b7520b8f1eb610f2f29de7e4e04a1b7c9c79b
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-all.zip
distributionSha256Sum=258e722ec21e955201e31447b0aed14201765a3bfbae296a46cf60b70e66db70
distributionUrl=https\://services.gradle.org/distributions/gradle-8.9-all.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
Expand Down
7 changes: 5 additions & 2 deletions gradlew
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@
# See the License for the specific language governing permissions and
# limitations under the License.
#
# SPDX-License-Identifier: Apache-2.0
#

##############################################################################
#
Expand Down Expand Up @@ -55,7 +57,7 @@
# Darwin, MinGW, and NonStop.
#
# (3) This script is generated from the Groovy template
# https://github.com/gradle/gradle/blob/HEAD/subprojects/plugins/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# https://github.com/gradle/gradle/blob/HEAD/platforms/jvm/plugins-application/src/main/resources/org/gradle/api/internal/plugins/unixStartScript.txt
# within the Gradle project.
#
# You can find Gradle at https://github.com/gradle/gradle/.
Expand Down Expand Up @@ -84,7 +86,8 @@ done
# shellcheck disable=SC2034
APP_BASE_NAME=${0##*/}
# Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036)
APP_HOME=$( cd "${APP_HOME:-./}" > /dev/null && pwd -P ) || exit
APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s
' "$PWD" ) || exit

# Use the maximum available, or set MAX_FD != -1 to use that value.
MAX_FD=maximum
Expand Down
22 changes: 12 additions & 10 deletions gradlew.bat
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
@rem See the License for the specific language governing permissions and
@rem limitations under the License.
@rem
@rem SPDX-License-Identifier: Apache-2.0
@rem

@if "%DEBUG%"=="" @echo off
@rem ##########################################################################
Expand Down Expand Up @@ -43,11 +45,11 @@ set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if %ERRORLEVEL% equ 0 goto execute

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH. 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand All @@ -57,11 +59,11 @@ set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto execute

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.
echo. 1>&2
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME% 1>&2
echo. 1>&2
echo Please set the JAVA_HOME variable in your environment to match the 1>&2
echo location of your Java installation. 1>&2

goto fail

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

public interface CockroachDBTestImages {
DockerImageName COCKROACHDB_IMAGE = DockerImageName.parse("cockroachdb/cockroach:v22.2.3");

DockerImageName FIRST_COCKROACHDB_IMAGE_WITH_ENV_VARS_SUPPORT = DockerImageName.parse(
"cockroachdb/cockroach:v22.1.0"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

public interface JUnitJupiterTestImages {
DockerImageName POSTGRES_IMAGE = DockerImageName.parse("postgres:9.6.12");

DockerImageName HTTPD_IMAGE = DockerImageName.parse("httpd:2.4-alpine");

DockerImageName MYSQL_IMAGE = DockerImageName.parse("mysql:8.0.32");
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@

public interface LocalstackTestImages {
DockerImageName LOCALSTACK_IMAGE = DockerImageName.parse("localstack/localstack:0.12.8");

DockerImageName LOCALSTACK_0_10_IMAGE = LOCALSTACK_IMAGE.withTag("0.10.7");

DockerImageName LOCALSTACK_0_11_IMAGE = LOCALSTACK_IMAGE.withTag("0.11.3");

DockerImageName LOCALSTACK_0_12_IMAGE = LOCALSTACK_IMAGE.withTag("0.12.8");

DockerImageName LOCALSTACK_0_13_IMAGE = LOCALSTACK_IMAGE.withTag("0.13.0");

DockerImageName LOCALSTACK_2_3_IMAGE = LOCALSTACK_IMAGE.withTag("2.3");

DockerImageName AWS_CLI_IMAGE = DockerImageName.parse("amazon/aws-cli:2.7.27");
}
13 changes: 0 additions & 13 deletions modules/oracle-free/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,3 @@ dependencies {
testImplementation testFixtures(project(':r2dbc'))
testRuntimeOnly 'com.oracle.database.r2dbc:oracle-r2dbc:1.2.0'
}

test {
javaLauncher = javaToolchains.launcherFor {
languageVersion = JavaLanguageVersion.of(11)
}
}

compileTestJava {
javaCompiler = javaToolchains.compilerFor {
languageVersion = JavaLanguageVersion.of(11)
}
options.release.set(11)
}
Loading

0 comments on commit d21ea3c

Please sign in to comment.