-
Notifications
You must be signed in to change notification settings - Fork 1
/
run
executable file
·48 lines (39 loc) · 1.5 KB
/
run
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
#!/bin/bash
# shellcheck disable=SC1090
source "$(dirname "$0")/dev/include.sh" #follow
function generate { #: Generates code for e.g. mocks
run-in-docker
cmd go generate ./...
}
function _mockgen {
# this is usually invoked indirectly via //go:generate commands in the source, downstream from `./run generate` and/or `go generate ./...`
# this lets us have much terser/clearer mockgen commands, plus automatically run in docker if needed
# usage: //go:generate $ROOTDIR/run _mockgen OutputFileSegmenter
# runs: mockgen -destination lib/output/output_file_segmenter_mock.go -package output -self_package github.com/dbsteward/dbsteward/lib/output github.com/dbsteward/dbsteward/lib/output OutputFileSegmenter
# TODO(go,nth) we can skip this if the output mock file is newer than the input file!
info "go:generate mockgen $*"
pkg="github.com/dbsteward/dbsteward/$ORELDIR"
cmd mockgen -destination "$ORIGDIR/${GOFILE%%.go}_mock.go" -package "$GOPACKAGE" -self_package "$pkg" "$pkg" "${@:1}"
}
function test { #: Runs all tests
run-in-docker
generate
cmd go test -coverprofile=profile.cov ./...
}
function dbsteward { # [...args]: Builds and runs dbsteward
run-in-docker
cmd go run . "$@"
}
function example { # [task [...args]]: Runs `example/run [task [args]]`, defaults to "all"
args=("$@")
if [ ${#args[@]} -eq 0 ]; then
args=("all")
fi
run-in-docker
cmd example/run "${args[@]}"
}
function bash { #: opens bash in the docker container
run-in-docker -it
exec bash
}
main "$@"