Skip to content

Commit

Permalink
feat: add standalone SQLite backed denokv server (#14)
Browse files Browse the repository at this point in the history
This is a standalone Deno KV server backed by SQLite. It exposes a HTTP
API that implements the KV Connect protocol and can be used from
the Deno CLI.

The server can be connected to from multiple clients at the same time,
which enables a simple way to self host a production ready Deno KV
database.
  • Loading branch information
lucacasonato committed Nov 3, 2023
1 parent 5fc6a0a commit 40b67f3
Show file tree
Hide file tree
Showing 14 changed files with 1,584 additions and 74 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
target/
75 changes: 65 additions & 10 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,38 +13,93 @@ env:

jobs:
test:
runs-on: ubuntu-latest
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, macos-latest, windows-latest]

steps:
- uses: actions/checkout@v3

- name: Install Rust
uses: dsherret/rust-toolchain-file@v1

- uses: Swatinem/rust-cache@v2

- name: Install protoc
uses: arduino/setup-protoc@v2
with:
version: "21.12"
token: ${{ secrets.GITHUB_TOKEN }}

- name: Check formatting
run: cargo fmt -- --check

- name: Check linting
run: cargo clippy --all-targets --all-features -- -D clippy::all
run: cargo clippy --release --all-targets --all-features -- -D clippy::all

- name: Build
run: cargo build --all-targets --all-features --tests -v
run: cargo build --release --all-targets --all-features --tests -v

- name: Test
run: cargo test
run: cargo test --release -- --nocapture

- name: Prepare artifact (Linux)
if: runner.os == 'Linux'
run: |-
cd target/release
zip -r denokv-x86_64-unknown-linux-gnu.zip denokv
- name: Prepare artifact (macOS)
if: runner.os == 'macOS'
run: |-
cd target/release
zip -r denokv-x86_64-apple-darwin.zip denokv
- name: Prepare artifact (Windows)
if: runner.os == 'Windows'
run: |-
Compress-Archive -CompressionLevel Optimal -Force -Path target/release/denokv.exe -DestinationPath target/release/denokv-x86_64-pc-windows-msvc.zip
- name: Upload artifact (Linux)
if: runner.os == 'Linux'
uses: actions/upload-artifact@v3
with:
name: denokv-x86_64-unknown-linux-gnu.zip
path: target/release/denokv-x86_64-unknown-linux-gnu.zip

- name: Upload artifact (macOS)
if: runner.os == 'macOS'
uses: actions/upload-artifact@v3
with:
name: denokv-x86_64-apple-darwin.zip
path: target/release/denokv-x86_64-apple-darwin.zip

- name: Upload artifact (Windows)
if: runner.os == 'Windows'
uses: actions/upload-artifact@v3
with:
name: denokv-x86_64-pc-windows-msvc.zip
path: target/release/denokv-x86_64-pc-windows-msvc.zip

- name: Upload release to GitHub
uses: softprops/[email protected]
if: github.repository == 'denoland/denokv' && startsWith(github.ref, 'refs/tags/')
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
with:
files: |-
target/release/denokv-x86_64-pc-windows-msvc.zip
target/release/denokv-x86_64-unknown-linux-gnu.zip
target/release/denokv-x86_64-apple-darwin.zip
draft: true

- name: Publish
if: |
runner.os == 'Linux' &&
github.repository == 'denoland/denokv' &&
startsWith(github.ref, 'refs/tags/')
- name: Publish to crates.io
if: runner.os == 'Linux' && github.repository == 'denoland/denokv' && startsWith(github.ref, 'refs/tags/')
env:
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}
run: |
run: |-
cargo publish -vv -p denokv_proto
cargo publish -vv -p denokv_sqlite
cargo publish -vv -p denokv_remote
cargo publish -vv -p denokv
39 changes: 39 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: docker

on:
push:
branches: ["main"]
tags: ["*"]
pull_request:
branches: ["main"]

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- name: Clone repository
uses: actions/checkout@v3

- name: Build image
run: |
docker build -f Dockerfile -t denokv .
- name: Smoke test image
run: |
docker run -i --init denokv --help
- name: Login to ghcr.io
if: github.repository == 'denoland/denokv' && startsWith(github.ref, 'refs/tags/')
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u $ --password-stdin

- name: Push images
if: github.repository == 'denoland/denokv' && startsWith(github.ref, 'refs/tags/')
run: |
docker tag denokv ghcr.io/denoland/denokv:${GITHUB_REF#refs/*/}
docker push ghcr.io/denoland/denokv:${GITHUB_REF#refs/*/}
docker tag denokv ghcr.io/denoland/denokv:latest
docker push ghcr.io/denoland/denokv:latest
Loading

0 comments on commit 40b67f3

Please sign in to comment.