ops: add ops scripts
This commit is contained in:
37
ops/build.sh
Executable file
37
ops/build.sh
Executable 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
16
ops/lint.sh
Executable 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
2
ops/test.sh
Executable file
@@ -0,0 +1,2 @@
|
||||
#!/bin/sh
|
||||
go test ./...
|
||||
Reference in New Issue
Block a user