Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ci: stablize golangci-lint task #1007

Merged
merged 3 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 23 additions & 14 deletions .github/workflows/bot.yml
Original file line number Diff line number Diff line change
@@ -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
Expand Down
47 changes: 47 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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 }}
39 changes: 0 additions & 39 deletions .github/workflows/project.yml

This file was deleted.

22 changes: 19 additions & 3 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -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

Expand Down
11 changes: 9 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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/[email protected]

container:
docker build -t ${IMAGE_NAME} --build-arg GOLANG_IMAGE="${GOLANG_IMAGE}" \
Expand Down
1 change: 1 addition & 0 deletions pulsar/internal/http_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {

Expand Down