Skip to content

Commit b3e02a4

Browse files
committed
Don't call linters/test tools by import path
1 parent c9aea9b commit b3e02a4

File tree

3 files changed

+42
-7
lines changed

3 files changed

+42
-7
lines changed

.github/workflows/build.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,17 @@ jobs:
2525
run: |
2626
go get -v -t -d ./...
2727
28+
- name: Install linters
29+
run: |
30+
go get golang.org/x/lint/golint
31+
go get github.com/golangci/golangci-lint/cmd/golangci-lint
32+
2833
- name: Lint Go source code
2934
run: zsh run-tests.sh -vl
3035

36+
- name: Install test dependencies
37+
run: go get github.com/mfridman/tparse
38+
3139
- name: Run unit tests
3240
run: zsh run-tests.sh -ic ./...
3341

azure-pipelines.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,22 @@ steps:
4545
workingDirectory: '$(modulePath)'
4646
displayName: Fetch Code
4747

48+
- script: |
49+
go get golang.org/x/lint/golint
50+
go get github.com/golangci/golangci-lint/cmd/golangci-lint
51+
workingDirectory: '$(modulePath)'
52+
displayName: Install Linters
53+
4854
- script: |
4955
./run-tests.sh -l
5056
workingDirectory: '$(modulePath)'
5157
displayName: Lint
5258

59+
- script: |
60+
go get github.com/mfridman/tparse
61+
workingDirectory: '$(modulePath)'
62+
displayName: Install Test Dependences
63+
5364
- script: |
5465
./run-tests.sh -ic ./...
5566
workingDirectory: '$(modulePath)'

run-tests.sh

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
#!/usr/bin/env zsh
22

3-
root="$( git rev-parse --show-toplevel )"
3+
root="$( git rev-parse --show-toplevel 2>/dev/null )"
44
testdir="${root}/testenv"
55
iplist="${root}/info.plist"
66
covfile="${root}/coverage.out"
77
covhtml="${root}/coverage.html"
88

99
verbose=false
10+
runinstall=false
1011
runlint=false
1112
runtests=true
1213
opencover=false
@@ -30,6 +31,18 @@ installed() {
3031
return $?
3132
}
3233

34+
# install <import-address> | Install Go program if it's not already installed
35+
install() {
36+
local p=$1
37+
local name=${p:t}
38+
installed "$name" || {
39+
log "installing $name ..."
40+
GO111MODULE=off go get -u $gopts $p
41+
[[ $? -eq 0 ]] || fail "install $name failed"
42+
success "installed $name"
43+
}
44+
}
45+
3346
# success <arg>... | Write message in green to STDOUT
3447
success() {
3548
$verbose || return 0
@@ -110,7 +123,6 @@ while getopts ":CcghilrtvV" opt; do
110123
vopt='-v'
111124
;;
112125
v)
113-
gopts+=(-v)
114126
verbose=true
115127
;;
116128
h)
@@ -131,11 +143,13 @@ $runlint && {
131143
}
132144
success "all files formatted correctly"
133145

134-
go run golang.org/x/lint/golint -set_exit_status ./...
146+
install golang.org/x/lint/golint
147+
golint -set_exit_status ./...
135148
[[ $? -eq 0 ]] || fail "linting with golint failed"
136149
success "golint found no issues"
137150

138-
go run github.com/golangci/golangci-lint/cmd/golangci-lint run -c .golangci.toml
151+
install github.com/golangci/golangci-lint/cmd/golangci-lint
152+
golangci-lint run -c .golangci.toml
139153
[[ $? -eq 0 ]] || fail "linting with golangci-lint failed"
140154
success "golangci-lint found no issues"
141155
exit 0
@@ -158,7 +172,8 @@ pkgs=(./...)
158172

159173
st=0
160174
$runtests && {
161-
go test -cover -json $gopts $pkgs | go run github.com/mfridman/tparse
175+
install github.com/mfridman/tparse
176+
go test -cover -json $gopts $pkgs | tparse
162177
# gotestsum -- $gopts $pkgs
163178
st=$?
164179
[[ $st -eq 0 ]] && success "unit tests passed"
@@ -170,8 +185,9 @@ cd -
170185

171186
$opencover && {
172187
$usegocov && {
173-
go run github.com/axw/gocov/gocov convert "$covfile" \
174-
| go run github.com/matm/gocov-html > "$covhtml"
188+
install github.com/axw/gocov/gocov
189+
install github.com/matm/gocov-html
190+
gocov convert "$covfile" | gocov-html > "$covhtml"
175191
open "$covhtml"
176192
} || {
177193
go tool cover -html="$covfile"

0 commit comments

Comments
 (0)