Skip to content

Commit

Permalink
*: adjust the project layout (#1245)
Browse files Browse the repository at this point in the history
  • Loading branch information
rleungx authored and disksing committed Sep 20, 2018
1 parent c51ce7c commit 55db505
Show file tree
Hide file tree
Showing 57 changed files with 886 additions and 170 deletions.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@ default.pd
*.swp
.DS_Store
tags
/_tools/
/.retools/
25 changes: 13 additions & 12 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@ BASIC_TEST_PKGS := $(filter-out github.com/pingcap/pd/pkg/integration_test,$(TES
PACKAGES := go list ./...
PACKAGE_DIRECTORIES := $(PACKAGES) | sed 's|github.com/pingcap/pd/||'
GOCHECKER := awk '{ print } END { if (NR > 0) { exit 1 } }'
RETOOL:= ./hack/retool

GOFAIL_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|vendor)" | xargs retool do gofail enable)
GOFAIL_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|vendor)" | xargs retool do gofail disable)
GOFAIL_ENABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|vendor)" | xargs ./hack/retool do gofail enable)
GOFAIL_DISABLE := $$(find $$PWD/ -type d | grep -vE "(\.git|vendor)" | xargs ./hack/retool do gofail disable)

LDFLAGS += -X "$(PD_PKG)/server.PDReleaseVersion=$(shell git describe --tags --dirty)"
LDFLAGS += -X "$(PD_PKG)/server.PDBuildTS=$(shell date -u '+%Y-%m-%d %I:%M:%S')"
Expand All @@ -35,9 +36,9 @@ ifeq ("$(WITH_RACE)", "1")
else
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o bin/pd-server cmd/pd-server/main.go
endif
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o bin/pd-ctl cmd/pd-ctl/main.go
CGO_ENABLED=0 go build -o bin/pd-tso-bench cmd/pd-tso-bench/main.go
CGO_ENABLED=0 go build -o bin/pd-recover cmd/pd-recover/main.go
CGO_ENABLED=0 go build -ldflags '$(LDFLAGS)' -o bin/pd-ctl tools/pd-ctl/main.go
CGO_ENABLED=0 go build -o bin/pd-tso-bench tools/pd-tso-bench/main.go
CGO_ENABLED=0 go build -o bin/pd-recover tools/pd-recover/main.go

test: retool-setup
# testing..
Expand All @@ -52,34 +53,34 @@ basic_test:

# These need to be fixed before they can be ran regularly
check-fail:
CGO_ENABLED=0 retool do gometalinter.v2 --disable-all \
CGO_ENABLED=0 ./hack/retool do gometalinter.v2 --disable-all \
--enable errcheck \
$$($(PACKAGE_DIRECTORIES))
CGO_ENABLED=0 retool do gosec $$($(PACKAGE_DIRECTORIES))
CGO_ENABLED=0 ./hack/retool do gosec $$($(PACKAGE_DIRECTORIES))

check-all: static lint
@echo "checking"

retool-setup:
@which retool >/dev/null 2>&1 || go get github.com/twitchtv/retool
@retool sync
@./hack/retool sync

check: retool-setup check-all

static:
@ # Not running vet and fmt through metalinter becauase it ends up looking at vendor
gofmt -s -l $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(GOCHECKER)
retool do govet --shadow $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(GOCHECKER)
./hack/retool do govet --shadow $$($(PACKAGE_DIRECTORIES)) 2>&1 | $(GOCHECKER)

CGO_ENABLED=0 retool do gometalinter.v2 --disable-all --deadline 120s \
CGO_ENABLED=0 ./hack/retool do gometalinter.v2 --disable-all --deadline 120s \
--enable misspell \
--enable megacheck \
--enable ineffassign \
$$($(PACKAGE_DIRECTORIES))

lint:
@echo "linting"
CGO_ENABLED=0 retool do revive -formatter friendly -config revive.toml $$($(PACKAGES))
CGO_ENABLED=0 ./hack/retool do revive -formatter friendly -config revive.toml $$($(PACKAGES))

