Skip to content

Commit 28f0759

Browse files
committed
feat: multiple database support
1 parent 2c3ed81 commit 28f0759

File tree

14 files changed

+2930
-77
lines changed

14 files changed

+2930
-77
lines changed

CONTRIBUTING.md

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -37,17 +37,21 @@ When reporting bugs:
3737
- **Git**
3838
- **Go >= 1.24**
3939
- **PostgreSQL**
40+
- **CockroachDB**
41+
- **SQLite**
4042

4143
### Getting Started
4244

4345
1. **Fork the repository** on GitHub
4446
2. **Clone your fork locally:**
47+
4548
```bash
4649
git clone https://github.com/YOUR_USERNAME/miniflux.git
4750
cd miniflux
4851
```
4952

5053
3. **Build the application binary:**
54+
5155
```bash
5256
make miniflux
5357
```
@@ -59,15 +63,11 @@ When reporting bugs:
5963

6064
### Database Setup
6165

62-
For development and testing, you can run a local PostgreSQL database with Docker:
66+
For development and testing, you can run PostgreSQL and CockroachDB via docker compose:
6367

6468
```bash
65-
# Start PostgreSQL container
66-
docker run --rm --name miniflux2-db -p 5432:5432 \
67-
-e POSTGRES_DB=miniflux2 \
68-
-e POSTGRES_USER=postgres \
69-
-e POSTGRES_PASSWORD=postgres \
70-
postgres
69+
# Start PostgreSQL and CockroachDB containers
70+
docker compose -d
7171
```
7272

7373
You can also use an existing PostgreSQL instance. Make sure to set the `DATABASE_URL` environment variable accordingly.
@@ -77,20 +77,27 @@ You can also use an existing PostgreSQL instance. Make sure to set the `DATABASE
7777
### Code Quality
7878

7979
1. **Run the linter:**
80+
8081
```bash
8182
make lint
8283
```
84+
8385
Requires `staticcheck` and `golangci-lint` to be installed.
8486

8587
2. **Run unit tests:**
88+
8689
```bash
8790
make test
8891
```
8992

9093
3. **Run integration tests:**
9194
```bash
92-
make integration-test
93-
make clean-integration-test
95+
make integration-test-postgresql
96+
make clean-integration-test-postgresql
97+
make integration-test-cockroachdb
98+
make clean-integration-test-cockroachdb
99+
make integration-test-sqlite
100+
make clean-integration-test-sqlite
94101
```
95102

96103
### Building
@@ -103,6 +110,7 @@ You can also use an existing PostgreSQL instance. Make sure to set the `DATABASE
103110
### Cross-Platform Support
104111

105112
Miniflux supports multiple architectures. When making changes, ensure compatibility across:
113+
106114
- Linux (amd64, arm64, armv7, armv6, armv5)
107115
- macOS (amd64, arm64)
108116
- FreeBSD, OpenBSD, Windows (amd64)
@@ -155,11 +163,13 @@ When creating a pull request, please include:
155163
## Testing
156164

157165
### Unit Tests
166+
158167
- Write unit tests for new functions and methods
159168
- Ensure tests are fast and don't require external dependencies
160169
- Aim for good test coverage
161170

162171
### Integration Tests
172+
163173
- Add integration tests for new API endpoints
164174
- Tests run against a real PostgreSQL database
165175
- Ensure tests clean up after themselves

Makefile

Lines changed: 61 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ DOCKER_IMAGE := miniflux/miniflux
33
VERSION := $(shell git describe --tags --exact-match 2>/dev/null)
44
LD_FLAGS := "-s -w -X 'miniflux.app/v2/internal/version.Version=$(VERSION)'"
55
PKG_LIST := $(shell go list ./... | grep -v /vendor/)
6-
DB_URL := postgres://postgres:postgres@localhost/miniflux_test?sslmode=disable
76
DOCKER_PLATFORM := amd64
87

