fix compileerrors, add tests (#2)

This commit is contained in:
T. von Dein
2025-11-21 14:06:32 +01:00
parent b10dd5cd59
commit ab0d3f8268
4 changed files with 87 additions and 24 deletions

View File

@@ -12,12 +12,42 @@ steps:
image: alpine:latest
commands:
- apk update
- apk add --no-cache bash build-base words-en gdb perl pcre2 pcre2-dev db db-dev pkgconfig meson ninja
- apk add --no-cache bash build-base gdb perl pcre2 pcre2-dev db db-dev pkgconfig meson ninja
- meson setup --reconfigure build
- ninja -C build
test-berkeley:
when:
event: [push]
image: alpine:latest
commands:
- apk update
- apk add --no-cache bash build-base pcre2 pcre2-dev db db-dev
- rm -f test.db
- build/dbtool -d test.db -i -k "test" -v "blah blah blah"
# insert keys
- build/dbtool -d test.db -i -k test -v blah
- build/dbtool -d test.db -i -k foo -v bar
# look if the appear in the dump
- build/dbtool -d test.db -D | grep blah
# count 'em
- build/dbtool -d test.db -D | wc -l | grep 2
# search for key
- build/dbtool -d test.db -s -k test
# search for key regex
- build/dbtool -d test.db -S -k 't$'
# remove key
- build/dbtool -d test.db -r -k foo
# count must match
- build/dbtool -d test.db -D | wc -l | grep 1
# modify a key
- build/dbtool -d test.db -u -k test -v modified
# check modified key
- build/dbtool -d test.db -s -k test | grep modified
# use splitting with regex
- printf "today:100\nyesterday:500\n" | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)'
# check if it works
- cat /etc/passwd | build/dbtool -d test.db -s -k today | grep 100
build-gdbm:
when:
@@ -25,9 +55,42 @@ steps:
image: alpine:latest
commands:
- apk update
- apk add --no-cache bash build-base words-en gdb perl pcre2 pcre2-dev gdbm gdbm-dev pkgconfig meson ninja
- apk add --no-cache bash build-base perl pcre2 pcre2-dev gdbm gdbm-dev pkgconfig meson ninja
- meson setup --reconfigure build
- ninja -C build
- rm -f test.db
- build/dbtool -d test.db -i -k "test" -v "blah blah blah"
- build/dbtool -d test.db -D | grep blah
test-gdbm:
when:
event: [push]
image: alpine:latest
commands:
- apk update
- apk add --no-cache bash build-base pcre2 pcre2-dev gdbm gdbm-dev
- rm -f test.db
# insert keys
- build/dbtool -d test.db -i -k test -v blah
- build/dbtool -d test.db -i -k foo -v bar
# look if the appear in the dump
- build/dbtool -d test.db -D | grep blah
# count 'em
- build/dbtool -d test.db -D | wc -l | grep 2
# search for key
- build/dbtool -d test.db -s -k test
# search for key regex
- build/dbtool -d test.db -S -k 't$'
# remove key
- build/dbtool -d test.db -r -k foo
# count must match
- build/dbtool -d test.db -D | wc -l | grep 1
# modify a key
- build/dbtool -d test.db -u -k test -v modified
# check modified key
- build/dbtool -d test.db -s -k test | grep modified
# use splitting with regex
- printf "today:100\nyesterday:500\n" | build/dbtool -d test.db -i -f -t '^([^:]*):([^:]*)'
# check if it works
- cat /etc/passwd | build/dbtool -d test.db -s -k today | grep 100

View File

@@ -6,12 +6,12 @@ labels:
steps:
compile:
when:
event: [manual]
event: [tag]
image: alpine:latest
commands:
- apk update
- apk add --no-cache bash build-base words-en gdb perl pcre2 pcre2-dev gdbm gdbm-dev pkgconfig meson ninja
- meson setup --reconfigure --prefer-static build
- apk add --no-cache bash build-base words-en gdb perl pcre2-static pcre2-dev gdbm gdbm-dev pkgconfig meson ninja
- meson setup --reconfigure --prefer-static -Dcpp_link_args="-static" --buildtype=release build
- ninja -C build
- file build/dbtool
- mv build/dbtool dbtool-linux-amd64
@@ -19,7 +19,7 @@ steps:
release:
image: alpine:latest
when:
event: [manual]
event: [tag]
environment:
DEPLOY_TOKEN:
from_secret: DEPLOY_TOKEN