Test both dbs (#205)

* move scripts, allow testing both dbs with one cmd

* tidy + vendor

* update test.sh to ignore cache

* put test commands directly in drone.yml

* change CONTRIBUTING slightly

* go ham on the readme
This commit is contained in:
tobi
2021-09-10 18:13:24 +02:00
committed by GitHub
parent f2e5bedea6
commit 64bd689e55
16 changed files with 337 additions and 196 deletions

11
scripts/build.sh Executable file
View File

@@ -0,0 +1,11 @@
#!/bin/sh
set -eu
COMMIT=$(git rev-list -1 HEAD)
VERSION=$(cat ./version)
CGO_ENABLED=0 go build -trimpath \
-tags 'netgo osusergo static_build' \
-ldflags="-s -w -extldflags '-static' -X 'main.Commit=${COMMIT}' -X 'main.Version=${VERSION}'" \
./cmd/gotosocial

7
scripts/dockerbuild.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -eu
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
docker build -t "superseriousbusiness/gotosocial:${BRANCH_NAME}" .

7
scripts/dockerpush.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/bin/bash
set -e
BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
docker push "superseriousbusiness/gotosocial:${BRANCH_NAME}"

9
scripts/generateswagger.sh Executable file
View File

@@ -0,0 +1,9 @@
#!/bin/bash
set -eu
SWAGGER_FILE="docs/api/swagger.yaml"
GTS_VERSION="$(cat version)"
swagger generate spec -o "${SWAGGER_FILE}" --scan-models
sed -i "s/REPLACE_ME/${GTS_VERSION}/" "${SWAGGER_FILE}"

13
scripts/test.sh Executable file
View File

@@ -0,0 +1,13 @@
#!/bin/sh
set -e
# "-count 1" = run all tests once, ignoring cache; useful for when we're running tests with different database back to back like this
# "-p 1" = run with parallel value of 1 -- in other words, one test at a time
# "./..." = all tests
# run tests with sqlite in-memory database
GTS_DB_TYPE="sqlite" GTS_DB_ADDRESS=":memory:" go test -count 1 -p 1 ./...
# run tests with postgres database at either GTS_DB_ADDRESS or default localhost
GTS_DB_TYPE="postgres" GTS_DB_ADDRESS="${GTS_DB_ADDRESS:-localhost}" go test -count 1 -p 1 ./...