Skip to content

Commit

Permalink
Feature/sqlite support (#4)
Browse files Browse the repository at this point in the history
* feat: add sqlite support

* test: test enabling postgres

* chore: update tests

* chore: remove network

* chore: test

* fix: rename variable

* chore: remove debug log

* chore: version bump

* chore: bump libs
  • Loading branch information
jkoenig134 authored Oct 16, 2023
1 parent bbe8faf commit e6f837c
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 18 deletions.
25 changes: 23 additions & 2 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Start FerretDB
uses: ./

Expand All @@ -29,7 +29,7 @@ jobs:

steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4
- name: Start FerretDB
uses: ./
with:
Expand All @@ -42,3 +42,24 @@ jobs:

- run: npm install
- run: PORT=12345 npm test

postgres-enabled:
name: Start FerretDB with Postgres

runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4
- name: Start FerretDB
uses: ./
with:
use-postgres: "true"

- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- run: npm install
- run: npm test
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ jobs:
node-version: 18

- name: Start FerretDB
uses: js-soft/ferretdb-github-action@1.0.2
uses: js-soft/ferretdb-github-action@1.1.0
with:
ferretdb-version: 0.8.1
ferretdb-version: 1.12.1

- run: npm install
- run: npm test
Expand Down
6 changes: 6 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,16 @@ inputs:
required: false
default: "disabled"

use-postgres:
description: 'Configure FerretDB to use PostgreSQL (default "disabled")'
required: false
default: "false"

runs:
using: "docker"
image: "Dockerfile"
args:
- ${{ inputs.ferretdb-version }}
- ${{ inputs.ferretdb-port }}
- ${{ inputs.ferretdb-telemetry }}
- ${{ inputs.use-postgres }}
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@js-soft/ferretdb-github-action",
"version": "1.0.2",
"version": "1.1.0",
"description": "FerretDB GitHub Action",
"keywords": [
"github",
Expand All @@ -21,8 +21,8 @@
"test": "uvu"
},
"devDependencies": {
"expect": "~29.3.1",
"mongoose": "~6.7.3",
"expect": "~29.7.0",
"mongoose": "~7.6.2",
"uvu": "~0.5.6"
},
"engines": {
Expand Down
36 changes: 25 additions & 11 deletions start-ferretdb.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,36 @@
FERRETDB_VERSION=$1
FERRETDB_PORT=$2
FERRETDB_TELEMETRY=$3
USE_POSTGRES=$4

echo "Starting FerretDB version ${FERRETDB_VERSION} on port ${FERRETDB_PORT}"

docker network create ferretdb
if [ "$USE_POSTGRES" = "true" ]; then
echo "Starting FerretDB with Postgres"

docker run --network ferretdb --name postgres \
-e POSTGRES_USER=username \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=ferretdb \
-d postgres
docker network create ferretdb

docker run --network ferretdb --name ferretdb \
-p $FERRETDB_PORT:27017 \
-e FERRETDB_POSTGRESQL_URL=postgres://username:password@postgres:5432/ferretdb?pool_max_conns=40 \
-e FERRETDB_TELEMETRY=$FERRETDB_TELEMETRY \
-d ghcr.io/ferretdb/ferretdb:$FERRETDB_VERSION
docker run --network ferretdb --name postgres \
-e POSTGRES_USER=username \
-e POSTGRES_PASSWORD=password \
-e POSTGRES_DB=ferretdb \
-d postgres

docker run --network ferretdb --name ferretdb \
-p $FERRETDB_PORT:27017 \
-e FERRETDB_POSTGRESQL_URL=postgres://username:password@postgres:5432/ferretdb?pool_max_conns=40 \
-e FERRETDB_TELEMETRY=$FERRETDB_TELEMETRY \
-d ghcr.io/ferretdb/ferretdb:$FERRETDB_VERSION
else
echo "Starting FerretDB with sqlite"

docker run --name ferretdb \
-p $FERRETDB_PORT:27017 \
-e FERRETDB_HANDLER=sqlite \
-e FERRETDB_SQLITE_URL=file:./ \
-e FERRETDB_TELEMETRY=$FERRETDB_TELEMETRY \
-d ghcr.io/ferretdb/ferretdb:$FERRETDB_VERSION
fi

if [ $? -ne 0 ]; then
echo "Error starting FerretDB Docker container"
Expand Down

0 comments on commit e6f837c

Please sign in to comment.