Skip to content

Refactor DefaultReactiveFlushEntityEventListener in order to reuse most of the code of DefaultFlushEntityEventListener instead of rewriting it #6106

Refactor DefaultReactiveFlushEntityEventListener in order to reuse most of the code of DefaultFlushEntityEventListener instead of rewriting it

Refactor DefaultReactiveFlushEntityEventListener in order to reuse most of the code of DefaultFlushEntityEventListener instead of rewriting it #6106

Workflow file for this run

name: Hibernate Reactive CI
on:
push:
branches:
- 'main'
- 'wip/**'
- '2.*'
- '3.*'
- '4.*'
tags:
- '2.*'
- '3.*'
- '4.*'
pull_request:
branches:
- 'main'
- 'wip/**'
- '2.*'
- '3.*'
- '4.*'
# For building snapshots
workflow_call:
inputs:
branch:
required: true
type: string
# Allow running this workflow against a specific branch/tag
workflow_dispatch:
# See https://github.com/hibernate/hibernate-orm/pull/4615 for a description of the behavior we're getting.
concurrency:
# Consider that two builds are in the same concurrency group (cannot run concurrently)
# if they use the same workflow and are about the same branch ("ref"), pull request, and branch name input (for scheduled job).
group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}, branch=${{ inputs.branch }}"
# Cancel previous builds in the same concurrency group even if they are in process
# for pull requests or pushes to forks (not the upstream repository).
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.repository != 'hibernate/hibernate-reactive' }}
jobs:
run_examples:
name: Run examples in '${{ matrix.example }}' on ${{ matrix.db }}
runs-on: ubuntu-latest
strategy:
matrix:
example: [ 'session-example', 'native-sql-example' ]
db: [ 'MySQL', 'PostgreSQL' ]
exclude:
# 'native-sql-example' doesn't run on MySQL because it has native queries
- example: 'native-sql-example'
db: 'MySQL'
services:
# Label used to access the service container
mysql:
image: container-registry.oracle.com/mysql/community-server:9.3.0
env:
MYSQL_ROOT_PASSWORD: hreact
MYSQL_DATABASE: hreact
MYSQL_USER: hreact
MYSQL_PASSWORD: hreact
# Set health checks to wait until postgres has started
options: >-
--health-cmd="mysqladmin ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 3306:3306
postgres:
# Docker Hub image
image: postgres:17.4
env:
POSTGRES_DB: hreact
POSTGRES_USER: hreact
POSTGRES_PASSWORD: hreact
# Set health checks to wait until postgres has started
options: >-
--health-cmd pg_isready
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 5432:5432
steps:
- name: Checkout ${{ inputs.branch }}
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: ${{ inputs.branch }}
- name: Get year/month for cache key
id: get-date
run: |
echo "yearmonth=$(/bin/date -u '+%Y-%m')" >> "$GITHUB_OUTPUT"
shell: bash
- name: Cache Gradle downloads
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
id: cache-gradle
with:
path: |
.gradle/caches
.gradle/jdks
.gradle/wrapper
# refresh cache every month to avoid unlimited growth
key: gradle-examples-${{ matrix.db }}-${{ steps.get-date.outputs.yearmonth }}
- name: Set up JDK 11
if: ${{ startsWith( inputs.branch, 'wip/2' ) }}
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: 11
- name: Set up JDK 17
if: ${{ !startsWith( inputs.branch, 'wip/2' ) }}
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: 17
- name: Print the effective ORM version used
run: ./gradlew :${{ matrix.example }}:dependencyInsight --dependency org.hibernate.orm:hibernate-core
- name: Run examples in '${{ matrix.example }}' on ${{ matrix.db }}
run: ./gradlew :${{ matrix.example }}:runAllExamplesOn${{ matrix.db }}
- name: Upload reports (if build failed)
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: failure()
with:
name: reports-examples-${{ matrix.db }}
path: './**/build/reports/'
test_dbs:
name: Test with ${{ matrix.db }}
runs-on: ubuntu-latest
strategy:
matrix:
db: [ 'MariaDB', 'MySQL', 'PostgreSQL', 'MSSQLServer', 'CockroachDB', 'Db2', 'Oracle' ]
steps:
- name: Checkout ${{ inputs.branch }}
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: ${{ inputs.branch }}
- name: Get year/month for cache key
id: get-date
run: |
echo "yearmonth=$(/bin/date -u '+%Y-%m')" >> "$GITHUB_OUTPUT"
shell: bash
- name: Cache Gradle downloads
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
id: cache-gradle
with:
path: |
.gradle/caches
.gradle/jdks
.gradle/wrapper
# refresh cache every month to avoid unlimited growth
key: gradle-db-${{ matrix.db }}-${{ steps.get-date.outputs.yearmonth }}
- name: Set up JDK 11
if: ${{ startsWith( inputs.branch, 'wip/2' ) }}
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: 11
- name: Set up JDK 17
if: ${{ !startsWith( inputs.branch, 'wip/2' ) }}
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: 17
- name: Print the effective ORM version used
run: ./gradlew :hibernate-reactive-core:dependencyInsight --dependency org.hibernate.orm:hibernate-core
- name: Build and Test with ${{ matrix.db }}
run: ./gradlew build -PshowStandardOutput -Pdocker -Pdb=${{ matrix.db }}
- name: Upload reports (if build failed)
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: failure()
with:
name: reports-db-${{ matrix.db }}
path: './**/build/reports/'
test_jdks:
name: Test with Java ${{ matrix.java.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# To list the available "feature versions" on adoptium.net (ignore "tip_version", it's not relevant):
# https://api.adoptium.net/v3/info/available_releases
# To list the available releases for a given "feature version" on adoptium.net (example for 16):
# https://api.adoptium.net/v3/assets/latest/16/hotspot
# To see the available versions and download links on jdk.java.net:
# https://github.com/oracle-actions/setup-java/blob/main/jdk.java.net-uri.properties
java:
- { name: "17", java_version_numeric: 17 }
# We want to enable preview features when testing newer builds of OpenJDK:
# even if we don't use these features, just enabling them can cause side effects
# and it's useful to test that.
- { name: "21", java_version_numeric: 21, jvm_args: '--enable-preview' }
- { name: "25", java_version_numeric: 25, from: 'jdk.java.net', jvm_args: '--enable-preview' }
- { name: "26-ea", java_version_numeric: 26, from: 'jdk.java.net', jvm_args: '--enable-preview' }
steps:
- name: Checkout ${{ inputs.branch }}
uses: actions/checkout@8e8c483db84b4bee98b60c0593521ed34d9990e8 # v6.0.1
with:
ref: ${{ inputs.branch }}
- name: Get year/month for cache key
id: get-date
run: |
echo "yearmonth=$(/bin/date -u '+%Y-%m')" >> "$GITHUB_OUTPUT"
shell: bash
- name: Generate cache key
id: cache-key
run: |
CURRENT_BRANCH="${{ github.repository != 'hibernate/hibernate-orm' && 'fork' || github.base_ref || github.ref_name }}"
CURRENT_MONTH=$(/bin/date -u "+%Y-%m")
CURRENT_DAY=$(/bin/date -u "+%d")
ROOT_CACHE_KEY="buildtool-cache"
echo "buildtool-monthly-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}" >> $GITHUB_OUTPUT
echo "buildtool-monthly-branch-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}" >> $GITHUB_OUTPUT
echo "buildtool-cache-key=${ROOT_CACHE_KEY}-${CURRENT_MONTH}-${CURRENT_BRANCH}-${CURRENT_DAY}" >> $GITHUB_OUTPUT
- name: Cache Maven/Gradle Dependency/Dist Caches
id: cache-maven
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
# if it's not a pull request, we restore and save the cache
if: github.event_name != 'pull_request'
with:
path: |
~/.m2/repository/
~/.m2/wrapper/
~/.gradle/caches/modules-2
~/.gradle/wrapper/
# A new cache will be stored daily. After that first store of the day, cache save actions will fail because the cache is immutable, but it's not a problem.
# The whole cache is dropped monthly to prevent unlimited growth.
# The cache is per branch but in case we don't find a branch for a given branch, we will get a cache from another branch.
key: ${{ steps.cache-key.outputs.buildtool-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-
- name: Restore Maven/Gradle Dependency/Dist Caches
uses: actions/cache/restore@0057852bfaa89a56745cba8c7296529d2fc39830 # v4.3.0
# if it's a pull request, we restore the cache, but we don't save it
if: github.event_name == 'pull_request'
with:
path: |
~/.m2/repository/
~/.m2/wrapper/
~/.gradle/caches/modules-2
~/.gradle/wrapper/
key: ${{ steps.cache-key.outputs.buildtool-cache-key }}
restore-keys: |
${{ steps.cache-key.outputs.buildtool-monthly-branch-cache-key }}-
${{ steps.cache-key.outputs.buildtool-monthly-cache-key }}-
- name: Set up latest JDK ${{ matrix.java.name }} from jdk.java.net
if: matrix.java.from == 'jdk.java.net'
uses: oracle-actions/setup-java@2e744f723b003fdd759727d0ff654c8717024845 # v1.4.0
with:
website: jdk.java.net
release: ${{ matrix.java.java_version_numeric }}
- name: Set up latest JDK ${{ matrix.java.name }} from Adoptium
if: matrix.java.from == '' || matrix.java.from == 'adoptium.net'
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: ${{ matrix.java.java_version_numeric }}
check-latest: true
- name: Export path to JDK ${{ matrix.java.name }}
id: testjdk-exportpath
run: echo "path=${JAVA_HOME}" >> $GITHUB_OUTPUT
- name: Set up JDK 11
if: ${{ startsWith( inputs.branch, 'wip/2' ) }}
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: 11
check-latest: true
- name: Set up JDK 17
if: ${{ !startsWith( inputs.branch, 'wip/2' ) }}
uses: actions/setup-java@f2beeb24e141e01a676f977032f5a29d81c9e27e # v5.1.0
with:
distribution: 'temurin'
java-version: 17
check-latest: true
- name: Export path to JDK 11
id: mainjdk-exportpath
run: echo "path=${JAVA_HOME}" >> $GITHUB_OUTPUT
- name: Display exact version of JDK ${{ matrix.java.name }}
run: |
${{ steps.testjdk-exportpath.outputs.path }}/bin/java -version
- name: Print the effective ORM version used
run: ./gradlew :hibernate-reactive-core:dependencyInsight --dependency org.hibernate.orm:hibernate-core
- name: Build and Test with Java ${{ matrix.java.name }}
run: |
./gradlew build -PshowStandardOutput -Pdocker -Ptest.jdk.version=${{ matrix.java.java_version_numeric }} \
-Porg.gradle.java.installations.paths=${{ steps.mainjdk-exportpath.outputs.path }},${{ steps.testjdk-exportpath.outputs.path }} \
${{ matrix.java.jvm_args && '-Ptest.jdk.launcher.args=' }}${{ matrix.java.jvm_args }}
- name: Upload reports (if build failed)
uses: actions/upload-artifact@330a01c490aca151604b8cf639adc76d48f6c5d4 # v5.0.0
if: failure()
with:
name: reports-java${{ matrix.java.name }}
path: './**/build/reports/'