This is an automated email from the ASF dual-hosted git repository.

xuanwo pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/incubator-opendal.git


The following commit(s) were added to refs/heads/main by this push:
     new 18c5a1878 ci(services/postgresql): add docker-compose to simplify the 
CI (#2877)
18c5a1878 is described below

commit 18c5a1878857b25d2d6b522588a4bb9b292bca51
Author: G-XD <[email protected]>
AuthorDate: Fri Aug 18 23:27:24 2023 +0800

    ci(services/postgresql): add docker-compose to simplify the CI (#2877)
    
    * chore(services/postgresql): add docker-compose
    
    * chore(services/postgresql): fix license check
---
 .github/workflows/service_test_postgresql.yml      | 31 ++++---------------
 .../postgresql/fixtures/docker-compose.yml         | 35 ++++++++++++++++++++++
 core/src/services/postgresql/fixtures/init.sql     | 20 +++++++++++++
 3 files changed, 60 insertions(+), 26 deletions(-)

diff --git a/.github/workflows/service_test_postgresql.yml 
b/.github/workflows/service_test_postgresql.yml
index 2e3eebde9..a4aeb5866 100644
--- a/.github/workflows/service_test_postgresql.yml
+++ b/.github/workflows/service_test_postgresql.yml
@@ -40,39 +40,18 @@ jobs:
   postgresql:
     runs-on: ubuntu-latest
 
-    services:
-      postgres:
-        image: postgres:13
-        env:
-          POSTGRES_USER: user
-          POSTGRES_PASSWORD: password
-          POSTGRES_DB: testdb
-        ports:
-          - 5432:5432
-        # needed because the postgres container does not provide a healthcheck
-        options: >-
-          --health-cmd pg_isready
-          --health-interval 10s
-          --health-timeout 5s
-          --health-retries 5
-
     steps:
       - uses: actions/checkout@v3
+      - name: Setup Postgresql Server
+        shell: bash
+        working-directory: core
+        run: docker-compose -f 
`pwd`/src/services/postgresql/fixtures/docker-compose.yml up -d
+
       - name: Setup Rust toolchain
         uses: ./.github/actions/setup
         with:
           need-nextest: true
 
-      - name: Setup PostgreSQL CLI
-        run: |
-          sudo apt -y install postgresql-client
-          psql -V
-
-      - name: Create table
-        run: |
-          export PGPASSWORD=password
-          psql -h localhost -U user -d testdb -c "CREATE TABLE data (key TEXT 
PRIMARY KEY, value BYTEA);"
-
       - name: Test
         shell: bash
         working-directory: core
diff --git a/core/src/services/postgresql/fixtures/docker-compose.yml 
b/core/src/services/postgresql/fixtures/docker-compose.yml
new file mode 100644
index 000000000..acf4f1171
--- /dev/null
+++ b/core/src/services/postgresql/fixtures/docker-compose.yml
@@ -0,0 +1,35 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+#
+#   http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+version: '3.8'
+
+services:
+  postgres-db:
+    image: postgres:13
+    ports:
+      - 5432:5432
+    environment:
+      - POSTGRES_PASSWORD=password
+      - POSTGRES_USER=user
+      - POSTGRES_DB=testdb
+    volumes:
+        - ./init.sql:/docker-entrypoint-initdb.d/init.sql
+    healthcheck:
+      test: ["CMD-SHELL", "sh -c 'pg_isready -U user -d testdb'"]
+      interval: 3s
+      timeout: 5s
+      retries: 5
diff --git a/core/src/services/postgresql/fixtures/init.sql 
b/core/src/services/postgresql/fixtures/init.sql
new file mode 100644
index 000000000..b6d2c111a
--- /dev/null
+++ b/core/src/services/postgresql/fixtures/init.sql
@@ -0,0 +1,20 @@
+--
+-- Licensed to the Apache Software Foundation (ASF) under one
+-- or more contributor license agreements.  See the NOTICE file
+-- distributed with this work for additional information
+-- regarding copyright ownership.  The ASF licenses this file
+-- to you under the Apache License, Version 2.0 (the
+-- "License"); you may not use this file except in compliance
+-- with the License.  You may obtain a copy of the License at
+--
+--   http://www.apache.org/licenses/LICENSE-2.0
+--
+-- Unless required by applicable law or agreed to in writing,
+-- software distributed under the License is distributed on an
+-- "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+-- KIND, either express or implied.  See the License for the
+-- specific language governing permissions and limitations
+-- under the License.
+--
+
+CREATE TABLE IF NOT EXISTS data (key TEXT PRIMARY KEY, value BYTEA);

Reply via email to