-
Notifications
You must be signed in to change notification settings - Fork 5
/
.justfile
46 lines (36 loc) · 1.67 KB
/
.justfile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
set dotenv-load := true
export TOOLS_BIN_DIR := join(env_var_or_default("XDG_CACHE_HOME", join(env_var("HOME") , ".cache")), "cerbos-sdk-go/bin")
export CERBOS_TEST_CONTAINER_TAG := "dev"
export CERBOS_TEST_DEBUG := "true"
tools_mod_dir := join(justfile_directory(), "tools")
default:
@ just --list
lint: _golangcilint
@ "${TOOLS_BIN_DIR}/golangci-lint" run --fix
test PKG='./...' TEST='.*': _gotestsum
@ "${TOOLS_BIN_DIR}/gotestsum" --format-hide-empty-pkg -- -tags=tests,integration -failfast -v -count=1 -run='{{ TEST }}' '{{ PKG }}'
tests: _gotestsum
@ "${TOOLS_BIN_DIR}/gotestsum" --format=dots-v2 --format-hide-empty-pkg -- -tags=tests,integration -failfast -count=1 ./...
compile:
@ go build -o /dev/null ./...
_gotestsum: (_install "gotestsum" "gotest.tools/gotestsum")
_golangcilint: (_install "golangci-lint" "github.com/golangci/golangci-lint" "cmd/golangci-lint")
_install EXECUTABLE MODULE CMD_PKG="":
#!/usr/bin/env bash
set -euo pipefail
cd {{ tools_mod_dir }}
TMP_VERSION=$(GOWORK=off go list -m -f "{{{{.Version}}" "{{ MODULE }}")
VERSION="${TMP_VERSION#v}"
BINARY="${TOOLS_BIN_DIR}/{{ EXECUTABLE }}"
SYMLINK="${BINARY}-${VERSION}"
if [[ ! -e "$SYMLINK" ]]; then
echo "Installing $SYMLINK"
mkdir -p "$TOOLS_BIN_DIR"
find "${TOOLS_BIN_DIR}" -lname "$BINARY" -delete
if [[ "{{ EXECUTABLE }}" == "golangci-lint" ]]; then
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "$TOOLS_BIN_DIR"
else
GOBIN="$TOOLS_BIN_DIR" go install {{ if CMD_PKG != "" { MODULE + "/" + CMD_PKG } else { MODULE } }}
fi
ln -s "$BINARY" "$SYMLINK"
fi