HHH-14336 Enable tests across databases in Github Actions

This commit is contained in:
Christian Beikov 2020-11-19 15:50:16 +01:00
parent c3eaa7cf30
commit 234bfab1ac
12 changed files with 324 additions and 32 deletions

110
.github/workflows/contributor-build.yml vendored Normal file
View File

@ -0,0 +1,110 @@
# The main CI of Hibernate ORM is https://ci.hibernate.org/job/hibernate-orm-6.0-h2-main/.
# However, Hibernate ORM builds run on GitHub actions regularly
# to check that it still works and can be used in GitHub forks.
# See https://docs.github.com/en/free-pro-team@latest/actions
# for more information about GitHub actions.
name: Hibernate ORM contributor build
on:
push:
branches:
- 'master'
- 'wip/6.0'
pull_request:
branches:
- 'master'
- 'wip/6.0'
jobs:
build:
name: Build and test on Java 8 against a wide range of DBs
runs-on: ubuntu-latest
strategy:
matrix:
include:
- rdbms: h2
jdk: 8
- rdbms: derby
jdk: 8
- rdbms: mariadb
jdk: 8
- rdbms: postgresql
jdk: 8
- rdbms: oracle
jdk: 8
- rdbms: db2
jdk: 8
- rdbms: mssql
jdk: 8
steps:
- uses: actions/checkout@v2
- name: Set up Java 8
uses: actions/setup-java@v1
with:
java-version: 1.8
- name: Get year/month for cache key
id: get-date
run: |
echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")"
shell: bash
- name: Cache Maven local repository
uses: actions/cache@v2
id: cache-maven
with:
path: |
~/.m2/repository
~/.gradle/caches/
~/.gradle/wrapper/
# refresh cache every month to avoid unlimited growth
key: maven-localrepo-${{ steps.get-date.outputs.yearmonth }}
- name: Run build script
env:
RDBMS: ${{ matrix.rdbms }}
JDK: ${{ matrix.jdk }}
run: ./ci/build-guthub.sh
shell: bash
- name: Upload test reports (if Gradle failed)
uses: actions/upload-artifact@v2
if: failure()
with:
name: test-reports-java8
path: './**/target/reports/tests/test/'
- name: Omit produced artifacts from build cache
run: ./ci/before-cache.sh
build11:
name: Build and test on Java 11
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Java 11
uses: actions/setup-java@v1
with:
java-version: 11
- name: Get year/month for cache key
id: get-date
run: |
echo "::set-output name=yearmonth::$(/bin/date -u "+%Y-%m")"
shell: bash
- name: Cache Maven local repository
uses: actions/cache@v2
id: cache-maven
with:
path: |
~/.m2/repository
~/.gradle/caches/
~/.gradle/wrapper/
# refresh cache every month to avoid unlimited growth
key: maven-localrepo-${{ steps.get-date.outputs.yearmonth }}
- name: Run build script
env:
JDK: 11
run: ./ci/build-guthub.sh
shell: bash
- name: Upload test reports (if Gradle failed)
uses: actions/upload-artifact@v2
if: failure()
with:
name: test-reports-java11
path: './**/target/reports/tests/test/'
- name: Omit produced artifacts from build cache
run: ./ci/before-cache.sh

View File

