Skip to content

Commit

Permalink
feat: swapping out a SQLite driver (#70)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHope committed Jun 8, 2024
1 parent 53b0480 commit e59492e
Show file tree
Hide file tree
Showing 7 changed files with 78 additions and 74 deletions.
8 changes: 2 additions & 6 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,21 +10,17 @@ permissions:

jobs:
goreleaser:
runs-on: macos-latest
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set SDK
run: echo "SDK=$(xcrun --sdk macosx --show-sdk-path)" >> $GITHUB_ENV
- name: Install Nix
uses: cachix/install-nix-action@v22
# - name: Setup Docker
# uses: douglascamata/setup-docker-macos-action@v1-alpha
- name: Release
run: |
sudo task release
task release
shell: nix develop --command bash -e {0}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Expand Down
90 changes: 35 additions & 55 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
env:
- CGO_ENABLED=1
- CGO_ENABLED=0

builds:
- id: armaria-darwin-amd64
Expand All @@ -9,13 +9,8 @@ builds:
- amd64
goos:
- darwin
env:
- CC=zig cc -target x86_64-macos -g0 --sysroot={{ .Env.SDK }} -I{{ .Env.SDK }}/usr/include -L{{ .Env.SDK }}/usr/lib -F{{ .Env.SDK }}/System/Library/Frameworks -framework CoreFoundation -Wno-expansion-to-defined -Wno-availability -Wno-nullability-completeness
- CXX=zig c++ -target x86_64-macos -g0 --sysroot={{ .Env.SDK }} -I{{ .Env.SDK }}/usr/include -L{{ .Env.SDK }}/usr/lib -F{{ .Env.SDK }}/System/Library/Frameworks -framework CoreFoundation -Wno-expansion-to-defined -Wno-availability -Wno-nullability-completeness
flags:
- -trimpath
- -tags=fts5
- -buildmode=pie
ldflags:
- -s
- -w
Expand All @@ -28,13 +23,8 @@ builds:
- arm64
goos:
- darwin
env:
- CC=zig cc -target aarch64-macos -g0 --sysroot={{ .Env.SDK }} -I{{ .Env.SDK }}/usr/include -L{{ .Env.SDK }}/usr/lib -F{{ .Env.SDK }}/System/Library/Frameworks -framework CoreFoundation -Wno-expansion-to-defined -Wno-availability -Wno-nullability-completeness
- CXX=zig c++ -target aarch64-macos -g0 --sysroot={{ .Env.SDK }} -I{{ .Env.SDK }}/usr/include -L{{ .Env.SDK }}/usr/lib -F{{ .Env.SDK }}/System/Library/Frameworks -framework CoreFoundation -Wno-expansion-to-defined -Wno-availability -Wno-nullability-completeness
flags:
- -trimpath
- -tags=fts5
- -buildmode=pie
ldflags:
- -s
- -w
Expand All @@ -43,18 +33,12 @@ builds:
- id: armaria-linux-amd64
binary: armaria
main: ./cmd/cli
env:
- CC=zig cc -target x86_64-linux-musl -g0
- CXX=zig c++ -target x86_64-linux-musl -g0
# https://github.com/mattn/go-sqlite3/issues/1164
- CGO_CFLAGS="-D_LARGEFILE64_SOURCE"
goarch:
- amd64
goos:
- linux
flags:
- -trimpath
- -tags=fts5
ldflags:
- -s
- -w
Expand All @@ -67,13 +51,9 @@ builds:
- amd64
goos:
- windows
env:
- CC=zig cc -target x86_64-windows-gnu -g0
- CXX=zig c++ -target x86_64-windows-gnu -g0
flags:
- -trimpath
- -buildmode=exe
- -tags=fts5
ldflags:
- -s
- -w
Expand Down Expand Up @@ -137,40 +117,40 @@ release:
extra_files:
- glob: ./**/*.snap

# snapcrafts:
# - id: armaria-snap
# builds:
# - armaria-linux-amd64
# name_template: "armaria_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
# name: armaria
# title: Armaria
# publish: true
# summary: Armaria is a fast, open, and local first bookmarks manager.
# description: Armaria is a FOSS bookmarks manager that keeps all of your local bookmarks in a SQLite database. You can use many different frontends to manage your bookmarks including browsers, and back them up and/or sync them however you see fit.
# confinement: strict
# license: MIT
# base: core18
# extra_files:
# - source: ./art/cabinet-light-128.png
# destination: meta/gui/icon.png
# mode: 0755
# apps:
# armaria:
# command: armaria
# plugs: ["dot-mozilla-native-messaging-hosts", "dot-config-google-chrome-native-messaging-hosts", "dot-config-chromium-native-messaging-hosts"]
# plugs:
# dot-mozilla-native-messaging-hosts:
# interface: personal-files
# write:
# - $HOME/.mozilla/native-messaging-hosts
# dot-config-google-chrome-native-messaging-hosts:
# interface: personal-files
# write:
# - $HOME/.config/google-chrome/NativeMessagingHosts
# dot-config-chromium-native-messaging-hosts:
# interface: personal-files
# write:
# - $HOME/.config/chromium/NativeMessagingHosts
snapcrafts:
- id: armaria-snap
builds:
- armaria-linux-amd64
name_template: "armaria_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
name: armaria
title: Armaria
publish: true
summary: Armaria is a fast, open, and local first bookmarks manager.
description: Armaria is a FOSS bookmarks manager that keeps all of your local bookmarks in a SQLite database. You can use many different frontends to manage your bookmarks including browsers, and back them up and/or sync them however you see fit.
confinement: strict
license: MIT
base: core18
extra_files:
- source: ./art/cabinet-light-128.png
destination: meta/gui/icon.png
mode: 0755
apps:
armaria:
command: armaria
plugs: ["dot-mozilla-native-messaging-hosts", "dot-config-google-chrome-native-messaging-hosts", "dot-config-chromium-native-messaging-hosts"]
plugs:
dot-mozilla-native-messaging-hosts:
interface: personal-files
write:
- $HOME/.mozilla/native-messaging-hosts
dot-config-google-chrome-native-messaging-hosts:
interface: personal-files
write:
- $HOME/.config/google-chrome/NativeMessagingHosts
dot-config-chromium-native-messaging-hosts:
interface: personal-files
write:
- $HOME/.config/chromium/NativeMessagingHosts

winget:
- name: Armaria
Expand Down
2 changes: 2 additions & 0 deletions TODO.org
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@ This is a running list of things that need to taken care of at some point:
- [ ] Long subtract function too complex
- [ ] The native messaging is broken on browsers installed by snap
- this is an issue with the Firefox Snapcraft in particular: https://forum.snapcraft.io/t/firefox-snapcraft-native-messaging-behavior/40437
- [ ] Cross compiling with the mattn driver seems impossible. I would prefer to do it, but I think that is a future problem. I would rather keep the project moving.
- Current issue: https://github.com/ziglang/zig/issues/19400
2 changes: 1 addition & 1 deletion cmd/cli/test/native_host/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ func nativeMessageLoop[T messaging.Payload](kind messaging.MessageKind, payload

// getLastInsertedID gets the ID of the last inserted bookmark.
func getLastInsertedID(dbLocation string, ignoreIds []string) (string, error) {
db, err := sql.Open("sqlite3", dbLocation)
db, err := sql.Open("sqlite", dbLocation)
if err != nil {
return "", err
}
Expand Down
14 changes: 12 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,14 @@ require (
github.com/knadh/koanf/providers/file v0.1.0
github.com/knadh/koanf/providers/structs v0.1.0
github.com/knadh/koanf/v2 v2.1.1
github.com/mattn/go-sqlite3 v1.14.22
github.com/muesli/reflow v0.3.0
github.com/nathan-fiscaletti/consolesize-go v0.0.0-20220204101620-317176b6684d
github.com/nullism/bqb v1.7.2
github.com/pressly/goose/v3 v3.20.0
github.com/samber/lo v1.39.0
golang.org/x/sys v0.20.0
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0
modernc.org/sqlite v1.30.0
)

require (
Expand All @@ -33,6 +34,7 @@ require (
github.com/charmbracelet/x/windows v0.1.2 // indirect
github.com/cucumber/gherkin/go/v26 v26.2.0 // indirect
github.com/cucumber/messages/go/v21 v21.0.1 // indirect
github.com/dustin/go-humanize v1.0.1 // indirect
github.com/erikgeiser/coninput v0.0.0-20211004153227-1c3628e74d0f // indirect
github.com/fatih/structs v1.1.0 // indirect
github.com/fsnotify/fsnotify v1.7.0 // indirect
Expand All @@ -41,6 +43,7 @@ require (
github.com/hashicorp/go-immutable-radix v1.3.1 // indirect
github.com/hashicorp/go-memdb v1.3.4 // indirect
github.com/hashicorp/golang-lru v1.0.2 // indirect
github.com/hashicorp/golang-lru/v2 v2.0.7 // indirect
github.com/knadh/koanf/maps v0.1.1 // indirect
github.com/lucasb-eyer/go-colorful v1.2.0 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
Expand All @@ -52,14 +55,21 @@ require (
github.com/muesli/ansi v0.0.0-20230316100256-276c6243b2f6 // indirect
github.com/muesli/cancelreader v0.2.2 // indirect
github.com/muesli/termenv v0.15.2 // indirect
github.com/ncruces/go-strftime v0.1.9 // indirect
github.com/pelletier/go-toml v1.9.5 // indirect
github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect
github.com/rivo/uniseg v0.4.7 // indirect
github.com/sethvargo/go-retry v0.2.4 // indirect
github.com/spf13/pflag v1.0.5 // indirect
github.com/xo/terminfo v0.0.0-20220910002029-abceb7e1c41e // indirect
go.uber.org/multierr v1.11.0 // indirect
golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d // indirect
golang.org/x/sync v0.7.0 // indirect
golang.org/x/sys v0.20.0 // indirect
golang.org/x/text v0.15.0 // indirect
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 // indirect
modernc.org/libc v1.50.9 // indirect
modernc.org/mathutil v1.6.0 // indirect
modernc.org/memory v1.8.0 // indirect
modernc.org/strutil v1.2.0 // indirect
modernc.org/token v1.1.0 // indirect
)
32 changes: 24 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ github.com/gofrs/uuid v4.4.0+incompatible h1:3qXRTX8/NbyulANqlc0lchS1gqAVxRgsuW1
github.com/gofrs/uuid v4.4.0+incompatible/go.mod h1:b2aQJv3Z4Fp6yNu3cdSllBxTCLRxnplIgP/c0N/04lM=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd h1:gbpYu9NMq8jhDVbvlGkMFWCjLFlqqEZjEmObmhUy6Vo=
github.com/google/pprof v0.0.0-20240409012703-83162a5b38cd/go.mod h1:kf6iHlnVGwgKolg33glAes7Yg/8iWP8ukqeldJSO7jw=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4=
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ=
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
Expand Down Expand Up @@ -92,8 +94,6 @@ github.com/mattn/go-localereader v0.0.1/go.mod h1:8fBrzywKY7BI3czFoHkuzRoWE9C+Ei
github.com/mattn/go-runewidth v0.0.12/go.mod h1:RAqKPSqVFrSLVXbA8x7dzmKdmGzieGRCM46jaSJTDAk=
github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U=
github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w=
github.com/mattn/go-sqlite3 v1.14.22 h1:2gZY6PC6kBnID23Tichd1K+Z0oS6nE/XwU+Vz/5o4kU=
github.com/mattn/go-sqlite3 v1.14.22/go.mod h1:Uh1q+B4BYcTPb+yiD3kU8Ct7aC0hY9fxUwlHK0RXw+Y=
github.com/mfridman/interpolate v0.0.2 h1:pnuTK7MQIxxFz1Gr+rjSIx9u7qVjf5VOoM/u6BbAxPY=
github.com/mfridman/interpolate v0.0.2/go.mod h1:p+7uk6oE07mpE/Ik1b8EckO0O4ZXiGAfshKBWLUM9Xg=
github.com/mitchellh/copystructure v1.2.0 h1:vpKXTN4ewci03Vljg/q9QvCGUDttBOGBIa15WveJJGw=
Expand Down Expand Up @@ -150,6 +150,8 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0=
go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y=
golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d h1:N0hmiNbwsSNwHBAvR3QB5w25pUwH4tK0Y/RltD1j1h4=
golang.org/x/exp v0.0.0-20240525044651-4c93da0ed11d/go.mod h1:XtvwrStGgqGPLc4cjQfWqZHG1YFdYs6swckp8vpsjnc=
golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA=
golang.org/x/mod v0.17.0/go.mod h1:hTbmBsO62+eylJbnUtE2MGJUyE7QWk4xUqPFrRgJ+7c=
golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M=
golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk=
golang.org/x/sys v0.0.0-20210809222454-d867a43fc93e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
Expand All @@ -158,23 +160,37 @@ golang.org/x/sys v0.20.0 h1:Od9JTbYCk261bKm4M/mw7AklTlFYIa0bIp9BgSm1S8Y=
golang.org/x/sys v0.20.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA=
golang.org/x/text v0.15.0 h1:h1V/4gjBv8v9cjcR6+AR5+/cIYK5N/WAgiv4xlsEtAk=
golang.org/x/text v0.15.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU=
golang.org/x/tools v0.21.0 h1:qc0xYgIbsSDt9EyWz05J5wfa7LOVW0YTLOXrqdLAWIw=
golang.org/x/tools v0.21.0/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk=
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0 h1:FVCohIoYO7IJoDDVpV2pdq7SgrMH6wHnuTyrdrxJNoY=
gopkg.in/DATA-DOG/go-sqlmock.v1 v1.3.0/go.mod h1:OdE7CF6DbADk7lN8LIKRzRJTTZXIjtWgA5THM5lhBAw=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q=
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
modernc.org/cc/v4 v4.21.2 h1:dycHFB/jDc3IyacKipCNSDrjIC0Lm1hyoWOZTRR20Lk=
modernc.org/cc/v4 v4.21.2/go.mod h1:HM7VJTZbUCR3rV8EYBi9wxnJ0ZBRiGE5OeGXNA0IsLQ=
modernc.org/ccgo/v4 v4.17.8 h1:yyWBf2ipA0Y9GGz/MmCmi3EFpKgeS7ICrAFes+suEbs=
modernc.org/ccgo/v4 v4.17.8/go.mod h1:buJnJ6Fn0tyAdP/dqePbrrvLyr6qslFfTbFrCuaYvtA=
modernc.org/fileutil v1.3.0 h1:gQ5SIzK3H9kdfai/5x41oQiKValumqNTDXMvKo62HvE=
modernc.org/fileutil v1.3.0/go.mod h1:XatxS8fZi3pS8/hKG2GH/ArUogfxjpEKs3Ku3aK4JyQ=
modernc.org/gc/v2 v2.4.1 h1:9cNzOqPyMJBvrUipmynX0ZohMhcxPtMccYgGOJdOiBw=
modernc.org/gc/v2 v2.4.1/go.mod h1:wzN5dK1AzVGoH6XOzc3YZ+ey/jPgYHLuVckd62P0GYU=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6 h1:5D53IMaUuA5InSeMu9eJtlQXS2NxAhyWQvkKEgXZhHI=
modernc.org/gc/v3 v3.0.0-20240107210532-573471604cb6/go.mod h1:Qz0X07sNOR1jWYCrJMEnbW/X55x206Q7Vt4mz6/wHp4=
modernc.org/libc v1.41.0 h1:g9YAc6BkKlgORsUWj+JwqoB1wU3o4DE3bM3yvA3k+Gk=
modernc.org/libc v1.41.0/go.mod h1:w0eszPsiXoOnoMJgrXjglgLuDy/bt5RR4y3QzUUeodY=
modernc.org/libc v1.50.9 h1:hIWf1uz55lorXQhfoEoezdUHjxzuO6ceshET/yWjSjk=
modernc.org/libc v1.50.9/go.mod h1:15P6ublJ9FJR8YQCGy8DeQ2Uwur7iW9Hserr/T3OFZE=
modernc.org/mathutil v1.6.0 h1:fRe9+AmYlaej+64JsEEhoWuAYBkOtQiMEU7n/XgfYi4=
modernc.org/mathutil v1.6.0/go.mod h1:Ui5Q9q1TR2gFm0AQRqQUaBWFLAhQpCwNcuhBOSedWPo=
modernc.org/memory v1.7.2 h1:Klh90S215mmH8c9gO98QxQFsY+W451E8AnzjoE2ee1E=
modernc.org/memory v1.7.2/go.mod h1:NO4NVCQy0N7ln+T9ngWqOQfi7ley4vpwvARR+Hjw95E=
modernc.org/sqlite v1.29.6 h1:0lOXGrycJPptfHDuohfYgNqoe4hu+gYuN/pKgY5XjS4=
modernc.org/sqlite v1.29.6/go.mod h1:S02dvcmm7TnTRvGhv8IGYyLnIt7AS2KPaB1F/71p75U=
modernc.org/memory v1.8.0 h1:IqGTL6eFMaDZZhEWwcREgeMXYwmW83LYW8cROZYkg+E=
modernc.org/memory v1.8.0/go.mod h1:XPZ936zp5OMKGWPqbD3JShgd/ZoQ7899TUuQqxY+peU=
modernc.org/opt v0.1.3 h1:3XOZf2yznlhC+ibLltsDGzABUGVx8J6pnFMS3E4dcq4=
modernc.org/opt v0.1.3/go.mod h1:WdSiB5evDcignE70guQKxYUl14mgWtbClRi5wmkkTX0=
modernc.org/sortutil v1.2.0 h1:jQiD3PfS2REGJNzNCMMaLSp/wdMNieTbKX920Cqdgqc=
modernc.org/sortutil v1.2.0/go.mod h1:TKU2s7kJMf1AE84OoiGppNHJwvB753OYfNl2WRb++Ss=
modernc.org/sqlite v1.30.0 h1:8YhPUs/HTnlEgErn/jSYQTwHN/ex8CjHHjg+K9iG7LM=
modernc.org/sqlite v1.30.0/go.mod h1:cgkTARJ9ugeXSNaLBPK3CqbOe7Ec7ZhWPoMFGldEYEw=
modernc.org/strutil v1.2.0 h1:agBi9dp1I+eOnxXeiZawM8F4LawKv4NzGWSaLfyeNZA=
modernc.org/strutil v1.2.0/go.mod h1:/mdcBmfOibveCTBxUl5B5l6W+TTH1FXPLHZE6bTosX0=
modernc.org/token v1.1.0 h1:Xl7Ap9dKaEs5kLoOQeQmPWevfnk/DM5qcLcYlA8ys6Y=
Expand Down
4 changes: 2 additions & 2 deletions internal/db/connect.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ import (

"github.com/jonathanhope/armaria/internal/null"
"github.com/jonathanhope/armaria/internal/paths"
_ "github.com/mattn/go-sqlite3"
"github.com/pressly/goose/v3"
_ "modernc.org/sqlite"
)

//go:embed migrations/*.sql
Expand All @@ -26,7 +26,7 @@ func connectDB(inputPath null.NullString, configPath string) (*sql.DB, error) {
return nil, fmt.Errorf("error getting database location wile connecting to database: %w", err)
}

db, err := sql.Open("sqlite3", dbLocation)
db, err := sql.Open("sqlite", dbLocation)
if err != nil {
return nil, fmt.Errorf("error while connecting to database: %w", err)
}
Expand Down

0 comments on commit e59492e

Please sign in to comment.