diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 7bd5b4a3..77f56014 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -18,6 +18,12 @@ jobs: platform: [ubuntu-latest, macos-latest, windows-latest] runs-on: ${{ matrix.platform }} steps: + - if: ${{ runner.os == 'Windows' }} + name: Use GNU tar for faster cache restore + shell: cmd + run: | + echo "Adding GNU tar to PATH" + echo C:\Program Files\Git\usr\bin>>"%GITHUB_PATH%" - name: "checkout repo" uses: actions/checkout@v3 with: diff --git a/.gitignore b/.gitignore index e613cd38..603023e6 100644 --- a/.gitignore +++ b/.gitignore @@ -7,4 +7,4 @@ test vendor work .vscode/ -.coverage* +.cover* diff --git a/Makefile b/Makefile index 2d2729a9..d190c1cf 100644 --- a/Makefile +++ b/Makefile @@ -35,19 +35,24 @@ default: cmd cmd: $(EXECUTABLE_TARGETS) -build: +build: cmd go build $(BUILDFLAGS) ./... + cd lib && go build $(BUILDFLAGS) ./... cmd_%: OUTPUT=$(patsubst cmd_%,./bin/%,$@) cmd_%: SOURCE=$(patsubst cmd_%,./cmd/%,$@) cmd_%: go build $(BUILDFLAGS) -o $(OUTPUT) $(SOURCE) -test: - go test -coverprofile=.coverage.out ./... - go tool cover -func=.coverage.out -o .coverage.func - tail -1 .coverage.func - go tool cover -html=.coverage.out -o .coverage.html +test: ./bin/gocovmerge + go test -coverprofile=.cover.pkg ./... + cd lib && go test -coverprofile=../.cover.lib ./... + ./bin/gocovmerge .cover.* > .cover + rm .cover.* + go tool cover -html=.cover -o .cover.html + +./bin/gocovmerge: + GOBIN=$(GOBIN) go install github.com/wadey/gocovmerge@master docker: docker build $(DOCKERFLAG) -t "tiproxy:${IMAGE_TAG}" --build-arg='GOPROXY=$(shell go env GOPROXY),BUILDFLAGS=$(BUILDFLAGS),' -f docker/Dockerfile . diff --git a/lib/config/namespace_test.go b/lib/config/namespace_test.go index 3b393874..003e27bc 100644 --- a/lib/config/namespace_test.go +++ b/lib/config/namespace_test.go @@ -1,3 +1,17 @@ +// Copyright 2022 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package config import ( diff --git a/lib/config/proxy_test.go b/lib/config/proxy_test.go index bdafaa2b..bb0fb41b 100644 --- a/lib/config/proxy_test.go +++ b/lib/config/proxy_test.go @@ -1,7 +1,20 @@ +// Copyright 2022 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + package config import ( - "net/url" "testing" "github.com/stretchr/testify/require" @@ -9,16 +22,10 @@ import ( var testProxyConfig = Config{ Workdir: "./wd", - LCUrlsI: []string{"http://0.0.0.0:3080"}, - ACUrlsI: []string{}, - LPUrlsI: []string{"http://0.0.0.0:3081"}, - APUrlsI: []string{}, - LCUrls: []url.URL{}, - ACUrls: []url.URL{}, - LPUrls: []url.URL{}, - APUrls: []url.URL{}, - Config: ConfigManager{ + Advance: Advance{ + PeerPort: "343", IgnoreWrongNamespace: true, + WatchInterval: "30m", }, Proxy: ProxyServer{ Addr: "0.0.0.0:4000", @@ -29,13 +36,12 @@ var testProxyConfig = Config{ }, }, API: API{ + Addr: "0.0.0.0:3080", EnableBasicAuth: false, User: "user", Password: "pwd", }, - Metrics: Metrics{ - PromCluster: "ffgfg", - }, + Metrics: Metrics{}, Log: Log{ Level: "info", Encoder: "tidb",