-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjustfile
More file actions
70 lines (56 loc) · 1.88 KB
/
justfile
File metadata and controls
70 lines (56 loc) · 1.88 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
59
60
61
62
63
64
65
66
67
68
69
70
set dotenv-load
rootdir := `git rev-parse --show-toplevel`
distdir := rootdir + '/dist'
covdir := rootdir + '/coverage'
default:
@just --list
build *args:
./release/build.sh '{{args}}'
[positional-arguments]
test *args:
#!/usr/bin/env bash
set -eEuo pipefail
cov=0
pkgs=()
argsa=(-v -race -count=1 -failfast)
argsb=()
# It would be nice if Just supported recipe flags, so we could avoid manually
# parsing arguments. See https://github.com/casey/just/issues/476
while [ "$#" -gt 0 ]; do
case $1 in
-c|--coverage) cov=1 ;;
# Other options are passed through to go test
-*) argsa+=("$1") ;;
*) pkgs+=("$1") ;;
esac
shift
done
if [ "$cov" -gt 0 ]; then
mkdir -p "{{covdir}}"
argsa+=(-coverpkg=./...)
argsb+=(-args -test.gocoverdir="{{covdir}}")
echo "Applying Go coverage workaround ..."
./bin/fix-missing-go-coverage.sh
fi
[ "${#pkgs[@]}" -eq 0 ] && pkgs=(./...)
go test "${argsa[@]}" "${pkgs[@]}" "${argsb[@]}"
if [ "$cov" -gt 0 ]; then
go tool covdata textfmt -i="{{covdir}}" -o "{{covdir}}/coverage.txt"
fcov report "{{covdir}}/coverage.txt"
fi
lint report="":
#!/usr/bin/env sh
if [ -z '{{report}}' ]; then
golangci-lint run --timeout=5m --output.tab.path=stdout --new-from-rev=1418b46a1a ./...
exit $?
fi
_report_id="$(date '+%Y%m%d')-$(git describe --tags --abbrev=10 --always)"
golangci-lint run --timeout 5m --output.tab.path=stdout --issues-exit-code=0 \
--show-stats=false ./... \
| tee "golangci-lint-${_report_id}.txt" \
| awk 'NF {if ($2 == "revive") print $2 ":" $3; else print $2}' \
| sed 's,:$,,' | sort | uniq -c | sort -nr \
| tee "golangci-lint-summary-${_report_id}.txt"
clean:
@rm -rf "{{distdir}}" "{{covdir}}" "{{rootdir}}"/golangci-lint*.txt
@git ls-files --others --exclude-standard | grep '_test\.go' | xargs -r rm