travis_coverage:
ifeq ("$(TRAVIS_COVERAGE)", "1")
Expand All @@ -100,7 +101,7 @@ endif
bash ./hack/clean_vendor.sh

simulator:
CGO_ENABLED=0 go build -o bin/simulator cmd/simulator/main.go
CGO_ENABLED=0 go build -o bin/pd-simulator tools/pd-simulator/main.go

gofail-enable:
# Converting gofail failpoints...
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
4 changes: 0 additions & 4 deletions cmd/README.md

This file was deleted.

8 changes: 8 additions & 0 deletions hack/retool
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env bash
#
# Add standard retool options
set -euo pipefail


cd $(dirname "$0")/..
exec retool -tool-dir "$PWD/.retools" "$@"
20 changes: 11 additions & 9 deletions hack/retool-install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -3,21 +3,23 @@ set -euo pipefail

# This script generates tools.json
# It helps record what releases/branches are being used

cd $(dirname "$0")/..
which retool >/dev/null || go get github.com/twitchtv/retool

# tool environment
# check runner
retool add gopkg.in/alecthomas/gometalinter.v2 v2.0.5
./hack/retool add gopkg.in/alecthomas/gometalinter.v2 v2.0.5
# check spelling
retool add github.com/client9/misspell/cmd/misspell v0.3.4
./hack/retool add github.com/client9/misspell/cmd/misspell v0.3.4
# checks correctness
retool add github.com/gordonklaus/ineffassign 7bae11eba15a3285c75e388f77eb6357a2d73ee2
retool add honnef.co/go/tools/cmd/megacheck master
retool add github.com/dnephin/govet 4a96d43e39d340b63daa8bc5576985aa599885f6
./hack/retool add github.com/gordonklaus/ineffassign 7bae11eba15a3285c75e388f77eb6357a2d73ee2
./hack/retool add honnef.co/go/tools/cmd/megacheck master
./hack/retool add github.com/dnephin/govet 4a96d43e39d340b63daa8bc5576985aa599885f6
# slow checks
retool add github.com/kisielk/errcheck v1.1.0
./hack/retool add github.com/kisielk/errcheck v1.1.0
# linter
retool add github.com/mgechev/revive 7773f47324c2bf1c8f7a5500aff2b6c01d3ed73b
retool add github.com/securego/gosec/cmd/gosec 1.0.0
./hack/retool add github.com/mgechev/revive 7773f47324c2bf1c8f7a5500aff2b6c01d3ed73b
./hack/retool add github.com/securego/gosec/cmd/gosec 1.0.0
# go fail
retool add github.com/etcd-io/gofail master
./hack/retool add github.com/etcd-io/gofail master
103 changes: 0 additions & 103 deletions pdctl/README.md

This file was deleted.

2 changes: 1 addition & 1 deletion pkg/integration_test/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import (

"github.com/coreos/etcd/clientv3"
. "github.com/pingcap/check"
pd "github.com/pingcap/pd/pd-client"
pd "github.com/pingcap/pd/client"
"github.com/pingcap/pd/pkg/testutil"
)

Expand Down
4 changes: 2 additions & 2 deletions server/testutil.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ func NewTestServer() (*Config, *Server, CleanupFunc, error) {
}

// NewTestSingleConfig is only for test to create one pd.
// Because pd-client also needs this, so export here.
// Because PD client also needs this, so export here.
func NewTestSingleConfig() *Config {
cfg := &Config{
Name: "pd",
Expand Down Expand Up @@ -93,7 +93,7 @@ func NewTestSingleConfig() *Config {
}

// NewTestMultiConfig is only for test to create multiple pd configurations.
// Because pd-client also needs this, so export here.
// Because PD client also needs this, so export here.
func NewTestMultiConfig(count int) []*Config {
cfgs := make([]*Config, count)

Expand Down
Loading

0 comments on commit 55db505

Please sign in to comment.