This is an automated email from the ASF dual-hosted git repository. tison pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/pulsar-client-go.git
The following commit(s) were added to refs/heads/master by this push: new 16b1fa3 ci: stablize golangci-lint task (#1007) 16b1fa3 is described below commit 16b1fa34339843dbea5b9e57c7b2e51d3ded11a0 Author: tison <wander4...@gmail.com> AuthorDate: Mon Apr 10 23:34:43 2023 +0800 ci: stablize golangci-lint task (#1007) Modifications 1. Replace the usage of golangci-lint action with barely bin commands. 2. Support run with the specified version with one command `make lint` and store the binutil project-wise. Signed-off-by: tison <wander4...@gmail.com> --- .github/workflows/bot.yml | 37 ++++++++++++++++---------- Makefile => .github/workflows/ci.yml | 51 ++++++++++++++++++++---------------- .github/workflows/project.yml | 39 --------------------------- .golangci.yml | 22 +++++++++++++--- Makefile | 11 ++++++-- pulsar/internal/http_client.go | 1 + 6 files changed, 80 insertions(+), 81 deletions(-) diff --git a/.github/workflows/bot.yml b/.github/workflows/bot.yml index eb86c56..343963e 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/Makefile b/.github/workflows/ci.yml similarity index 52% copy from Makefile copy to .github/workflows/ci.yml index 231c05e..7c946b7 100644 --- a/Makefile +++ b/.github/workflows/ci.yml @@ -1,4 +1,3 @@ -# # 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 @@ -15,28 +14,34 @@ # KIND, either express or implied. See the License for the # specific language governing permissions and limitations # under the License. -# - -IMAGE_NAME = pulsar-client-go-test:latest -PULSAR_VERSION ?= 2.10.3 -PULSAR_IMAGE = apachepulsar/pulsar:$(PULSAR_VERSION) -GO_VERSION ?= 1.18 -GOLANG_IMAGE = golang:$(GO_VERSION) - -build: - go build ./pulsar - go build -o bin/pulsar-perf ./perf - -lint: - golangci-lint run -container: - docker build -t ${IMAGE_NAME} --build-arg GOLANG_IMAGE="${GOLANG_IMAGE}" \ - --build-arg PULSAR_IMAGE="${PULSAR_IMAGE}" . +name: CI +on: [pull_request] +jobs: + build: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-go@v3 + - run: make build -test: container - docker run -i ${IMAGE_NAME} bash -c "cd /pulsar/pulsar-client-go && ./scripts/run-ci.sh" + lint: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - run: make lint -clean: - docker rmi --force $(IMAGE_NAME) || true - rm bin/* + 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 a52a4be..0000000 --- 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 2dc120a..1f1b42c 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 231c05e..433db8c 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 dccc143..c3b38f2 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) {