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 11#! /usr/bin/env bash
22
3- source .github/lib.sh
3+ source .github/lib.sh || exit 1
44
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
810
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
1025 set +x
1126 echo
12- echo " files are not formatted correctly "
27+ echo " files either need generation or are formatted incorrectly "
1328 echo " please run:"
1429 echo " ./test.sh"
1530 echo
Original file line number Diff line number Diff line change @@ -7,13 +7,12 @@ export PAGER=cat
77
88# shellcheck disable=SC2034
99# CI is used by the scripts that source this file.
10- CI=${GITHUB_ACTION-}
10+ export CI=${GITHUB_ACTION-}
1111
1212if [[ $CI ]]; then
1313 export GOFLAGS=-mod=readonly
1414fi
1515
16- function unstaged_files() {
17- [[ $( git ls-files --other --modified --exclude-standard) != " " ]]
16+ unstaged_files () {
17+ git ls-files --other --modified --exclude-standard
1818}
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 11#! /usr/bin/env bash
22
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
304
315COVERAGE_PROFILE=$( mktemp)
326go test -race -v " -coverprofile=${COVERAGE_PROFILE} " -vet=off ./...
337go tool cover " -func=${COVERAGE_PROFILE} "
348
359if [[ $CI ]]; then
36- bash <( curl -s https://codecov.io/bash)
10+ bash <( curl -s https://codecov.io/bash) -f " $COVERAGE_PROFILE "
3711else
3812 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"
3917fi
Original file line number Diff line number Diff line change 11#! /usr/bin/env bash
22
3- # This is for local testing. See .github for CI.
3+ # This script is for local testing. See .github for CI.
44
5- source ./.github/lib.sh
5+ source .github/lib.sh || exit 1
6+ cd " $( dirname " ${0} " ) "
67
78function docker_run() {
8- local dir=$1
9+ local DIR=" $1 "
10+ local IMAGE
11+ IMAGE=" $( docker build -q " $DIR " ) "
912 docker run \
1013 -v " ${PWD} :/repo" \
1114 -v " $( go env GOPATH) :/go" \
1215 -v " $( go env GOCACHE) :/root/.cache/go-build" \
1316 -w /repo \
14- " $( docker build -q " $dir " ) "
17+ " ${IMAGE} "
1518}
19+
20+ if [[ $# -gt 0 ]]; then
21+ docker_run " .github/$* "
22+ exit 0
23+ fi
24+
1625docker_run .github/fmt
26+ docker_run .github/lint
1727docker_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