Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add checkstyle check and fix script for go deps #1491

Merged
merged 10 commits into from
Jan 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
31 changes: 24 additions & 7 deletions .github/workflows/checkstyle.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ jobs:
- name: Checkout
uses: actions/checkout@v1

- name: Setup go
uses: actions/setup-go@v2
with:
go-version: "1.17.2" # Keep in sync with WORKSPACE

- name: gofmt
run: |
gofmt -d . > gofmt-diff.txt || true
Expand All @@ -25,18 +30,27 @@ jobs:

- name: buildifier
run: |
go get -u github.com/bazelbuild/buildtools/buildifier
go install github.com/bazelbuild/buildtools/buildifier@3.4.0
"$(go env GOPATH)/bin/buildifier" -d -r . > buildifier-diff.txt || true
echo "buildifier diff:"
cat buildifier-diff.txt

- name: gazelle
# Keep Gazelle version in sync with WORKSPACE
run: |
go get github.com/bazelbuild/bazel-gazelle/cmd/gazelle
go install github.com/bazelbuild/bazel-gazelle/cmd/gazelle@v0.23.0
"$(go env GOPATH)/bin/gazelle" -mode diff > gazelle-diff.txt || true
echo "gazelle diff:"
cat gazelle-diff.txt

- name: go deps
# Keep Gazelle version in sync with WORKSPACE
run: |
go install github.com/bazelbuild/bazel-gazelle/cmd/gazelle@v0.23.0
GAZELLE_PATH="$(go env GOPATH)/bin/gazelle" tools/fix_go_deps.sh --diff &> go-deps-diff.txt || true
echo "go deps diff:"
cat go-deps-diff.txt

- name: clang-format
run: |
git ls-files | grep '\.proto$' | xargs --no-run-if-empty -d'\n' clang-format -i --style=Google --dry-run &> clang-format-errors.txt || true
Expand All @@ -58,18 +72,21 @@ jobs:

- name: Check
run: |
echo "===== gofmt diff ====="
echo "===== gofmt diff (fix with ./buildfix.sh) ====="
cat gofmt-diff.txt
echo "===== buildifier diff ====="
echo "===== buildifier diff (fix with ./buildfix.sh) ====="
cat buildifier-diff.txt
echo "===== gazelle diff ====="
echo "===== gazelle diff (fix with ./buildfix.sh --gazelle) ====="
cat gazelle-diff.txt
echo "===== clang-format errors ====="
echo "===== go deps diff (fix with ./buildfix.sh --go_deps) ====="
cat go-deps-diff.txt
echo "===== clang-format errors (fix with ./buildfix.sh) ====="
cat clang-format-errors.txt
echo "===== prettier errors ====="
echo "===== prettier errors (fix with ./buildfix.sh) ====="
cat prettier-errors.txt

