]> git.ipfire.org Git - thirdparty/patchwork.git/commitdiff
ci: Add tests for sqlite3
authorYou-Sheng Yang <vicamo@gmail.com>
Thu, 9 Dec 2021 03:38:42 +0000 (11:38 +0800)
committerStephen Finucane <stephen@that.guru>
Wed, 23 Feb 2022 13:43:59 +0000 (13:43 +0000)
Signed-off-by: You-Sheng Yang <vicamo@gmail.com>
Reviewed-by: Stephen Finucane <stephen@that.guru>
.github/workflows/ci.yaml
docker-compose-sqlite3.yml [new file with mode: 0644]
tools/docker/Dockerfile
tools/docker/entrypoint.sh

index 6e9033deb150a56ded03c81d0d5bda2cefd5f8dc..0818aca5f45e4b9695471e2b3015fa2f4609ddb5 100644 (file)
@@ -24,11 +24,11 @@ jobs:
     strategy:
       matrix:
         python: [3.6, 3.7, 3.8, 3.9]
-        db: [postgres, mysql]
+        db: [postgres, mysql, sqlite3]
     env:
       DATABASE_TYPE: "${{ matrix.db }}"
       DATABASE_HOST: "127.0.0.1"
-      DATABASE_NAME: patchwork
+      DATABASE_NAME: ${{ matrix.db != 'sqlite3' && 'patchwork' || '/dev/shm/patchwork.test.db.sqlite3' }}
       DATABASE_USER: patchwork
       DATABASE_PASSWORD: password
       MYSQL_ROOT_PASSWORD: root
@@ -115,9 +115,9 @@ jobs:
     runs-on: ubuntu-latest
     strategy:
       matrix:
-        db: [postgres, mysql]
+        db: [postgres, mysql, sqlite3]
     env:
-      COMPOSE_FILE: ${{ matrix.db == 'mysql' && 'docker-compose.yml' || 'docker-compose-pg.yml' }}
+      COMPOSE_FILE: ${{ matrix.db == 'mysql' && 'docker-compose.yml' || (matrix.db == 'postgres' && 'docker-compose-pg.yml') || 'docker-compose-sqlite3.yml' }}
     steps:
       - name: Checkout source code
         uses: actions/checkout@v2
diff --git a/docker-compose-sqlite3.yml b/docker-compose-sqlite3.yml
new file mode 100644 (file)
index 0000000..d4c6659
--- /dev/null
@@ -0,0 +1,19 @@
+version: "3"
+services:
+  web:
+    build:
+      context: .
+      dockerfile: ./tools/docker/Dockerfile
+      args:
+        - UID
+        - GID
+    command: python3 manage.py runserver 0.0.0.0:8000
+    volumes:
+      - .:/home/patchwork/patchwork/
+    ports:
+      - "8000:8000"
+    environment:
+      - UID
+      - GID
+      - DATABASE_TYPE=sqlite3
+      - DATABASE_NAME=/home/patchwork/patchwork/tools/docker/db/db.sqlite3
index ceacc0911db948ab7ef06ab878f71310c01fc1fb..79902d7415862000d0f46ed97c66767268648959 100644 (file)
@@ -26,6 +26,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \
     libsqlite3-dev \
     mariadb-client \
     postgresql-client \
+    sqlite3 \
     tzdata \
     && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*
 
index d1bad8259857ad60bea7e264d5f5526bd7a5891e..48d7aa27dec11fdbe690211163d89660706265fc 100755 (executable)
@@ -3,18 +3,22 @@ set -euo pipefail
 
 export DATABASE_HOST=${DATABASE_HOST:-}
 export DATABASE_PORT=${DATABASE_PORT:-}
-export DATABASE_NAME=${DATABASE_NAME:-patchwork}
 export DATABASE_USER=${DATABASE_USER:-patchwork}
 export DATABASE_PASSWORD=${DATABASE_PASSWORD:-password}
 
 case "${DATABASE_TYPE:-}" in
 postgres)
+    export DATABASE_NAME=${DATABASE_NAME:-patchwork}
     export PGPORT=${DATABASE_PORT}
     export PGPASSWORD=${DATABASE_PASSWORD}
     psql_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} "--username=${DATABASE_USER}" )
     ;;
+sqlite3)
+    export DATABASE_NAME=${DATABASE_NAME:-/dev/shm/patchwork.db.sqlite3}
+    ;;
 *)
     export DATABASE_TYPE=mysql
+    export DATABASE_NAME=${DATABASE_NAME:-patchwork}
     mysql_args=( ${DATABASE_HOST:+--host=${DATABASE_HOST}} ${DATABASE_PORT:+--port=${DATABASE_PORT}} "--user=${DATABASE_USER}" "--password=${DATABASE_PASSWORD}" )
     ;;
 esac
@@ -22,11 +26,14 @@ esac
 # functions
 
 test_database() {
-    if [ ${DATABASE_TYPE} = "postgres" ]; then
-        echo ';' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null
-    else
-        echo ';' | mysql "${mysql_args[@]}" "${DATABASE_NAME}" 2> /dev/null
-    fi
+    case "${DATABASE_TYPE}" in
+    "postgres")
+        echo ';' | psql "${psql_args[@]}" "${DATABASE_NAME}" 2> /dev/null ;;
+    "mysql")
+        echo ';' | mysql "${mysql_args[@]}" "${DATABASE_NAME}" 2> /dev/null ;;
+    "sqlite3")
+        echo ';' | sqlite3 "${DATABASE_NAME}" > /dev/null 2> /dev/null ;;
+    esac
 }
 
 # the script begins!