diff --git a/.github/workflows/bot.yml b/.github/workflows/bot.yml index eb86c5657..343963efd 100644 --- a/.github/workflows/bot.yml +++ b/.github/workflows/bot.yml @@ -1,24 +1,33 @@ -name: Bot tests +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +name: Pulsar Bot on: issue_comment: types: [created] - pull_request: - types: [closed] jobs: - bot: - runs-on: ubuntu-latest - timeout-minutes: 120 - + pulsarbot: + runs-on: ubuntu-20.04 + timeout-minutes: 10 + if: github.event_name == 'issue_comment' && contains(github.event.comment.body, '/pulsarbot') steps: - - name: checkout - uses: actions/checkout@v2 - with: - fetch-depth: 100 - ref: ${{ github.event.pull_request.head.sha }} - name: Execute pulsarbot command - id: pulsarbot - if: github.event_name == 'issue_comment' && startsWith(github.event.comment.body, '/pulsarbot') + id: pulsarbot env: GITHUB_TOKEN: ${{ secrets.GO_CLIENT_BOT_TOKEN }} BOT_TARGET_REPOSITORY: apache/pulsar-client-go diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 000000000..7c946b765 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,47 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +name: CI +on: [pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + - run: make build + + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: make lint + + integration-tests: + runs-on: ubuntu-latest + strategy: + matrix: + go-version: [1.16, 1.17, 1.18, 1.19] + steps: + - uses: actions/checkout@v3 + - name: clean docker cache + run: docker rmi $(docker images -q) -f && df -h + - uses: actions/setup-go@v3 + with: + go-version: ${{ matrix.go-version }} + - name: Run Tests + run: make test GO_VERSION=${{ matrix.go-version }} diff --git a/.github/workflows/project.yml b/.github/workflows/project.yml deleted file mode 100644 index a52a4be4f..000000000 --- a/.github/workflows/project.yml +++ /dev/null @@ -1,39 +0,0 @@ -name: CI -on: [pull_request] -jobs: - build: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 - - name: build - run: make build - - lint: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v3 - - uses: golangci/golangci-lint-action@v3 - with: - version: v1.50.1 - - integration-tests: - runs-on: ubuntu-latest - strategy: - matrix: - go-version: [1.16, 1.17, 1.18, 1.19] - steps: - - name: clean docker cache - run: | - docker rmi $(docker images -q) -f - df -h - - - uses: actions/setup-go@v3 - with: - go-version: ${{ matrix.go-version }} - - - name: Check out code into the Go module directory - uses: actions/checkout@v3 - - - name: Run Tests - run: make test GO_VERSION=${{ matrix.go-version }} diff --git a/.golangci.yml b/.golangci.yml index 2dc120a20..1f1b42c5b 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -1,6 +1,22 @@ -# Make sure golangci-lint is installed. -# https://github.com/golangci/golangci-lint#install -# We can execute `golangci-lint run` for code checking. +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you 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. + +# Run `make lint` from the root path of this project to check code with golangci-lint. + run: deadline: 6m diff --git a/Makefile b/Makefile index 231c05eb5..433db8cb7 100644 --- a/Makefile +++ b/Makefile @@ -23,12 +23,19 @@ PULSAR_IMAGE = apachepulsar/pulsar:$(PULSAR_VERSION) GO_VERSION ?= 1.18 GOLANG_IMAGE = golang:$(GO_VERSION) +# Golang standard bin directory. +GOPATH ?= $(shell go env GOPATH) +GOROOT ?= $(shell go env GOROOT) + build: go build ./pulsar go build -o bin/pulsar-perf ./perf -lint: - golangci-lint run +lint: bin/golangci-lint + bin/golangci-lint run + +bin/golangci-lint: + GOBIN=$(shell pwd)/bin go install github.com/golangci/golangci-lint/cmd/golangci-lint@v1.51.2 container: docker build -t ${IMAGE_NAME} --build-arg GOLANG_IMAGE="${GOLANG_IMAGE}" \ diff --git a/pulsar/internal/http_client.go b/pulsar/internal/http_client.go index dccc1431b..c3b38f26f 100644 --- a/pulsar/internal/http_client.go +++ b/pulsar/internal/http_client.go @@ -173,6 +173,7 @@ func (c *httpClient) GetWithQueryParams(endpoint string, obj interface{}, params return c.GetWithOptions(endpoint, obj, params, decode, nil) } +//nolint:bodyclose // false positive func (c *httpClient) GetWithOptions(endpoint string, obj interface{}, params map[string]string, decode bool, file io.Writer) ([]byte, error) {