-
Notifications
You must be signed in to change notification settings - Fork 14
/
test.sh
executable file
·56 lines (46 loc) · 1.14 KB
/
test.sh
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
#!/bin/bash
set -euo pipefail
RUNALL=false
DEPENDENCIES=false
TESTS=false
BUILD=false
LINTER=false
print_usage() {
echo "Program usage: [./script.sh flags]
Flag: -a [Run everything bellow]
Flag: -d [Get dependencies]
Flag: -t [Run tests with coverage]
Flag: -b [Run a build as test]
Flag: -l [Run golangci-lint]
Flag: -h [Print help message]
"
}
while getopts 'hadtbl' flag; do
case "${flag}" in
h) print_usage
exit 0 ;;
a) RUNALL=true ;;
d) DEPENDENCIES=true ;;
t) TESTS=true ;;
b) BUILD=true ;;
l) LINTER=true ;;
*) print_usage
exit 1 ;;
esac
done
if [[ ${DEPENDENCIES} == true || ${RUNALL} == true ]]; then
echo "Get dependencies"
go get -v -t -d ./...
fi
if [[ ${LINTER} == true || ${RUNALL} == true ]]; then
echo "Run golangci-lint"
golangci-lint run --timeout 5m
fi
if [[ ${TESTS} == true || ${RUNALL} == true ]]; then
echo "Run test with coverage"
go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic
fi
if [[ ${BUILD} == true || ${RUNALL} == true ]]; then
echo "Run a build as test"
go build -v cmd/lcm/main.go
fi