if [ -s gazelle-diff.txt ]; then exit 1; fi
if [ -s go-deps-diff.txt ]; then exit 1; fi
if [ -s gofmt-diff.txt ]; then exit 1; fi
if [ -s buildifier-diff.txt ]; then exit 1; fi
if [ -s clang-format-errors.txt ]; then exit 1; fi
Expand Down
3 changes: 2 additions & 1 deletion WORKSPACE
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ http_archive(
http_archive(
name = "bazel_gazelle",
sha256 = "62ca106be173579c0a167deb23358fdfe71ffa1e4cfdddf5582af26520f1c66f",
# Keep version in sync with .github/workflows/checkstyle.yaml
urls = [
"https://mirror.bazel.build/github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
"https://github.com/bazelbuild/bazel-gazelle/releases/download/v0.23.0/bazel-gazelle-v0.23.0.tar.gz",
Expand All @@ -34,7 +35,7 @@ go_download_sdk(
name = "go_sdk_linux",
goarch = "amd64",
goos = "linux",
version = "1.17.2",
version = "1.17.2", # Keep in sync with .github/workflows/checkstyle.yaml
)

go_download_sdk(
Expand Down
25 changes: 23 additions & 2 deletions buildfix.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,23 @@ cd "$(dirname "$0")"
# If ~/go/bin exists, make sure we respect it
export PATH="$PATH:$HOME/go/bin"

gazelle=$([[ "${1:-}" == '-g' ]] || [[ "${1:-}" == '--gazelle' ]] && echo 1 || echo 0)
GAZELLE=0
GO_DEPS=0
while [[ $# -gt 0 ]]; do
case $1 in
-a | --all)
GAZELLE=1
GO_DEPS=1
;;
-g | --gazelle)
GAZELLE=1
;;
-d | --go_deps)
GO_DEPS=1
;;
esac
shift
done

c_yellow="\x1b[33m"
c_reset="\x1b[0m"
Expand Down Expand Up @@ -39,7 +55,7 @@ else
bazel run //tools/prettier:fix
fi

if ((gazelle)); then
if ((GAZELLE)); then
echo "Fixing BUILD deps with gazelle..."
if which gazelle &>/dev/null; then
gazelle
Expand All @@ -48,4 +64,9 @@ if ((gazelle)); then
fi
fi

if ((GO_DEPS)); then
echo "Fixing go.mod, go.sum, and deps.bzl..."
GAZELLE_PATH=$(which gazelle || true) ./tools/fix_go_deps.sh
fi

echo 'All done!'
16 changes: 8 additions & 8 deletions deps.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,8 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
go_repository(
name = "com_github_cockroachdb_pebble",
importpath = "github.com/cockroachdb/pebble",
sum = "h1:dqFirML/6RMDwkge7Tqf33qE0ORbF6rRJOLjCmmwTNg=",
version = "v0.0.0-20210331181633-27fc006b8bfb",
sum = "h1:9Ydk2DZyu/YEL1W7Kha7Ax78R2rUvbTgS/U2nW3O8iw=",
version = "v0.0.0-20210406181039-e3809b89b488",
)
go_repository(
name = "com_github_cockroachdb_redact",
Expand Down Expand Up @@ -773,8 +773,8 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
go_repository(
name = "com_github_datadog_zstd",
importpath = "github.com/DataDog/zstd",
sum = "h1:+K/VEwIAaPcHiMtQvpLD4lqW7f0Gk3xdYZmI1hD+CXo=",
version = "v1.5.0",
sum = "h1:EndNeuB0l9syBZhut0wns3gV1hL8zX8LIu6ZiVHWLIQ=",
version = "v1.4.5",
)

go_repository(
Expand Down Expand Up @@ -1614,8 +1614,8 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
go_repository(
name = "com_github_golang_snappy",
importpath = "github.com/golang/snappy",
sum = "h1:fHPg5GQYlCeLIPB9BZqMVR5nR9A+IM5zcgeTdjMYmLA=",
version = "v0.0.3",
sum = "h1:vsBwDpPr442gOtutTvPdgJ0xhaUI/1uX53JosuHzIRE=",
version = "v0.0.4-0.20210502035320-33fc3d5d8d99",
)

go_repository(
Expand Down Expand Up @@ -2567,8 +2567,8 @@ def install_buildbuddy_dependencies(workspace_name = "buildbuddy"):
go_repository(
name = "com_github_lni_goutils",
importpath = "github.com/lni/goutils",
sum = "h1:oBhV7Z5DjNWbcy/c3fFj6qo4SnHcpyTY28qfKvLy6UM=",
version = "v1.3.0",
sum = "h1:R+GuqvAnPJsA/kRZn1w9+/m0rz7HIt2yVLFUCpKhWNA=",
version = "v1.3.1-0.20210517080819-7f56813dc438",
)
go_repository(
name = "com_github_lni_vfs",
Expand Down
54 changes: 35 additions & 19 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -5,26 +5,27 @@ go 1.17
replace (
github.com/firecracker-microvm/firecracker-go-sdk => github.com/tylerwilliams/firecracker-go-sdk v0.22.1
github.com/go-redsync/redsync/v4 v4.4.1 => github.com/bduffany/redsync/v4 v4.4.1-minimal
github.com/lni/dragonboat/v3 => github.com/tylerwilliams/dragonboat/v3 v3.3.4-rc2
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thankyou!

)

require (
cloud.google.com/go/storage v1.15.0
github.com/Azure/azure-storage-blob-go v0.14.0
github.com/GoogleCloudPlatform/cloudsql-proxy v1.17.0
github.com/aws/aws-sdk-go v1.35.37
github.com/bazelbuild/bazelisk v1.11.0
github.com/bazelbuild/rules_go v0.29.0
github.com/bazelbuild/rules_webtesting v0.2.0
github.com/bojand/ghz v0.95.0
github.com/bradfitz/gomemcache v0.0.0-20190913173617-a41fca850d0b
github.com/cespare/xxhash/v2 v2.1.1
github.com/cockroachdb/errors v1.8.6 // indirect
github.com/containerd/containerd v1.5.2 // indirect
github.com/cockroachdb/pebble v0.0.0-20210406181039-e3809b89b488
github.com/coreos/go-oidc v2.2.1+incompatible
github.com/creack/pty v1.1.17
github.com/crewjam/saml v0.4.5
github.com/dgrijalva/jwt-go v3.2.0+incompatible
github.com/docker/distribution v2.7.1+incompatible
github.com/docker/docker v20.10.7+incompatible
github.com/docker/go-connections v0.4.0 // indirect
github.com/docker/go-units v0.4.0
github.com/elastic/gosigar v0.11.0
github.com/firecracker-microvm/firecracker-go-sdk v0.0.0-00010101000000-000000000000
Expand All @@ -37,31 +38,24 @@ require (
github.com/golang/protobuf v1.5.2
github.com/google/go-cmp v0.5.6
github.com/google/go-github v17.0.0+incompatible
github.com/google/go-querystring v1.0.0 // indirect
github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510
github.com/google/uuid v1.2.0
github.com/groob/plist v0.0.0-20210519001750-9f754062e6d6
github.com/grpc-ecosystem/go-grpc-prometheus v1.2.0
github.com/hanwen/go-fuse/v2 v2.1.0
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/hashicorp/golang-lru v0.5.4
github.com/hashicorp/memberlist v0.3.0
github.com/hashicorp/serf v0.9.6
github.com/jessevdk/go-flags v1.4.0
github.com/jhump/protoreflect v1.8.2
github.com/jsimonetti/rtnetlink v0.0.0-20210714135244-af39de65d6ad
github.com/klauspost/compress v1.14.1
github.com/klauspost/pgzip v1.2.5
github.com/lestrrat-go/jwx v1.2.11
github.com/lni/dragonboat/v3 v3.3.4 // indirect
github.com/lni/vfs v0.2.0 // indirect
github.com/lni/dragonboat/v3 v3.3.4
github.com/logrusorgru/aurora v2.0.3+incompatible
github.com/mattn/go-shellwords v1.0.11
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/mdlayher/vsock v0.0.0-20210303205602-10d591861736
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/pkg/errors v0.9.1
github.com/pquerna/cachecontrol v0.0.0-20201205024021-ac21108117ac // indirect
github.com/prometheus/client_golang v1.7.1
github.com/rs/zerolog v1.20.0
github.com/sirupsen/logrus v1.8.0
Expand All @@ -76,11 +70,10 @@ require (
go.opentelemetry.io/otel/sdk v1.2.0
go.opentelemetry.io/otel/trace v1.2.0
golang.org/x/crypto v0.0.0-20210322153248-0c34fe9e7dc2
golang.org/x/mod v0.4.2
golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c
golang.org/x/sys v0.0.0-20211210111614-af8b64212486
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
google.golang.org/api v0.63.0
google.golang.org/genproto v0.0.0-20220118154757-00ab72f36ad5
google.golang.org/grpc v1.43.0
Expand All @@ -97,24 +90,30 @@ require (
cloud.google.com/go/iam v0.1.0 // indirect
github.com/Azure/azure-pipeline-go v0.2.3 // indirect
github.com/BurntSushi/toml v0.3.1 // indirect
github.com/DataDog/zstd v1.4.5 // indirect
github.com/Microsoft/go-winio v0.4.17 // indirect
github.com/PuerkitoBio/purell v1.1.1 // indirect
github.com/PuerkitoBio/urlesc v0.0.0-20170810143723-de5bf2ad4578 // indirect
github.com/VictoriaMetrics/metrics v1.6.2 // indirect
github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751 // indirect
github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da // indirect
github.com/asaskevich/govalidator v0.0.0-20200428143746-21a406dcc535 // indirect
github.com/bazelbuild/bazelisk v1.11.0 // indirect
github.com/beevik/etree v1.1.0 // indirect
github.com/beorn7/perks v1.0.1 // indirect
github.com/blang/semver v3.5.1+incompatible // indirect
github.com/cockroachdb/errors v1.8.6 // indirect
github.com/cockroachdb/logtags v0.0.0-20190617123548-eb05cc24525f // indirect
github.com/cockroachdb/redact v1.1.1 // indirect
github.com/cockroachdb/sentry-go v0.6.1-cockroachdb.2 // indirect
github.com/containerd/containerd v1.5.2 // indirect
github.com/containerd/fifo v1.0.0 // indirect
github.com/containernetworking/cni v0.8.1 // indirect
github.com/containernetworking/plugins v0.9.1 // indirect
github.com/creack/pty v1.1.17 // indirect
github.com/crewjam/httperr v0.0.0-20190612203328-a946449404da // indirect
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.0-20210816181553-5444fa50b93d // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
github.com/docker/go-connections v0.4.0 // indirect
github.com/emirpasic/gods v1.12.0 // indirect
github.com/felixge/httpsnoop v1.0.2 // indirect
github.com/go-git/gcfg v1.5.0 // indirect
Expand All @@ -135,12 +134,16 @@ require (
github.com/goccy/go-json v0.7.10 // indirect
github.com/gofrs/uuid v3.3.0+incompatible // indirect
github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e // indirect
github.com/golang/snappy v0.0.4-0.20210502035320-33fc3d5d8d99 // indirect
github.com/google/btree v1.0.0 // indirect
github.com/google/go-querystring v1.0.0 // indirect
github.com/googleapis/gax-go/v2 v2.1.1 // indirect
github.com/hashicorp/errwrap v1.0.0 // indirect
github.com/hashicorp/go-immutable-radix v1.0.0 // indirect
github.com/hashicorp/go-msgpack v0.5.3 // indirect
github.com/hashicorp/go-multierror v1.1.0 // indirect
github.com/hashicorp/go-sockaddr v1.0.0 // indirect
github.com/hashicorp/go-version v1.3.0 // indirect
github.com/imdario/mergo v0.3.11 // indirect
github.com/jbenet/go-context v0.0.0-20150711004518-d14ea06fba99 // indirect
github.com/jinzhu/configor v1.1.1 // indirect
Expand All @@ -150,32 +153,43 @@ require (
github.com/jonboulle/clockwork v0.2.1 // indirect
github.com/josharian/intern v1.0.0 // indirect
github.com/josharian/native v0.0.0-20200817173448-b6b71def0850 // indirect
github.com/juju/ratelimit v1.0.2-0.20191002062651-f60b32039441 // indirect
github.com/kevinburke/ssh_config v0.0.0-20190725054713-01f96b0aa0cd // indirect
github.com/kr/pretty v0.2.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/lestrrat-go/backoff/v2 v2.0.8 // indirect
github.com/lestrrat-go/blackmagic v1.0.0 // indirect
github.com/lestrrat-go/httpcc v1.0.0 // indirect
github.com/lestrrat-go/iter v1.0.1 // indirect
github.com/lestrrat-go/option v1.0.0 // indirect
github.com/lni/goutils v1.3.1-0.20210517080819-7f56813dc438 // indirect
github.com/lni/vfs v0.2.0 // indirect
github.com/magefile/mage v1.10.0 // indirect
github.com/mailru/easyjson v0.7.6 // indirect
github.com/mattermost/xml-roundtrip-validator v0.0.0-20201213122252-bcd7e1b9601e // indirect
github.com/mattn/go-ieproxy v0.0.1 // indirect
github.com/mattn/go-sqlite3 v2.0.3+incompatible // indirect
github.com/matttproud/golang_protobuf_extensions v1.0.2-0.20181231171920-c182affec369 // indirect
github.com/mdlayher/netlink v1.4.1 // indirect
github.com/mdlayher/socket v0.0.0-20210307095302-262dc9984e00 // indirect
github.com/miekg/dns v1.1.41 // indirect
github.com/mitchellh/go-homedir v1.1.0 // indirect
github.com/mitchellh/mapstructure v1.3.2 // indirect
github.com/moby/term v0.0.0-20201216013528-df9cb8a40635 // indirect
github.com/morikuni/aec v1.0.0 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/opencontainers/image-spec v1.0.1 // indirect
github.com/opentracing/opentracing-go v1.2.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/pquerna/cachecontrol v0.0.0-20201205024021-ac21108117ac // indirect
github.com/prometheus/client_model v0.2.0 // indirect
github.com/prometheus/common v0.10.0 // indirect
github.com/prometheus/procfs v0.6.0 // indirect
github.com/russellhaering/goxmldsig v1.1.0 // indirect
github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 // indirect
github.com/sergi/go-diff v1.1.0 // indirect
github.com/valyala/fastrand v1.0.0 // indirect
github.com/valyala/histogram v1.0.1 // indirect
github.com/vishvananda/netns v0.0.0-20200728191858-db3c7e526aae // indirect
github.com/xanzy/ssh-agent v0.2.1 // indirect
go.mongodb.org/mongo-driver v1.4.2 // indirect
Expand All @@ -185,15 +199,17 @@ require (
go.uber.org/atomic v1.5.0 // indirect
go.uber.org/multierr v1.3.0 // indirect
go.uber.org/tools v0.0.0-20190618225709-2cfd321de3ee // indirect
golang.org/x/exp v0.0.0-20200513190911-00229845015e // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.4.2 // indirect
golang.org/x/net v0.0.0-20210525063256-abc453219eb5 // indirect
golang.org/x/net v0.0.0-20210614182718-04defd469f4e // indirect
golang.org/x/term v0.0.0-20210220032956-6a3ed077a48d // indirect
golang.org/x/text v0.3.6 // indirect
golang.org/x/time v0.0.0-20210723032227-1f47c861a9ac // indirect
golang.org/x/tools v0.1.5 // indirect
golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect
google.golang.org/appengine v1.6.7 // indirect
gopkg.in/square/go-jose.v2 v2.5.1 // indirect
gopkg.in/warnings.v0 v0.1.2 // indirect
gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776 // indirect
gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b // indirect
honnef.co/go/tools v0.0.1-2020.1.5 // indirect
)
Loading