@ -1,26 +1,56 @@
dist: trusty
language: java
jobs:
include:
- stage: Oracle JDK 8
jdk: oraclejdk8
- stage: AdoptOpenJDK 11.0.9
install:
- curl -L -o install-jdk.sh https://github.com/sormuras/bach/raw/master/install-jdk.sh
- source ./install-jdk.sh --target ./openjdk11 --url https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11.1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.9_11.tar.gz
before_script:
- java -version
- ./gradlew assemble
script:
- ./gradlew check -Plog-test-progress=true
- ./ci/build-travis.sh
before_cache:
- rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
- rm -fr $HOME/.gradle/caches/*/plugin-resolution/
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.bin
- rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.lock
- ./ci/before-cache.sh
cache:
directories:
- $HOME/.gradle/caches/
- $HOME/.gradle/wrapper/
matrix:
fast_finish: true
include:
- env: RDBMS=h2
jdk: oraclejdk8
sudo: required
# - env: RDBMS=derby
# jdk: oraclejdk8
# sudo: required
# - env: RDBMS=mariadb
# jdk: oraclejdk8
# sudo: true
# services:
# - docker
# - env: RDBMS=postgresql
# jdk: oraclejdk8
# sudo: true
# services:
# - docker
# - env: RDBMS=oracle
# jdk: oraclejdk8
# sudo: true
# services:
# - docker
# - env: RDBMS=db2
# jdk: oraclejdk8
# sudo: true
# services:
# - docker
# - env: RDBMS=mssql
# jdk: oraclejdk8
# sudo: true
# services:
# - docker
- env: JDK=11
install:
- curl -L -o install-jdk.sh https://github.com/sormuras/bach/raw/master/install-jdk.sh
- source ./install-jdk.sh --target ./openjdk11 --url https://github.com/AdoptOpenJDK/openjdk11-binaries/releases/download/jdk-11.0.9%2B11.1/OpenJDK11U-jdk_x64_linux_hotspot_11.0.9_11.tar.gz
allow_failures:
# - env: RDBMS=derby
# - env: RDBMS=mariadb
# - env: RDBMS=postgresql
# - env: RDBMS=oracle
# - env: RDBMS=db2
# - env: RDBMS=mssql
- env: JDK=11

7
ci/before-cache.sh Normal file
View File

@ -0,0 +1,7 @@
#! /bin/bash
rm -f $HOME/.gradle/caches/modules-2/modules-2.lock
rm -fr $HOME/.gradle/caches/*/plugin-resolution/
rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.bin
rm -f $HOME/.gradle/caches/*/fileHashes/fileHashes.lock
rm -fr $HOME/.m2/repository/org/hibernate

21
ci/build-github.sh Normal file
View File

@ -0,0 +1,21 @@
#! /bin/bash
java -version
./gradlew assemble
if [ "$RDBMS" == 'mysql' ]; then
bash ../docker_db.sh mysql_5_7
elif [ "$RDBMS" == 'mysql8' ]; then
bash ../docker_db.sh mysql_8_0
elif [ "$RDBMS" == 'mariadb' ]; then
bash ../docker_db.sh mariadb
elif [ "$RDBMS" == 'postgresql' ]; then
bash ../docker_db.sh postgresql_9_5
elif [ "$RDBMS" == 'db2' ]; then
bash ../docker_db.sh db2
elif [ "$RDBMS" == 'oracle' ]; then
bash ../docker_db.sh oracle
elif [ "$RDBMS" == 'mssql' ]; then
bash ../docker_db.sh mssql
fi
exec bash ./build.sh

25
ci/build-travis.sh Normal file
View File

@ -0,0 +1,25 @@
#! /bin/bash
java -version
./gradlew assemble
if [ "$RDBMS" == 'mysql' ]; then
sudo service mysql stop
bash ../docker_db.sh mysql_5_7
elif [ "$RDBMS" == 'mysql8' ]; then
sudo service mysql stop
bash ../docker_db.sh mysql_8_0
elif [ "$RDBMS" == 'mariadb' ]; then
sudo service mysql stop
bash ../docker_db.sh mariadb
elif [ "$RDBMS" == 'postgresql' ]; then
sudo service postgres stop
bash ../docker_db.sh postgresql_9_5
elif [ "$RDBMS" == 'db2' ]; then
bash ../docker_db.sh db2
elif [ "$RDBMS" == 'oracle' ]; then
bash ../docker_db.sh oracle
elif [ "$RDBMS" == 'mssql' ]; then
bash ../docker_db.sh mssql
fi
exec bash ./build.sh

18
ci/build.sh Normal file
View File

@ -0,0 +1,18 @@
#! /bin/bash
goal=
if [ "$RDBMS" == "derby" ]; then
goal="-Pdb=derby"
elif [ "$RDBMS" == "mariadb" ]; then
goal="-Pdb=mariadb"
elif [ "$RDBMS" == "postgresql" ]; then
goal="-Pdb=pgsql"
elif [ "$RDBMS" == "oracle" ]; then
goal="-Pdb=oracle -Dhibernate.connection.url=jdbc:oracle:thin:@localhost:1521:XE -Dhibernate.connection.username=SYSTEM -Dhibernate.connection.password=Oracle18"
elif [ "$RDBMS" == "db2" ]; then
goal="-Pdb=db2 -Dhibernate.connection.url=jdbc:db2://localhost:50000/orm_test -Dhibernate.connection.username=orm_test -Dhibernate.connection.password=orm_test"
elif [ "$RDBMS" == "mssql" ]; then
goal="-Pdb=mssql -Dhibernate.connection.url=jdbc:sqlserver://localhost:1433;databaseName= -Dhibernate.connection.username=sa -Dhibernate.connection.password=hibernate_orm_test"
fi
exec ./gradlew check ${goal} -Plog-test-progress=true --stacktrace

View File

@ -0,0 +1,8 @@
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
jdbcDependency 'com.ibm.db2:jcc:11.5.4.0'

View File

@ -0,0 +1,26 @@
#
# Hibernate, Relational Persistence for Idiomatic Java
#
# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
#
hibernate.dialect org.hibernate.dialect.DB2Dialect
hibernate.connection.driver_class com.ibm.db2.jcc.DB2Driver
hibernate.connection.url jdbc:db2://localhost:50000/orm_test
hibernate.connection.username orm_test
hibernate.connection.password orm_test
hibernate.connection.pool_size 5
hibernate.show_sql false
hibernate.format_sql true
hibernate.max_fetch_depth 5
hibernate.cache.region_prefix hibernate.test
hibernate.cache.region.factory_class org.hibernate.testing.cache.CachingRegionFactory
javax.persistence.validation.mode=NONE
hibernate.service.allow_crawling=false
hibernate.session.events.log=true

View File

@ -5,10 +5,4 @@
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
*/
jdbcDependency 'com.microsoft.sqlserver:mssql-jdbc:6.4.0.jre8'