98
export PGPASSWORD := postgres
@@ -28,8 +27,12 @@ export PGPASSWORD := postgres
2827
add-string \
2928
test \
3029
lint \
31-
integration-test \
32-
clean-integration-test \
30+
integration-test-postgresql \
31+
clean-integration-test-postgresql \
32+
integration-test-cockroachdb \
33+
clean-integration-test-cockroachdb \
34+
integration-test-sqlite \
35+
clean-integration-test-sqlite \
3336
docker-image \
3437
docker-image-distroless \
3538
docker-images \
@@ -103,17 +106,18 @@ lint:
103106
staticcheck ./...
104107
golangci-lint run --disable errcheck --enable sqlclosecheck --enable misspell --enable gofmt --enable goimports --enable whitespace
105108

106-
integration-test:
107-
psql -U postgres -c 'drop database if exists miniflux_test;'
108-
psql -U postgres -c 'create database miniflux_test;'
109+
integration-test-postgresql:
110+
psql -U postgres -p 5432 -c 'drop database if exists miniflux2;'
111+
psql -U postgres -p 5432 -c 'create database miniflux2;'
109112

110-
DATABASE_URL=$(DB_URL) \
113+
go build -o miniflux-test main.go
114+
DATABASE_URL='postgres://postgres:postgres@localhost:5432/miniflux2?sslmode=disable' \
111115
ADMIN_USERNAME=admin \
112116
ADMIN_PASSWORD=test123 \
113117
CREATE_ADMIN=1 \
114118
RUN_MIGRATIONS=1 \
115119
LOG_LEVEL=debug \
116-
go run main.go >/tmp/miniflux.log 2>&1 & echo "$$!" > "/tmp/miniflux.pid"
120+
./miniflux-test >/tmp/miniflux.log 2>&1 & echo "$$!" > "/tmp/miniflux.pid"
117121

118122
while ! nc -z localhost 8080; do sleep 1; done
119123

@@ -122,10 +126,57 @@ integration-test:
122126
TEST_MINIFLUX_ADMIN_PASSWORD=test123 \
123127
go test -v -count=1 ./internal/api
124128

125-
clean-integration-test:
129+
clean-integration-test-postgresql:
126130
@ kill -9 `cat /tmp/miniflux.pid`
127131
@ rm -f /tmp/miniflux.pid /tmp/miniflux.log
128-
@ psql -U postgres -c 'drop database if exists miniflux_test;'
132+
@ psql -U postgres -c 'drop database if exists miniflux2;'
133+
134+
integration-test-cockroachdb:
135+
psql -U postgres -p 26257 -c 'drop database if exists miniflux2;'
136+
psql -U postgres -p 26257 -c 'create database miniflux2;'
137+
138+
go build -o miniflux-test main.go
139+
DATABASE_URL='cockroach://postgres:postgres@localhost:26257/miniflux2?sslmode=disable' \
140+
ADMIN_USERNAME=admin \
141+
ADMIN_PASSWORD=test123 \
142+
CREATE_ADMIN=1 \
143+
RUN_MIGRATIONS=1 \
144+
LOG_LEVEL=debug \
145+
./miniflux-test >/tmp/miniflux.log 2>&1 & echo "$$!" > "/tmp/miniflux.pid"
146+
147+
while ! nc -z localhost 8080; do sleep 1; done
148+
149+
TEST_MINIFLUX_BASE_URL=http://127.0.0.1:8080 \
150+
TEST_MINIFLUX_ADMIN_USERNAME=admin \
151+
TEST_MINIFLUX_ADMIN_PASSWORD=test123 \
152+
go test -v -count=1 ./internal/api
153+
154+
clean-integration-test-cockroachdb:
155+
@ kill -9 `cat /tmp/miniflux.pid`
156+
@ rm -f /tmp/miniflux.pid /tmp/miniflux.log
157+
@ psql -U postgres -c 'drop database if exists miniflux2;'
158+
159+
integration-test-sqlite:
160+
go build -o miniflux-test main.go
161+
DATABASE_URL='file::memory:?cache=shared' \
162+
ADMIN_USERNAME=admin \
163+
ADMIN_PASSWORD=test123 \
164+
CREATE_ADMIN=1 \
165+
RUN_MIGRATIONS=1 \
166+
DEBUG=1 \
167+
./miniflux-test >/tmp/miniflux.log 2>&1 & echo "$$!" > "/tmp/miniflux.pid"
168+
169+
while ! nc -z localhost 8080; do sleep 1; done
170+
171+
TEST_MINIFLUX_BASE_URL=http://127.0.0.1:8080 \
172+
TEST_MINIFLUX_ADMIN_USERNAME=admin \
173+
TEST_MINIFLUX_ADMIN_PASSWORD=test123 \
174+
go test -v -count=1 ./internal/api
175+
176+
clean-integration-test-sqlite:
177+
@ kill -9 `cat /tmp/miniflux.pid`
178+
@ rm -f /tmp/miniflux.pid /tmp/miniflux.log
179+
@ rm miniflux-test
129180

