ops: add ops scripts

This commit is contained in:
2026-10-14 20:50:24 -07:00
parent 190a5bf8b2
commit 5da0c76be2
6 changed files with 30 additions and 19 deletions

37
ops/build.sh Executable file
View File

@@ -0,0 +1,37 @@
#!/usr/bin/env sh
set -e
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
cd "$SCRIPT_DIR/.." # .custom-gcl.yaml is only discovered in the current directory
BIN="bin/golint"
STAMP="bin/.golint.stamp"
# Everything that changes the compiled binary: the linter sources, and the build
# config that pins the golangci-lint version the plugin links against. testdata
# is excluded -- fixtures are not compiled into the binary.
current_stamp() {
{
find . -type f ! -path '*/testdata/*' | sort | xargs shasum -a 256
shasum -a 256 .custom-gcl.yaml
} | shasum -a 256 | cut -d' ' -f1
}
if [ "$1" = "--if-needed" ] &&
[ -x "$BIN" ] &&
[ -f "$STAMP" ] &&
[ "$(cat "$STAMP")" = "$(current_stamp)" ]; then
exit 0
fi
if ! [ -x "$(command -v golangci-lint)" ]; then
echo "golangci-lint is not installed. Please install it from https://golangci-lint.run/welcome/install/"
exit 1
fi
echo "Building golint (golangci-lint + custom linters)..."
golangci-lint custom
current_stamp > "$STAMP"
echo "Done: $SCRIPT_DIR/$BIN"

16
ops/lint.sh Executable file
View File

@@ -0,0 +1,16 @@
#!/usr/bin/env sh
set -e
SCRIPT_DIR=$(cd "$(dirname "$0")" && pwd)
SERVER_ROOT="$SCRIPT_DIR/.."
cd "$SERVER_ROOT" # Run script from server directory
./ops/build.sh --if-needed
GOLANGCI="./bin/golint"
echo "Linting $(go list ./... | wc -w) packages"
# Catches config keys in the wrong place, which are otherwise silently ignored.
$GOLANGCI config verify
$GOLANGCI run

2
ops/test.sh Executable file
View File

@@ -0,0 +1,2 @@
#!/bin/sh
go test ./...