From 4093b4f27ec21dbe5c57ebea8bf0f308dda15c77 Mon Sep 17 00:00:00 2001 From: Yingchun Lai Date: Fri, 5 Jan 2024 14:50:20 +0800 Subject: [PATCH] chore(collector): add fmt job for collector CI (#1833) - Update collector README - Update the url from github.com/pegasus-kv/collector to github.com/apache/incubator-pegasus/collector - Add fmt job for collector CI --- .github/workflows/lint_and_test_collector.yml | 19 +++++++++++++++++++ collector/README.md | 16 ++++++++++++++++ collector/go.mod | 2 +- collector/main.go | 6 +++--- collector/sink/falcon_sink.go | 2 +- collector/sink/prometheus_sink.go | 2 +- collector/sink/sink.go | 2 +- collector/usage/usage_recorder.go | 2 +- collector/webui/index.go | 2 +- 9 files changed, 44 insertions(+), 9 deletions(-) diff --git a/.github/workflows/lint_and_test_collector.yml b/.github/workflows/lint_and_test_collector.yml index e257dbc93d..e21ede1a87 100644 --- a/.github/workflows/lint_and_test_collector.yml +++ b/.github/workflows/lint_and_test_collector.yml @@ -31,14 +31,32 @@ on: paths: - .github/workflows/lint_and_test_collector.yml - collector/** + - go-client/** # for manually triggering workflow workflow_dispatch: # workflow tasks jobs: + format: + name: Format + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v3 + - name: Setup Go + uses: actions/setup-go@v2 + with: + go-version: 1.18 + - name: Format + working-directory: ./go-client + run: | + gofmt -d . + test -z "$(gofmt -d .)" + lint: name: Lint + needs: format runs-on: ubuntu-20.04 steps: - name: Checkout @@ -58,6 +76,7 @@ jobs: build: name: Build + needs: lint runs-on: ubuntu-20.04 steps: - name: Checkout diff --git a/collector/README.md b/collector/README.md index 7f8b09ac2d..d05cf8c73a 100644 --- a/collector/README.md +++ b/collector/README.md @@ -26,3 +26,19 @@ Collector is a part of the Pegasus ecosystem that serves as: 1. the service availability detector 2. the hotkey detector 3. the capacity units recorder + +## Requirement + +- Go1.18+ + +## Development + +Build the collector: +```bash +make build +``` + +Format the code: +```bash +make fmt +``` diff --git a/collector/go.mod b/collector/go.mod index 9ba2888dd8..de9e22a9ee 100644 --- a/collector/go.mod +++ b/collector/go.mod @@ -15,7 +15,7 @@ // specific language governing permissions and limitations // under the License. -module github.com/pegasus-kv/collector +module github.com/apache/incubator-pegasus/collector go 1.18 diff --git a/collector/main.go b/collector/main.go index 71dd5abbf9..e42881adfc 100644 --- a/collector/main.go +++ b/collector/main.go @@ -26,9 +26,9 @@ import ( "strings" "syscall" - "github.com/pegasus-kv/collector/avail" - "github.com/pegasus-kv/collector/metrics" - "github.com/pegasus-kv/collector/webui" + "github.com/apache/incubator-pegasus/collector/avail" + "github.com/apache/incubator-pegasus/collector/metrics" + "github.com/apache/incubator-pegasus/collector/webui" log "github.com/sirupsen/logrus" "github.com/spf13/viper" "gopkg.in/natefinch/lumberjack.v2" diff --git a/collector/sink/falcon_sink.go b/collector/sink/falcon_sink.go index 906374b92d..3f27c7632d 100644 --- a/collector/sink/falcon_sink.go +++ b/collector/sink/falcon_sink.go @@ -25,7 +25,7 @@ import ( "net/http" "time" - "github.com/pegasus-kv/collector/aggregate" + "github.com/apache/incubator-pegasus/collector/aggregate" log "github.com/sirupsen/logrus" "github.com/spf13/viper" ) diff --git a/collector/sink/prometheus_sink.go b/collector/sink/prometheus_sink.go index 34d5e18841..7b62543894 100644 --- a/collector/sink/prometheus_sink.go +++ b/collector/sink/prometheus_sink.go @@ -20,7 +20,7 @@ package sink import ( "sync" - "github.com/pegasus-kv/collector/aggregate" + "github.com/apache/incubator-pegasus/collector/aggregate" "github.com/prometheus/client_golang/prometheus" ) diff --git a/collector/sink/sink.go b/collector/sink/sink.go index 361c73303e..9389e2249e 100644 --- a/collector/sink/sink.go +++ b/collector/sink/sink.go @@ -18,7 +18,7 @@ package sink import ( - "github.com/pegasus-kv/collector/aggregate" + "github.com/apache/incubator-pegasus/collector/aggregate" log "github.com/sirupsen/logrus" "github.com/spf13/viper" ) diff --git a/collector/usage/usage_recorder.go b/collector/usage/usage_recorder.go index 6a6784d39f..d031e5f745 100644 --- a/collector/usage/usage_recorder.go +++ b/collector/usage/usage_recorder.go @@ -22,8 +22,8 @@ import ( "fmt" "time" + "github.com/apache/incubator-pegasus/collector/aggregate" "github.com/apache/incubator-pegasus/go-client/pegasus" - "github.com/pegasus-kv/collector/aggregate" log "github.com/sirupsen/logrus" "github.com/spf13/viper" "gopkg.in/tomb.v2" diff --git a/collector/webui/index.go b/collector/webui/index.go index 0c0d26ff4b..948dd563ce 100644 --- a/collector/webui/index.go +++ b/collector/webui/index.go @@ -18,8 +18,8 @@ package webui import ( + "github.com/apache/incubator-pegasus/collector/aggregate" "github.com/kataras/iris/v12" - "github.com/pegasus-kv/collector/aggregate" ) var indexPageClusterStats = []string{