Skip to content

Commit

Permalink
feat: initial library, cli, and tests (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
JonathanHope authored Nov 11, 2023
1 parent fc5c703 commit 88c9522
Show file tree
Hide file tree
Showing 65 changed files with 6,509 additions and 3 deletions.
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
dist
1 change: 1 addition & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
use flake
4 changes: 1 addition & 3 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ name: Build, Test and Lint Armaria
on:
pull_request:
types: [opened, synchronize]
branches:
- main

permissions:
contents: read
pull-requests: read

jobs:
lint:
name: Lint PR title
runs-on: ubuntu-latest
steps:
- uses: amannn/action-semantic-pull-request@v5
Expand Down
7 changes: 7 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
*.db
*.db-shm
*.db-wal
cli/cli
.direnv
armaria
dist
33 changes: 33 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
linters:
disable-all: true
enable:
- govet
- errcheck
- gosimple
- ineffassign
- staticcheck
- asciicheck
- containedctx
- contextcheck
- errchkjson
- errorlint
- forcetypeassert
- gocheckcompilerdirectives
- gochecknoinits
- gochecknoglobals
- gofmt
- gosec
- makezero
- musttag
- nilerr
- nilnil
- predeclared
- reassign
- sqlclosecheck
- unconvert
- unparam
- wastedassign
run:
skip-files:
- lib/go_sqlite3_migrate.go
- test/armaria_test.go
93 changes: 93 additions & 0 deletions .goreleaser.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
env:
- CGO_ENABLED=1

builds:
- id: armaria-darwin-amd64
binary: armaria
main: ./cli
goarch:
- amd64
goos:
- darwin
env:
- CC=o64-clang
- CXX=o64-clang++
flags:
- -trimpath
- -tags=fts5

- id: armaria-darwin-arm64
binary: armria
main: ./cli
goarch:
- arm64
goos:
- darwin
env:
- CC=oa64-clang
- CXX=oa64-clang++
flags:
- -trimpath
- -tags=fts5

- id: armaria-linux-amd64
binary: armaria
main: ./cli
env:
- CC=x86_64-linux-gnu-gcc
- CXX=x86_64-linux-gnu-g++
goarch:
- amd64
goos:
- linux
flags:
- -trimpath
- -tags=fts5
ldflags:
- -extldflags "-lc -lrt -lpthread --static"
- -s
- -w

- id: armaria-windows-amd64
binary: armaria
main: ./cli
goarch:
- amd64
goos:
- windows
env:
- CC=x86_64-w64-mingw32-gcc
- CXX=x86_64-w64-mingw32-g++
flags:
- -trimpath
- -buildmode=exe
- -tags=fts5

universal_binaries:
- id: armaria-darwin-universal
ids:
- armaria-darwin-amd64
- armaria-darwin-arm64
replace: true
name_template: "armaria"

archives:
- id: w/version
builds:
- armaria-darwin-universal
- armaria-linux-amd64
- armaria-windows-amd64
name_template: "armaria_{{ .Version }}_{{ .Os }}_{{ .Arch }}"
wrap_in_directory: false
format: zip
files:
- none*

checksum:
name_template: 'checksums.txt'

snapshot:
name_template: "{{ incpatch .Version }}-next"

changelog:
sort: asc
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2023 Jonathan Hope

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
67 changes: 67 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
* Armaria

#+BEGIN_QUOTE
Armaria are a kind of closed, labeled cupboards that were used for book storage in ancient times up till the middle ages.
#+END_QUOTE

*NOTE: This software is still in progress and should be considered pre alpha*

Armaria is a new way to manage your bookmarks.

As it stands bookmarks are stored either in the cloud, in browser specific formats, or both. It doesn't have to be this way. Armaria stores bookmarks in a SQLite database. This means your bookmarks are local and shared across all clients including browsers.

* Supported Platforms

- Windows x64
- Linux x64
- Mac x64/arm64

* Features

- URL, Name, and Description fields
- Nested folder structure
- Tags
- Full text search
- CLI

* Schema

The ERD for the bookmarks database is as follows:

#+begin_src mermaid :file "bookmarks-db.svg" :pupeteer-config-file "~/.emacs.d/pupeteer-config.json" :mermaid-config-file "~/.emacs.d/mermaid-config.json" :background-color "transparent"
erDiagram
bookmarks ||--|{ bookmarks_tags: ""
tags ||--|{ bookmarks_tags: ""
bookmarks o|--o{ bookmarks: ""

bookmarks {
text id
text parent_id
integer is_folder
text name
text url
text description
text modified
}

tags {
text tag
text modified
}

bookmarks_tags {
text bookmark_id
text tag
text modified
}
#+end_src

#+RESULTS:
[[file:bookmarks-db.svg]]


* FAQ

** How do I back up my bookmarks?

You can use whatever you are already using to backup your files to the cloud.
56 changes: 56 additions & 0 deletions Taskfile.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
version: '3'

tasks:
lint-lib:
dir: lib
cmds:
- golangci-lint run --config ../.golangci.yml --timeout 3m
lint-cli:
dir: cli
cmds:
- golangci-lint run --config ../.golangci.yml --timeout 3m
lint-bdd:
dir: bdd
cmds:
- golangci-lint run --config ../.golangci.yml --timeout 3m
lint:
cmds:
- task: lint-lib
- task: lint-cli
- task: lint-bdd
test-bdd:
dir: bdd
cmds:
- go test --tags "fts5"
test-lib:
dir: lib
cmds:
- go test --tags "fts5"
test:
cmds:
- task: test-bdd
- task: test-lib
build:
dir: cli
cmds:
- go build --tags "fts5" -ldflags "-s -w"
- cp cli ../armaria
migrate-up:
cmds:
- goose -dir ./lib/migrations sqlite3 ./bookmarks.db up
migrate-down:
cmds:
- goose -dir ./lib/migrations sqlite3 ./bookmarks.db down
clean:
cmds:
- rm -f armaria
- rm -f cli/cli
- find . -name "*.db" -type f -delete
- find . -name "*.db-shm" -type f -delete
- find . -name "*.db-wal" -type f -delete
release:
cmds:
- docker run -v $(pwd):/src -w /src -e GITHUB_TOKEN=$GITHUB_TOKEN -i goreleaser/goreleaser-cross:v1.20 release
release-snapshot:
cmds:
- docker run -v $(pwd):/src -w /src -i goreleaser/goreleaser-cross:v1.20 release --snapshot
45 changes: 45 additions & 0 deletions bdd/armaria_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package test

import (
"flag"
"os"
"testing"

"github.com/cucumber/godog"
"github.com/cucumber/godog/colors"
)

// This integrates godog with go test.
// It was taken from the godog docs.

//nolint:gochecknoglobals
var opts = godog.Options{
Output: colors.Colored(os.Stdout),
Format: "progress",
Concurrency: 4,
}

//nolint:gochecknoinits
func init() {
godog.BindFlags("godog.", flag.CommandLine, &opts)
}

func TestFeatures(t *testing.T) {
o := opts
o.TestingT = t

status := godog.TestSuite{
Name: "aramaria",
Options: &o,
TestSuiteInitializer: InitializeTestSuite,
ScenarioInitializer: InitializeScenario,
}.Run()

if status == 2 {
t.SkipNow()
}

if status != 0 {
t.Fatalf("zero status code expected, %d received", status)
}
}
Loading

0 comments on commit 88c9522

Please sign in to comment.