From b63b7fad9908df063c794cf745262f487f92bc73 Mon Sep 17 00:00:00 2001 From: shelly-li-sl Date: Wed, 17 Sep 2025 00:15:33 +0000 Subject: [PATCH 1/6] fix json test --- tests/json_bulk_test.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/json_bulk_test.go b/tests/json_bulk_test.go index e0a2eef..81cf099 100644 --- a/tests/json_bulk_test.go +++ b/tests/json_bulk_test.go @@ -56,7 +56,7 @@ func TestBasicCRUD_JSONText(t *testing.T) { } DB.Migrator().DropTable(&JsonRecord{}) - if err := DB.AutoMigrate(&JsonRecord{}); err != nil { + if err := DB.Set("gorm:table_options", "TABLESPACE SYSAUX").AutoMigrate(&JsonRecord{}); err != nil { t.Fatalf("migrate failed: %v", err) } From 07240f6ac7fff4e469773319bdb8d9f406a579c9 Mon Sep 17 00:00:00 2001 From: shelly-li-sl Date: Wed, 17 Sep 2025 00:39:47 +0000 Subject: [PATCH 2/6] setup tablespace in workflow --- .github/workflows/run-tests.yaml | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index da491b5..8996b03 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -38,6 +38,34 @@ jobs: # Update the runtime link path echo "/home/runner/work/_temp/instantclient_23_9" | sudo tee /etc/ld.so.conf.d/oracle-instantclient.conf sudo ldconfig + + - name: Wait for Oracle to be ready + run: | + # Wait until Oracle is accepting connections + for i in {1..30}; do + if docker exec $(docker ps -qf "ancestor=gvenzl/oracle-free:latest") \ + bash -c "echo exit | sqlplus -s / as sysdba" >/dev/null 2>&1; then + echo "Oracle is ready!" + break + fi + echo "Waiting for Oracle..." + sleep 10 + done + + - name: Get SYS password from Oracle logs + id: get-sys-pass + run: | + CONTAINER_ID=$(docker ps -qf "ancestor=gvenzl/oracle-free:latest") + SYS_PASS=$(docker logs $CONTAINER_ID 2>&1 | grep "DATABASE IS READY TO USE!" -B20 | grep "SYS Password:" | awk '{print $3}') + echo "SYS_PASS=$SYS_PASS" >> $GITHUB_ENV + + - name: Create tablespace and grant user access + run: | + cat <<'EOF' > alter_user.sql + ALTER USER $GORM_ORACLEDB_USER QUOTA UNLIMITED ON SYSAUX; + EOF + + $GORM_ORACLEDB_LIBDIR/sqlplus -s sys/${SYS_PASS}@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA @alter_user.sql - name: Checkout uses: actions/checkout@v4 From 69b2669f9f454ef5a041e40b113a6f49d9039c19 Mon Sep 17 00:00:00 2001 From: shelly-li-sl Date: Wed, 17 Sep 2025 00:43:42 +0000 Subject: [PATCH 3/6] add sqlplus package --- .github/workflows/run-tests.yaml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 8996b03..80b44fe 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -29,10 +29,12 @@ jobs: - name: Install Oracle Instant Client run: | cd $RUNNER_TEMP - # Download the desired Oracle Instant Client zip files + # Download the desired Oracle Instant Client zip files and SQL*Plus packages curl -sSfLO "https://download.oracle.com/otn_software/linux/instantclient/2390000/instantclient-basic-linux.x64-23.9.0.25.07.zip" + curl -sSfLO "https://download.oracle.com/otn_software/linux/instantclient/2390000/instantclient-sqlplus-linux.x64-23.9.0.25.07.zip" # Unzip the packages into a single directory unzip -q -o "instantclient-basic-linux.x64-23.9.0.25.07.zip" + unzip -q -o "instantclient-sqlplus-linux.x64-23.9.0.25.07.zip" # Install the operating system libaio package sudo ln -s /usr/lib/x86_64-linux-gnu/libaio.so.1t64 /usr/lib/libaio.so.1 # Update the runtime link path @@ -59,7 +61,7 @@ jobs: SYS_PASS=$(docker logs $CONTAINER_ID 2>&1 | grep "DATABASE IS READY TO USE!" -B20 | grep "SYS Password:" | awk '{print $3}') echo "SYS_PASS=$SYS_PASS" >> $GITHUB_ENV - - name: Create tablespace and grant user access + - name: Alter user quota on tablespace SYSAUX run: | cat <<'EOF' > alter_user.sql ALTER USER $GORM_ORACLEDB_USER QUOTA UNLIMITED ON SYSAUX; From 370af7b463f3ab2de73e845c91c93fa01258f6f2 Mon Sep 17 00:00:00 2001 From: shelly-li-sl Date: Wed, 17 Sep 2025 00:50:08 +0000 Subject: [PATCH 4/6] fix sys user --- .github/workflows/run-tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 80b44fe..5839d20 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -63,11 +63,11 @@ jobs: - name: Alter user quota on tablespace SYSAUX run: | - cat <<'EOF' > alter_user.sql + cat < alter_user.sql ALTER USER $GORM_ORACLEDB_USER QUOTA UNLIMITED ON SYSAUX; EOF - $GORM_ORACLEDB_LIBDIR/sqlplus -s sys/${SYS_PASS}@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA @alter_user.sql + $GORM_ORACLEDB_LIBDIR/sqlplus -s "sys/$SYS_PASS@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA" @alter_user.sql - name: Checkout uses: actions/checkout@v4 From 37d7d94dc83e5c9d7494e024e92d4b3f63780276 Mon Sep 17 00:00:00 2001 From: shelly-li-sl Date: Wed, 17 Sep 2025 00:53:26 +0000 Subject: [PATCH 5/6] fix sys password --- .github/workflows/run-tests.yaml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index 5839d20..c1da347 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -16,7 +16,7 @@ jobs: env: APP_USER: ${{ env.GORM_ORACLEDB_USER }} APP_USER_PASSWORD: ${{ env.GORM_ORACLEDB_PASSWORD }} - ORACLE_RANDOM_PASSWORD: yes + ORACLE_PASSWORD: oracle ports: - 1521:1521 steps: @@ -54,20 +54,13 @@ jobs: sleep 10 done - - name: Get SYS password from Oracle logs - id: get-sys-pass - run: | - CONTAINER_ID=$(docker ps -qf "ancestor=gvenzl/oracle-free:latest") - SYS_PASS=$(docker logs $CONTAINER_ID 2>&1 | grep "DATABASE IS READY TO USE!" -B20 | grep "SYS Password:" | awk '{print $3}') - echo "SYS_PASS=$SYS_PASS" >> $GITHUB_ENV - - name: Alter user quota on tablespace SYSAUX run: | cat < alter_user.sql ALTER USER $GORM_ORACLEDB_USER QUOTA UNLIMITED ON SYSAUX; EOF - $GORM_ORACLEDB_LIBDIR/sqlplus -s "sys/$SYS_PASS@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA" @alter_user.sql + $GORM_ORACLEDB_LIBDIR/sqlplus -s "sys/oracle@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA" @alter_user.sql - name: Checkout uses: actions/checkout@v4 From 61f75732e581988d68eb4e9d68e72ffdb0d2b201 Mon Sep 17 00:00:00 2001 From: shelly-li-sl Date: Wed, 17 Sep 2025 20:19:05 +0000 Subject: [PATCH 6/6] use GORM_SYS_PASSOWRD for sys password --- .github/workflows/run-tests.yaml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.github/workflows/run-tests.yaml b/.github/workflows/run-tests.yaml index c1da347..846c69d 100644 --- a/.github/workflows/run-tests.yaml +++ b/.github/workflows/run-tests.yaml @@ -9,6 +9,7 @@ jobs: GORM_ORACLEDB_USER: ${{ secrets.GORM_ORACLEDB_USER }} GORM_ORACLEDB_PASSWORD: ${{ secrets.GORM_ORACLEDB_PASSWORD }} GORM_ORACLEDB_CONNECTSTRING: ${{ secrets.GORM_ORACLEDB_CONNECTSTRING }} + GORM_SYS_PASSOWRD: ${{ secrets.GORM_SYS_PASSOWRD }} GORM_ORACLEDB_LIBDIR: /home/runner/work/_temp/instantclient_23_9 services: oracle: @@ -16,7 +17,7 @@ jobs: env: APP_USER: ${{ env.GORM_ORACLEDB_USER }} APP_USER_PASSWORD: ${{ env.GORM_ORACLEDB_PASSWORD }} - ORACLE_PASSWORD: oracle + ORACLE_PASSWORD: ${{ env.GORM_SYS_PASSOWRD }} ports: - 1521:1521 steps: @@ -60,7 +61,7 @@ jobs: ALTER USER $GORM_ORACLEDB_USER QUOTA UNLIMITED ON SYSAUX; EOF - $GORM_ORACLEDB_LIBDIR/sqlplus -s "sys/oracle@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA" @alter_user.sql + $GORM_ORACLEDB_LIBDIR/sqlplus -s "sys/${GORM_SYS_PASSOWRD}@${GORM_ORACLEDB_CONNECTSTRING} AS SYSDBA" @alter_user.sql - name: Checkout uses: actions/checkout@v4