File tree Expand file tree Collapse file tree 6 files changed +65
-45
lines changed Expand file tree Collapse file tree 6 files changed +65
-45
lines changed Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- source .github/lib.sh
3
+ source .github/lib.sh || exit 1
4
4
5
- gofmt -w -s .
6
- go run go.coder.com/go-tools/cmd/goimports -w " -local=$( go list -m) " .
7
- go run mvdan.cc/sh/cmd/shfmt -w -s -sr .
5
+ gen () {
6
+ # Unfortunately, this is the only way to ensure go.mod and go.sum are correct.
7
+ # See https://github.com/golang/go/issues/27005
8
+ go list ./... > /dev/null
9
+ go mod tidy
8
10
9
- if [[ $CI ]] && unstaged_files; then
11
+ go install github.com/golang/protobuf/protoc-gen-go
12
+ go generate ./...
13
+ }
14
+
15
+ fmt () {
16
+ gofmt -w -s .
17
+ go run go.coder.com/go-tools/cmd/goimports -w " -local=$( go list -m) " .
18
+ go run mvdan.cc/sh/cmd/shfmt -w -s -sr .
19
+ }
20
+
21
+ gen
22
+ fmt
23
+
24
+ if [[ $CI && $( unstaged_files) != " " ]]; then
10
25
set +x
11
26
echo
12
- echo " files are not formatted correctly "
27
+ echo " files either need generation or are formatted incorrectly "
13
28
echo " please run:"
14
29
echo " ./test.sh"
15
30
echo
Original file line number Diff line number Diff line change @@ -7,13 +7,12 @@ export PAGER=cat
7
7
8
8
# shellcheck disable=SC2034
9
9
# CI is used by the scripts that source this file.
10
- CI=${GITHUB_ACTION-}
10
+ export CI=${GITHUB_ACTION-}
11
11
12
12
if [[ $CI ]]; then
13
13
export GOFLAGS=-mod=readonly
14
14
fi
15
15
16
- function unstaged_files() {
17
- [[ $( git ls-files --other --modified --exclude-standard) != " " ]]
16
+ unstaged_files () {
17
+ git ls-files --other --modified --exclude-standard
18
18
}
19
-
Original file line number Diff line number Diff line change
1
+ FROM codercom/playcicache
2
+
3
+ LABEL "com.github.actions.name" ="lint"
4
+ LABEL "com.github.actions.description" ="lint"
5
+ LABEL "com.github.actions.icon" ="code"
6
+ LABEL "com.github.actions.color" ="purple"
7
+
8
+ COPY entrypoint.sh /entrypoint.sh
9
+
10
+ CMD ["/entrypoint.sh" ]
Original file line number Diff line number Diff line change
1
+ #! /usr/bin/env bash
2
+
3
+ source .github/lib.sh || exit 1
4
+
5
+ (
6
+ shopt -s globstar nullglob dotglob
7
+ shellcheck ./** /* .sh
8
+ )
9
+
10
+ go vet -composites=false ./...
11
+ go run golang.org/x/lint/golint -set_exit_status ./...
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- source .github/lib.sh
4
-
5
- # Unfortunately, this is the only way to ensure go.mod and go.sum are correct.
6
- # See https://github.com/golang/go/issues/27005
7
- go list ./... > /dev/null
8
- go mod tidy
9
-
10
- go install golang.org/x/tools/cmd/stringer
11
- go generate ./...
12
-
13
- if [[ $CI ]] && unstaged_files; then
14
- set +x
15
- echo
16
- echo " generated code needs an update"
17
- echo " please run:"
18
- echo " ./test.sh"
19
- echo
20
- git status
21
- exit 1
22
- fi
23
-
24
- (
25
- shopt -s globstar nullglob dotglob
26
- shellcheck ./** /* .sh
27
- )
28
-
29
- go vet -composites=false ./...
3
+ source .github/lib.sh || exit 1
30
4
31
5
COVERAGE_PROFILE=$( mktemp)
32
6
go test -race -v " -coverprofile=${COVERAGE_PROFILE} " -vet=off ./...
33
7
go tool cover " -func=${COVERAGE_PROFILE} "
34
8
35
9
if [[ $CI ]]; then
36
- bash <( curl -s https://codecov.io/bash)
10
+ bash <( curl -s https://codecov.io/bash) -f " $COVERAGE_PROFILE "
37
11
else
38
12
go tool cover " -html=${COVERAGE_PROFILE} " -o=coverage.html
13
+
14
+ set +x
15
+ echo
16
+ echo " please open coverage.html to see detailed test coverage stats"
39
17
fi
Original file line number Diff line number Diff line change 1
1
#! /usr/bin/env bash
2
2
3
- # This is for local testing. See .github for CI.
3
+ # This script is for local testing. See .github for CI.
4
4
5
- source ./.github/lib.sh
5
+ source .github/lib.sh || exit 1
6
+ cd " $( dirname " ${0} " ) "
6
7
7
8
function docker_run() {
8
- local dir=$1
9
+ local DIR=" $1 "
10
+ local IMAGE
11
+ IMAGE=" $( docker build -q " $DIR " ) "
9
12
docker run \
10
13
-v " ${PWD} :/repo" \
11
14
-v " $( go env GOPATH) :/go" \
12
15
-v " $( go env GOCACHE) :/root/.cache/go-build" \
13
16
-w /repo \
14
- " $( docker build -q " $dir " ) "
17
+ " ${IMAGE} "
15
18
}
19
+
20
+ if [[ $# -gt 0 ]]; then
21
+ docker_run " .github/$* "
22
+ exit 0
23
+ fi
24
+
16
25
docker_run .github/fmt
26
+ docker_run .github/lint
17
27
docker_run .github/test
18
-
19
- set +x
20
- echo " please open coverage.html to see detailed test coverage stats"
You can’t perform that action at this time.
0 commit comments