View File

@ -5,13 +5,6 @@
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
#
#
# Hibernate, Relational Persistence for Idiomatic Java
#
# License: GNU Lesser General Public License (LGPL), version 2.1 or later.
# See the lgpl.txt file in the root directory or <http://www.gnu.org/licenses/lgpl-2.1.html>.
#
hibernate.dialect org.hibernate.dialect.SQLServer2012Dialect
hibernate.connection.driver_class com.microsoft.sqlserver.jdbc.SQLServerDriver
hibernate.connection.url jdbc:sqlserver://hibernate-testing-mssql-express.ccuzkqo3zqzq.us-east-1.rds.amazonaws.com

60
docker_db.sh Executable file
View File

@ -0,0 +1,60 @@
#! /bin/bash
mysql_5_7() {
docker rm -f mysql || true
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -p3306:3306 -d mysql:5.7 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
}
mysql_8_0() {
docker rm -f mysql || true
docker run --name mysql -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -p3306:3306 -d mysql:8.0.21 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
}
mariadb() {
docker rm -f mariadb || true
docker run --name mariadb -e MYSQL_USER=hibernate_orm_test -e MYSQL_PASSWORD=hibernate_orm_test -e MYSQL_DATABASE=hibernate_orm_test -p3306:3306 -d mariadb:10.5.8 --character-set-server=utf8mb4 --collation-server=utf8mb4_unicode_ci
}
postgresql_9_5() {
docker rm -f postgres || true
docker run --name postgres -e POSTGRES_USER=hibernate_orm_test -e POSTGRES_PASSWORD=hibernate_orm_test -e POSTGRES_DB=hibernate_orm_test -p5432:5432 -d postgres:9.5
}
db2() {
docker rm -f db2 || true
docker run --name db2 --privileged -e DB2INSTANCE=orm_test -e DB2INST1_PASSWORD=orm_test -e DBNAME=orm_test -e LICENSE=accept -p 50000:50000 -d ibmcom/db2:11.5.0.0a
# Give the container some time to start
OUTPUT=
while [[ $OUTPUT != *"Setup has completed"* ]]; do
echo "Waiting for DB2 to start..."
sleep 10
OUTPUT=$(docker logs db2)
done
docker exec -t db2 su - orm_test bash -c ". /database/config/orm_test/sqllib/db2profile && /database/config/orm_test/sqllib/bin/db2 'connect to orm_test' && /database/config/orm_test/sqllib/bin/db2 'CREATE USER TEMPORARY TABLESPACE usr_tbsp MANAGED BY AUTOMATIC STORAGE'"
}
mssql() {
docker rm -f mssql || true
docker run --name mssql -d -p 1433:1433 -e "SA_PASSWORD=hibernate_orm_test" -e ACCEPT_EULA=Y microsoft/mssql-server-linux:2017-CU13
}
oracle() {
docker rm -f oracle || true
# We need to use the defaults
# SYSTEM/Oracle18
docker run --shm-size=1536m --name oracle -d -p 1521:1521 quillbuilduser/oracle-18-xe
}
if [ -z ${1} ]; then
echo "No db name provided"
echo "Provide one of:"
echo -e "\tmysql_5_7"
echo -e "\tmysql_8_0"
echo -e "\tmariadb"
echo -e "\tpostgresql_9_5"
echo -e "\tdb2"
echo -e "\tmssql"
echo -e "\toracle"
else
${1}
fi

View File

@ -118,7 +118,7 @@ ext {
oracle: 'com.oracle.database.jdbc:ojdbc8:19.8.0.0',
mssql: 'com.microsoft.sqlserver:mssql-jdbc:7.2.1.jre8',
db2: 'com.ibm.db2:db2jcc:10.5',
db2: 'com.ibm.db2:jcc:11.5.4.0',
hana: 'com.sap.cloud.db.jdbc:ngdbc:2.4.59',
jodaTime: "joda-time:joda-time:${jodaTimeVersion}",