From 917457f36d2d753af60bfc55cd353cca2d1e702d Mon Sep 17 00:00:00 2001 From: Christian Beikov Date: Thu, 21 Sep 2023 15:42:43 +0200 Subject: [PATCH] HHH-17237 Add Atlas workflow --- .github/workflows/atlas.yml | 88 +++++++++++++++++++++++++++++++++++++ ci/build.sh | 28 ++++++++++++ ci/database-start.sh | 8 ++++ docker_db.sh | 53 ++++++++++++++++++++++ gradle/databases.gradle | 41 ++++++++++++++++- 5 files changed, 216 insertions(+), 2 deletions(-) create mode 100644 .github/workflows/atlas.yml diff --git a/.github/workflows/atlas.yml b/.github/workflows/atlas.yml new file mode 100644 index 0000000000..c1d7504839 --- /dev/null +++ b/.github/workflows/atlas.yml @@ -0,0 +1,88 @@ +# The main CI of Hibernate ORM is https://ci.hibernate.org/job/hibernate-orm-pipeline/. +# 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 build-Atlas + +on: + push: + branches: + - '6.2' + pull_request: + branches: + - '6.2' + +permissions: {} # none + +# 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") or pull request. + group: "workflow = ${{ github.workflow }}, ref = ${{ github.event.ref }}, pr = ${{ github.event.pull_request.id }}" + # 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-orm' }} + +jobs: + build: + permissions: + contents: read + name: Java 11 + # runs-on: ubuntu-latest + runs-on: [self-hosted, Linux, X64, OCI] + strategy: + fail-fast: false + matrix: + include: + - rdbms: oracle_atps + - rdbms: oracle_db19c + - rdbms: oracle_db21c + - rdbms: oracle_db23c + steps: + - uses: actions/checkout@v3 + with: + persist-credentials: false + - name: Reclaim Disk Space + run: .github/ci-prerequisites.sh + - name: Start database + env: + RDBMS: ${{ matrix.rdbms }} + RUNID: ${{ github.run_number }} + run: ci/database-start.sh + - name: Set up Java 11 + uses: actions/setup-java@v3 + with: + distribution: 'temurin' + java-version: '11' + - name: Get year/month for cache key + id: get-date + run: echo "yearmonth=$(/bin/date -u "+%Y-%m")" >> $GITHUB_OUTPUT + shell: bash + - name: Cache Maven local repository + uses: actions/cache@v3 + 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 }} + RUNID: ${{ github.run_number }} + run: ./ci/build-github.sh + shell: bash + - name: Upload test reports (if Gradle failed) + uses: actions/upload-artifact@v3 + if: failure() + with: + name: test-reports-java11-${{ matrix.rdbms }} + path: | + ./**/target/reports/tests/ + ./**/target/reports/checkstyle/ + - name: Omit produced artifacts from build cache + run: ./ci/before-cache.sh \ No newline at end of file diff --git a/ci/build.sh b/ci/build.sh index b511fd0b88..05ce725ac4 100755 --- a/ci/build.sh +++ b/ci/build.sh @@ -20,6 +20,34 @@ elif [ "$RDBMS" == "edb" ] || [ "$RDBMS" == "edb_10" ]; then goal="-Pdb=edb_ci -DdbHost=localhost:5444" elif [ "$RDBMS" == "oracle" ]; then goal="-Pdb=oracle_ci" +elif [ "$RDBMS" == "oracle_atps" ]; then + echo "Managing Oracle Autonomous Database..." + export INFO=$(curl -s -k -L -X GET "https://api.atlas-controller.oraclecloud.com/ords/atlas/admin/database?type=autonomous&hostname=`hostname`" -H 'accept: application/json') + export HOST=$(echo $INFO | jq -r '.database' | jq -r '.host') + export SERVICE=$(echo $INFO | jq -r '.database' | jq -r '.service') + # I have no idea why, but these tests don't seem to work on CI... + goal="-Pdb=oracle_cloud_autonomous_tls -DrunID=$RUNID -DdbHost=$HOST -DdbService=$SERVICE" +elif [ "$RDBMS" == "oracle_db19c" ]; then + echo "Managing Oracle Database 19c..." + export INFO=$(curl -s -k -L -X GET "https://api.atlas-controller.oraclecloud.com/ords/atlas/admin/database?type=db19c&hostname=`hostname`" -H 'accept: application/json') + export HOST=$(echo $INFO | jq -r '.database' | jq -r '.host') + export SERVICE=$(echo $INFO | jq -r '.database' | jq -r '.service') + # I have no idea why, but these tests don't seem to work on CI... + goal="-Pdb=oracle_cloud_db19c -DrunID=$RUNID -DdbHost=$HOST -DdbService=$SERVICE" +elif [ "$RDBMS" == "oracle_db21c" ]; then + echo "Managing Oracle Database 21c..." + export INFO=$(curl -s -k -L -X GET "https://api.atlas-controller.oraclecloud.com/ords/atlas/admin/database?type=db21c&hostname=`hostname`" -H 'accept: application/json') + export HOST=$(echo $INFO | jq -r '.database' | jq -r '.host') + export SERVICE=$(echo $INFO | jq -r '.database' | jq -r '.service') + # I have no idea why, but these tests don't seem to work on CI... + goal="-Pdb=oracle_cloud_db21c -DrunID=$RUNID -DdbHost=$HOST -DdbService=$SERVICE" +elif [ "$RDBMS" == "oracle_db23c" ]; then + echo "Managing Oracle Database 23c..." + export INFO=$(curl -s -k -L -X GET "https://api.atlas-controller.oraclecloud.com/ords/atlas/admin/database?type=db23c&hostname=`hostname`" -H 'accept: application/json') + export HOST=$(echo $INFO | jq -r '.database' | jq -r '.host') + export SERVICE=$(echo $INFO | jq -r '.database' | jq -r '.service') + # I have no idea why, but these tests don't seem to work on CI... + goal="-Pdb=oracle_cloud_db23c -DrunID=$RUNID -DdbHost=$HOST -DdbService=$SERVICE" elif [ "$RDBMS" == "oracle_11_2" ]; then goal="-Pdb=oracle_legacy_ci" elif [ "$RDBMS" == "db2" ]; then diff --git a/ci/database-start.sh b/ci/database-start.sh index a1baf2444b..433bd1f420 100755 --- a/ci/database-start.sh +++ b/ci/database-start.sh @@ -14,6 +14,14 @@ elif [ "$RDBMS" == 'db2' ]; then bash $DIR/../docker_db.sh db2 elif [ "$RDBMS" == 'oracle' ]; then bash $DIR/../docker_db.sh oracle +elif [ "$RDBMS" == 'oracle_atps' ]; then + bash $DIR/../docker_db.sh oracle_atps +elif [ "$RDBMS" == 'oracle_db19c' ]; then + bash $DIR/../docker_db.sh oracle_db19c +elif [ "$RDBMS" == 'oracle_db21c' ]; then + bash $DIR/../docker_db.sh oracle_db21c +elif [ "$RDBMS" == 'oracle_db23c' ]; then + bash $DIR/../docker_db.sh oracle_db23c elif [ "$RDBMS" == 'mssql' ]; then bash $DIR/../docker_db.sh mssql elif [ "$RDBMS" == 'sybase' ]; then diff --git a/docker_db.sh b/docker_db.sh index eb39b809f4..da07e06dfd 100755 --- a/docker_db.sh +++ b/docker_db.sh @@ -646,6 +646,59 @@ disable_userland_proxy() { fi } +oracle_atps() { + echo "Managing Oracle Autonomous Database..." + export INFO=$(curl -s -k -L -X GET "https://api.atlas-controller.oraclecloud.com/ords/atlas/admin/database?type=autonomous&hostname=`hostname`" -H 'accept: application/json') + export HOST=$(echo $INFO | jq -r '.database' | jq -r '.host') + export SERVICE=$(echo $INFO | jq -r '.database' | jq -r '.service') + export PASSWORD=$(echo $INFO | jq -r '.database' | jq -r '.password') + + curl -s -X POST "https://${HOST}.oraclecloudapps.com/ords/admin/_/sql" -H 'content-type: application/sql' -H 'accept: application/json' -basic -u admin:${PASSWORD} --data-ascii "create user hibernate_orm_test_$RUNID identified by \"Oracle_19_Password\" DEFAULT TABLESPACE DATA TEMPORARY TABLESPACE TEMP;alter user hibernate_orm_test_$RUNID quota unlimited on data;grant pdb_dba to hibernate_orm_test_$RUNID;BEGIN ords_admin.enable_schema(p_enabled => TRUE, p_schema => 'hibernate_orm_test_$RUNID', p_url_mapping_type => 'BASE_PATH', p_url_mapping_pattern => 'hibernate_orm_test_$RUNID', p_auto_rest_auth => TRUE); END;" +} + +oracle_db19c() { + echo "Managing Oracle Database 19c..." + export INFO=$(curl -s -k -L -X GET "https://api.atlas-controller.oraclecloud.com/ords/atlas/admin/database?type=db19c&hostname=`hostname`" -H 'accept: application/json') + export HOST=$(echo $INFO | jq -r '.database' | jq -r '.host') + export SERVICE=$(echo $INFO | jq -r '.database' | jq -r '.service') + export PASSWORD=$(echo $INFO | jq -r '.database' | jq -r '.password') + +/home/opc/sqlcl/bin/sql -s system/$PASSWORD@$HOST:1521/$SERVICE <