Skip to content

Update GitHub Actions and fix linter issues #2

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
22 changes: 11 additions & 11 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,17 @@ name: lint
on: [ pull_request ]

jobs:
lint:
golangci:
name: lint
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v1
with:
go-version: 1.19.x

- name: Checkout code
uses: actions/checkout@v1

- name: Run Lint
run: make lint
- uses: actions/checkout@v3
- uses: actions/setup-go@v4
with:
go-version: '1.20'
cache: false
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with:
version: v1.54
args: --deadline 10m -v
23 changes: 14 additions & 9 deletions .github/workflows/unittest.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
name: unittest
on: [ push, pull_request ]
on:
push:
branches:
- master
pull_request:

jobs:
unittest:
Expand All @@ -11,22 +15,23 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Setup Go
uses: actions/setup-go@v1
uses: actions/setup-go@v4
with:
go-version: ${{ matrix.go-version }}

- name: Setup Java
uses: actions/setup-java@v1
uses: actions/setup-java@v3
with:
java-version: 14
distribution: 'temurin'
java-version: '17'

- name: Checkout code
uses: actions/checkout@v1
uses: actions/checkout@v4

- name: Test code
run: make test ZK_VERSION=${{ matrix.zk-version }}

- name: Upload code coverage
uses: codecov/codecov-action@v1
with:
file: ./profile.cov
# - name: Upload code coverage
# uses: codecov/codecov-action@v3
# with:
# file: ./profile.cov
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
.vscode/
.idea
.DS_Store
profile.cov
coverage.xml
bin/
zookeeper
zookeeper-*/
zookeeper-*.tar.gz
Expand Down
65 changes: 40 additions & 25 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,11 +1,8 @@

REPO_ROOT = $(shell pwd -P)
TOOLS_BINDIR = $(REPO_ROOT)/tools/bin
GOTESTSUM_BIN = $(TOOLS_BINDIR)/gotestsum
GOLANGCI_LINT_BIN ?= $(TOOLS_BINDIR)/golangci-lint

PACKAGES := $(shell go list ./... | grep -v examples)

GOLANGCILINT_VERSION = 1.54
GOTESTSUM_VERSION = 1.8.2
# make file to hold the logic of build and test setup
ZK_VERSION ?= 3.6.2

Expand All @@ -18,49 +15,49 @@ else
endif
ZK_URL = "https://archive.apache.org/dist/zookeeper/zookeeper-$(ZK_VERSION)/$(ZK).tar.gz"

# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
ifeq (,$(shell go env GOBIN))
GOBIN=$(shell go env GOPATH)/bin
else
GOBIN=$(shell go env GOBIN)
endif

.DEFAULT_GOAL := test

$(ZK):
validate-java:
which java

$(ZK): validate-java
wget $(ZK_URL)
tar -zxf $(ZK).tar.gz
rm $(ZK).tar.gz

zookeeper: $(ZK)
# we link to a standard directory path so then the tests dont need to find based on version
# in the test code. this allows backward compatable testing.
# in the test code. this allows backward compatible testing.
ln -s $(ZK) zookeeper

.PHONY: setup
setup: zookeeper tools

.PHONY: tools
tools: tools/tools.go tools/go.mod
mkdir -p "$(TOOLS_BINDIR)"
cd tools && \
export GOBIN="${TOOLS_BINDIR}" && \
go install \
github.com/golangci/golangci-lint/cmd/golangci-lint \
gotest.tools/gotestsum && \
cd ..
setup: zookeeper

.PHONY: lint
lint: tools
lint: golangci-lint
go vet ./...
$(GOLANGCI_LINT_BIN) run -v --deadline 10m
$(GOLANGCILINT) run -v --deadline 10m

.PHONY: lint-fix
lint-fix: tools
lint-fix: golangci-lint
go fmt ./...
go vet ./...
$(GOLANGCI_LINT_BIN) run -v --deadline 10m --fix
$(GOLANGCILINT) run -v --deadline 10m --fix

.PHONY: build
build:
go build ./...

.PHONY: test
test: tools build zookeeper
ZK_VERSION=$(ZK_VERSION) $(GOTESTSUM_BIN) --format dots -- -timeout 500s -v -race -covermode atomic -coverprofile=profile.cov $(PACKAGES)
test: gotestsum build zookeeper
ZK_VERSION=$(ZK_VERSION) $(GOTESTSUM) --format dots -- -timeout 500s -v -race -covermode atomic -coverprofile profile.cov $(PACKAGES)

.PHONY: clean
clean:
Expand All @@ -70,4 +67,22 @@ clean:
rm -rf zookeeper-*/
rm -f zookeeper
rm -f profile.cov
rm -rf tools/bin

LOCALBIN ?= $(shell pwd)/bin

$(LOCALBIN):
mkdir -p $(LOCALBIN)

## Tool Binaries
GOLANGCILINT ?= $(LOCALBIN)/golangci-lint
GOTESTSUM ?= $(LOCALBIN)/gotestsum

.PHONY: golangci-lint
golangci-lint: $(GOLANGCILINT) ## Download golangci-lint locally if necessary.
$(GOLANGCILINT): $(LOCALBIN)
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCILINT_VERSION}

.PHONY: gotestsum
gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary.
$(GOTESTSUM): $(LOCALBIN)
test -s $(LOCALBIN)/gotestsum || GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@v${GOTESTSUM_VERSION}
6 changes: 1 addition & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,11 +1,7 @@
Native Go Zookeeper Client Library
===================================

/!\ This is a fork of https://github.com/go-zookeeper/zk / https://github.com/samuel/go-zookeeper /!\

[![GoDoc](https://godoc.org/github.com/Shopify/zk?status.svg)](https://godoc.org/github.com/Shopify/zk)
[![Build Status](https://img.shields.io/github/workflow/status/Shopify/zk/unittest/master)](https://github.com/Shopify/zk/actions?query=branch%3Amaster)
[![Coverage Status](https://img.shields.io/codecov/c/github/Shopify/zk/master)](https://codecov.io/gh/Shopify/zk/branch/master)
/!\ This is a fork of https://github.com/Shopify/zk / https://github.com/go-zookeeper/zk / https://github.com/samuel/go-zookeeper /!\

License
-------
Expand Down
2 changes: 1 addition & 1 deletion conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -882,7 +882,7 @@ func (c *Conn) recvLoop(conn net.Conn) error {
}
c.sendEvent(ev)
c.notifyWatchers(ev)
} else if res.Xid == -2 {
} else if res.Xid == -2 { //nolint:revive
// Ping response. Ignore.
} else if res.Xid < 0 {
c.logger.Printf("xid < 0 (%d) but not ping or watcher event", res.Xid)
Expand Down
2 changes: 0 additions & 2 deletions go.mod
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
module github.com/Shopify/zk

go 1.18

require golang.org/x/sync v0.0.0-20220907140024-f12130a52804
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
@@ -1,2 +0,0 @@
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
1 change: 0 additions & 1 deletion tools/.gitignore

This file was deleted.

Loading