130181
docker-image:
131182
docker build --pull -t $(DOCKER_IMAGE):$(VERSION) -f packaging/docker/alpine/Dockerfile .

README.md

Lines changed: 14 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
1-
Miniflux 2
2-
==========
1+
# Miniflux 2
32

43
Miniflux is a minimalist and opinionated feed reader.
54
It's simple, fast, lightweight and super easy to install.
65

76
Official website: <https://miniflux.app>
87

9-
Features
10-
--------
8+
## Features
119

1210
### Feed Reader
1311

@@ -19,7 +17,7 @@ Features
1917
- Share individual articles publicly.
2018
- Fetches website icons (favicons).
2119
- Saves articles to third-party services.
22-
- Provides full-text search (powered by Postgres).
20+
- Provides full-text search.
2321
- Available in 20 languages: Portuguese (Brazilian), Chinese (Simplified and Traditional), Dutch, English (US), Finnish, French, German, Greek, Hindi, Indonesian, Italian, Japanese, Polish, Romanian, Russian, Taiwanese POJ, Ukrainian, Spanish, and Turkish.
2422

2523
### Privacy and Security
@@ -34,7 +32,7 @@ Features
3432
- Supports alternative YouTube video players such as [Invidious](https://invidio.us).
3533
- Blocks external JavaScript to prevent tracking and enhance security.
3634
- Sanitizes external content before rendering it.
37-
- Enforces a [Content Security](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) and a [Trusted Types Policy](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) to only application JavaScript and blocks inline scripts and styles.
35+
- Enforces a [Content Security](https://developer.mozilla.org/en-US/docs/Web/HTTP/CSP) and a [Trusted Types Policy](https://developer.mozilla.org/en-US/docs/Web/API/Trusted_Types_API) to only application JavaScript and blocks inline scripts and styles.
3836

3937
### Bot Protection Bypass Mechanisms
4038

@@ -63,12 +61,12 @@ Features
6361
- Optional touch gesture support for navigation on mobile devices.
6462
- Custom stylesheets and JavaScript to personalize the user interface to your preferences.
6563
- Themes:
66-
- Light (Sans-Serif)
67-
- Light (Serif)
68-
- Dark (Sans-Serif)
69-
- Dark (Serif)
70-
- System (Sans-Serif) – Automatically switches between Dark and Light themes based on system preferences.
71-
- System (Serif)
64+
- Light (Sans-Serif)
65+
- Light (Serif)
66+
- Dark (Sans-Serif)
67+
- Dark (Serif)
68+
- System (Sans-Serif) – Automatically switches between Dark and Light themes based on system preferences.
69+
- System (Serif)
7270

7371
### Integrations
7472

@@ -90,7 +88,7 @@ Features
9088

9189
- Written in [Go (Golang)](https://golang.org/).
9290
- Single binary compiled statically without dependency.
93-
- Works only with [PostgreSQL](https://www.postgresql.org/).
91+
- Works with [PostgreSQL](https://www.postgresql.org/), [CockroachDB](https://www.cockroachlabs.com/) and [SQLite](https://sqlite.org/).
9492
- Does not use any ORM or any complicated frameworks.
9593
- Uses modern vanilla JavaScript only when necessary.
9694
- All static files are bundled into the application binary using the Go `embed` package.
@@ -109,8 +107,7 @@ Features
109107
- Only uses a couple of MB of memory and a negligible amount of CPU, even with several hundreds of feeds.
110108
- Respects/sends Last-Modified, If-Modified-Since, If-None-Match, Cache-Control, Expires and ETags headers, and has a default polling interval of 1h.
111109

112-
Documentation
113-
-------------
110+
## Documentation
114111

115112
The Miniflux documentation is available here: <https://miniflux.app/docs/> ([Man page](https://miniflux.app/miniflux.1.html))
116113

@@ -130,8 +127,7 @@ The Miniflux documentation is available here: <https://miniflux.app/docs/> ([Man
130127
- [Internationalization](https://miniflux.app/docs/i18n.html)
131128
- [Frequently Asked Questions](https://miniflux.app/faq.html)
132129

133-
Screenshots
134-
-----------
130+
## Screenshots
135131

136132
Default theme:
137133

@@ -141,8 +137,7 @@ Dark theme when using keyboard navigation:
141137

142138
![Dark theme](https://miniflux.app/images/item-selection-black-theme.png)
143139

144-
Credits
145-
-------
140+
## Credits
146141

147142
- Authors: Frédéric Guillot - [List of contributors](https://github.com/miniflux/v2/graphs/contributors)
148143
- Distributed under Apache 2.0 License

docker-compose.yml

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
services:
2+
postgresql:
3+
image: postgres:17.6
4+
volumes:
5+
- postgres-data:/var/lib/postgresql/data
6+
ports:
7+
- 5432:5432
8+
environment:
9+
POSTGRES_DB: miniflux2
10+
POSTGRES_USER: postgres
11+
POSTGRES_PASSWORD: postgres
12+
healthcheck:
13+
test: ["CMD", "pg_isready -d miniflux2 -U postgres"]
14+
timeout: 30s
15+
interval: 5s
16+
17+
cockroachdb:
18+
image: cockroachdb/cockroach:v23.2.28
19+
command: start-single-node --insecure
20+
volumes:
21+
- cockroach-data:/cockroach/cockroach-data
22+
environment:
23+
COCKROACH_DATABASE: miniflux2
24+
COCKROACH_USER: postgres
25+
ports:
26+
- "26257:26257"
27+
- "8080:8080"
28+
healthcheck:
29+
test: ["CMD", "cockroach", "sql", "--insecure", "--host=localhost:26257", "-e", "select 1"]
30+
timeout: 30s
31+
interval: 5s
32+
33+
volumes:
34+
postgres-data:
35+
driver: local
36+
cockroach-data:
37+
driver: local

flake.nix

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,20 @@
1111
let
1212
pkgs = import nixpkgs {
1313
inherit system;
14+
config.allowUnfree = true;
1415
};
1516
in
1617
{
1718
devShells.default = pkgs.mkShell {
19+
PGHOST = "localhost";
20+
PGPORT = 5432;
21+
PGPASSWORD = "postgres";
22+
PGUSER = "postgres";
23+
PGDATABASE = "miniflux2";
24+
25+
COCKROACH_URL = "postgresql://postgres:postgres@localhost:26257/miniflux2";
26+
COCKROACH_INSECURE = true;
27+
1828
packages = with pkgs; [
1929
git
2030

@@ -36,6 +46,11 @@
3646
gopls
3747
go-tools
3848
gofumpt
49+
50+
postgresql
51+
cockroachdb
52+
sqlite
53+
usql
3954
];
4055
};
4156
}

0 commit comments

Comments
 (0)