Skip to content

Commit 2d4acd5

Browse files
committed
Update GitHub Actions and fix linter issues
1 parent 3a76678 commit 2d4acd5

File tree

15 files changed

+77
-1242
lines changed

15 files changed

+77
-1242
lines changed

.github/workflows/lint.yaml

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,16 @@ name: lint
22
on: [ pull_request ]
33

44
jobs:
5-
lint:
5+
golangci:
66
name: lint
77
runs-on: ubuntu-latest
88
steps:
9-
- name: Setup Go
10-
uses: actions/setup-go@v1
11-
with:
12-
go-version: 1.19.x
13-
14-
- name: Checkout code
15-
uses: actions/checkout@v1
16-
17-
- name: Run Lint
18-
run: make lint
9+
- uses: actions/checkout@v3
10+
- uses: actions/setup-go@v4
11+
with:
12+
go-version: '1.20'
13+
cache: false
14+
- name: golangci-lint
15+
uses: golangci/golangci-lint-action@v3
16+
with:
17+
version: v1.54

.github/workflows/unittest.yaml

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
name: unittest
2-
on: [ push, pull_request ]
2+
on:
3+
push:
4+
branches:
5+
- master
6+
pull_request:
37

48
jobs:
59
unittest:
@@ -11,22 +15,23 @@ jobs:
1115
runs-on: ubuntu-latest
1216
steps:
1317
- name: Setup Go
14-
uses: actions/setup-go@v1
18+
uses: actions/setup-go@v4
1519
with:
1620
go-version: ${{ matrix.go-version }}
1721

1822
- name: Setup Java
19-
uses: actions/setup-java@v1
23+
uses: actions/setup-java@v3
2024
with:
21-
java-version: 14
25+
distribution: 'temurin'
26+
java-version: '17'
2227

2328
- name: Checkout code
24-
uses: actions/checkout@v1
29+
uses: actions/checkout@v4
2530

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

29-
- name: Upload code coverage
30-
uses: codecov/codecov-action@v1
31-
with:
32-
file: ./profile.cov
34+
# - name: Upload code coverage
35+
# uses: codecov/codecov-action@v3
36+
# with:
37+
# file: ./profile.cov

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
.vscode/
2+
.idea
23
.DS_Store
34
profile.cov
5+
coverage.xml
6+
bin/
47
zookeeper
58
zookeeper-*/
69
zookeeper-*.tar.gz

Makefile

Lines changed: 40 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,8 @@
1-
21
REPO_ROOT = $(shell pwd -P)
3-
TOOLS_BINDIR = $(REPO_ROOT)/tools/bin
4-
GOTESTSUM_BIN = $(TOOLS_BINDIR)/gotestsum
5-
GOLANGCI_LINT_BIN ?= $(TOOLS_BINDIR)/golangci-lint
6-
72
PACKAGES := $(shell go list ./... | grep -v examples)
83

4+
GOLANGCILINT_VERSION = 1.54
5+
GOTESTSUM_VERSION = 1.8.2
96
# make file to hold the logic of build and test setup
107
ZK_VERSION ?= 3.6.2
118

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

18+
# Get the currently used golang install path (in GOPATH/bin, unless GOBIN is set)
19+
ifeq (,$(shell go env GOBIN))
20+
GOBIN=$(shell go env GOPATH)/bin
21+
else
22+
GOBIN=$(shell go env GOBIN)
23+
endif
24+
2125
.DEFAULT_GOAL := test
2226

23-
$(ZK):
27+
validate-java:
28+
which java
29+
30+
$(ZK): validate-java
2431
wget $(ZK_URL)
2532
tar -zxf $(ZK).tar.gz
2633
rm $(ZK).tar.gz
2734

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

3340
.PHONY: setup
34-
setup: zookeeper tools
35-
36-
.PHONY: tools
37-
tools: tools/tools.go tools/go.mod
38-
mkdir -p "$(TOOLS_BINDIR)"
39-
cd tools && \
40-
export GOBIN="${TOOLS_BINDIR}" && \
41-
go install \
42-
github.com/golangci/golangci-lint/cmd/golangci-lint \
43-
gotest.tools/gotestsum && \
44-
cd ..
41+
setup: zookeeper
4542

4643
.PHONY: lint
47-
lint: tools
44+
lint: golangci-lint
4845
go vet ./...
49-
$(GOLANGCI_LINT_BIN) run -v --deadline 10m
46+
$(GOLANGCILINT) run -v --deadline 10m
5047

5148
.PHONY: lint-fix
52-
lint-fix: tools
49+
lint-fix: golangci-lint
5350
go fmt ./...
5451
go vet ./...
55-
$(GOLANGCI_LINT_BIN) run -v --deadline 10m --fix
52+
$(GOLANGCILINT) run -v --deadline 10m --fix
5653

5754
.PHONY: build
5855
build:
5956
go build ./...
6057

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

6562
.PHONY: clean
6663
clean:
@@ -70,4 +67,22 @@ clean:
7067
rm -rf zookeeper-*/
7168
rm -f zookeeper
7269
rm -f profile.cov
73-
rm -rf tools/bin
70+
71+
LOCALBIN ?= $(shell pwd)/bin
72+
73+
$(LOCALBIN):
74+
mkdir -p $(LOCALBIN)
75+
76+
## Tool Binaries
77+
GOLANGCILINT ?= $(LOCALBIN)/golangci-lint
78+
GOTESTSUM ?= $(LOCALBIN)/gotestsum
79+
80+
.PHONY: golangci-lint
81+
golangci-lint: $(GOLANGCILINT) ## Download golangci-lint locally if necessary.
82+
$(GOLANGCILINT): $(LOCALBIN)
83+
test -s $(LOCALBIN)/golangci-lint || GOBIN=$(LOCALBIN) go install github.com/golangci/golangci-lint/cmd/golangci-lint@v${GOLANGCILINT_VERSION}
84+
85+
.PHONY: gotestsum
86+
gotestsum: $(GOTESTSUM) ## Download gotestsum locally if necessary.
87+
$(GOTESTSUM): $(LOCALBIN)
88+
test -s $(LOCALBIN)/gotestsum || GOBIN=$(LOCALBIN) go install gotest.tools/gotestsum@v${GOTESTSUM_VERSION}

README.md

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,7 @@
11
Native Go Zookeeper Client Library
22
===================================
33

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

106
License
117
-------

conn.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -882,7 +882,7 @@ func (c *Conn) recvLoop(conn net.Conn) error {
882882
}
883883
c.sendEvent(ev)
884884
c.notifyWatchers(ev)
885-
} else if res.Xid == -2 {
885+
} else if res.Xid == -2 { //nolint:revive
886886
// Ping response. Ignore.
887887
} else if res.Xid < 0 {
888888
c.logger.Printf("xid < 0 (%d) but not ping or watcher event", res.Xid)

go.mod

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
11
module github.com/Shopify/zk
22

33
go 1.18
4-
5-
require golang.org/x/sync v0.0.0-20220907140024-f12130a52804

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +0,0 @@
1-
golang.org/x/sync v0.0.0-20220907140024-f12130a52804 h1:0SH2R3f1b1VmIMG7BXbEZCBUu2dKmHschSmjqGUrW8A=
2-
golang.org/x/sync v0.0.0-20220907140024-f12130a52804/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=

tools/.gitignore

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)