summaryrefslogtreecommitdiff
path: root/scripts
diff options
context:
space:
mode:
Diffstat (limited to 'scripts')
-rwxr-xr-xscripts/build.sh11
-rwxr-xr-xscripts/dockerbuild.sh7
-rwxr-xr-xscripts/dockerpush.sh7
-rwxr-xr-xscripts/generateswagger.sh9
-rwxr-xr-xscripts/test.sh13
5 files changed, 47 insertions, 0 deletions
diff --git a/scripts/build.sh b/scripts/build.sh
new file mode 100755
index 000000000..65b258cba
--- /dev/null
+++ b/scripts/build.sh
@@ -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
diff --git a/scripts/dockerbuild.sh b/scripts/dockerbuild.sh
new file mode 100755
index 000000000..a7e14d724
--- /dev/null
+++ b/scripts/dockerbuild.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -eu
+
+BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
+
+docker build -t "superseriousbusiness/gotosocial:${BRANCH_NAME}" .
diff --git a/scripts/dockerpush.sh b/scripts/dockerpush.sh
new file mode 100755
index 000000000..fb952032c
--- /dev/null
+++ b/scripts/dockerpush.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+set -e
+
+BRANCH_NAME="$(git rev-parse --abbrev-ref HEAD)"
+
+docker push "superseriousbusiness/gotosocial:${BRANCH_NAME}"
diff --git a/scripts/generateswagger.sh b/scripts/generateswagger.sh
new file mode 100755
index 000000000..a964ba41c
--- /dev/null
+++ b/scripts/generateswagger.sh
@@ -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}"
diff --git a/scripts/test.sh b/scripts/test.sh
new file mode 100755
index 000000000..09e9ae42e
--- /dev/null
+++ b/scripts/test.sh
@@ -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 ./...