-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy path.justfile
More file actions
58 lines (45 loc) · 2.13 KB
/
.justfile
File metadata and controls
58 lines (45 loc) · 2.13 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
set dotenv-load := true
test_dir := join("internal", "test")
testdata_dir := join(test_dir, "testdata")
tools_mod_dir := join(justfile_directory(), "tools")
export TOOLS_BIN_DIR := join(env_var_or_default("XDG_CACHE_HOME", join(env_var("HOME"), ".cache")), "cerbos/protoc-gen-jsonschema/bin")
default:
@ just --list
compile:
@ go build -o bin/protoc-gen-jsonschema cmd/protoc-gen-jsonschema/main.go
deps:
@ go mod tidy
# Run after testproto package is modified to generate new testdata
generate-testdata: _buf
@ rm -rf {{ testdata_dir }}/code_generator_request.pb.bin
@ cd {{ test_dir }} && "${TOOLS_BIN_DIR}/buf" generate .
lint: _golangcilint _buf
@ "${TOOLS_BIN_DIR}/golangci-lint" run --config=.golangci.yaml --fix
@ "${TOOLS_BIN_DIR}/buf" format -w
tests PKG='./...' TEST='.*': _gotestsum
@ "${TOOLS_BIN_DIR}/gotestsum" --format=dots-v2 --format-hide-empty-pkg -- -tags=tests,integration -failfast -count=1 -run='{{ TEST }}' '{{ PKG }}'
install:
@ go install ./cmd/protoc-gen-jsonschema
_buf: (_install "buf" "github.com/bufbuild/buf" "cmd/buf")
_golangcilint: (_install "golangci-lint" "github.com/golangci/golangci-lint/v2" "cmd/golangci-lint")
_gotestsum: (_install "gotestsum" "gotest.tools/gotestsum")
_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" 1>&2
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" "v${VERSION}"
else
export CGO_ENABLED={{ if EXECUTABLE =~ "(^sql|^tbls)" { "1" } else { "0" } }}
GOWORK=off GOBIN="$TOOLS_BIN_DIR" go install {{ if CMD_PKG != "" { MODULE + "/" + CMD_PKG } else { MODULE } }}@v${VERSION}
fi
ln -s "$BINARY" "$SYMLINK"
fi