Skip to content

Commit

Permalink
Merge pull request #2 from adrian-lin-1-0-0/1-chore-migrate-from-trav…
Browse files Browse the repository at this point in the history
…is-to-github-actions

feat : add github action
  • Loading branch information
adrian-lin-1-0-0 committed Nov 28, 2023
2 parents 41bb18b + fa59725 commit cc22915
Show file tree
Hide file tree
Showing 14 changed files with 877 additions and 202 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/on-pull-request.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: CI

on:
push:
branches:
- master
- main
pull_request:
branches:
- master
- main

jobs:
on-pull-request:
name: test
strategy:
matrix:
go-version:
- 1.19.x
- 1.20.x
os: [ ubuntu-latest ]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@master

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ${{ matrix.go-version }}

- run: go env

- name: Cache deps
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install deps
run: go mod download

- name: Test
run: go test ./...
19 changes: 0 additions & 19 deletions .travis.yml

This file was deleted.

24 changes: 24 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
API_PROTO_FILES=$(shell find groupcachepb -name "*.proto")
API_PROTO_FILES_PATH=./groupcachepb
TEST_PROTO_FILES=$(shell find testpb -name "*.proto")
TEST_PROTO_FILES_PATH=./testpb


.PHONY: api
# generate api proto
api:
protoc --proto_path=${API_PROTO_FILES_PATH} \
--go_out=paths=source_relative:${API_PROTO_FILES_PATH} \
$(API_PROTO_FILES)

.PHONY: testpb
# generate test proto
testpb:
protoc --proto_path=${TEST_PROTO_FILES_PATH} \
--go_out=paths=source_relative:${TEST_PROTO_FILES_PATH} \
$(TEST_PROTO_FILES)

.PHONY: test
# run test
test:
go test -v ./...
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
groupcache is a distributed caching and cache-filling library, intended as a
replacement for a pool of memcached nodes in many cases.

For API docs and examples, see http://godoc.org/github.com/golang/groupcache
For API docs and examples, see http://godoc.org/github.com/adrian-lin-1-0-0/groupcache

## Comparison to memcached

Expand Down
8 changes: 8 additions & 0 deletions go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
module github.com/adrian-lin-1-0-0/groupcache

go 1.20

require (
github.com/golang/protobuf v1.5.3
google.golang.org/protobuf v1.26.0
)
12 changes: 12 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
github.com/adrian-lin-1-0-0/groupcache v0.0.0-20210331224755-41bb18bfe9da h1:oI5xCqsCo564l8iNU+DwB5epxmsaqB+rhGL0m5jtYqE=
github.com/adrian-lin-1-0-0/groupcache v0.0.0-20210331224755-41bb18bfe9da/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc=
github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk=
github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg=
github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY=
github.com/google/go-cmp v0.5.5 h1:Khx7svrCpmxxtHBq5j2mp/xVjsi8hQMfNLvJFAlrGgU=
github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543 h1:E7g+9GITq07hpfrRu66IVDexMakfv52eLZ2CXBWiKr4=
golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw=
google.golang.org/protobuf v1.26.0 h1:bxAC2xTBsZGibn2RTntX0oH50xLsqy1OxA9tTL3p/lk=
google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc=
10 changes: 5 additions & 5 deletions groupcache.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,9 @@ import (
"sync"
"sync/atomic"

pb "github.com/golang/groupcache/groupcachepb"
"github.com/golang/groupcache/lru"
"github.com/golang/groupcache/singleflight"
pb "github.com/adrian-lin-1-0-0/groupcache/groupcachepb"
"github.com/adrian-lin-1-0-0/groupcache/lru"
"github.com/adrian-lin-1-0-0/groupcache/singleflight"
)

// A Getter loads data for a key.
Expand Down Expand Up @@ -303,8 +303,8 @@ func (g *Group) getLocally(ctx context.Context, key string, dest Sink) (ByteView

func (g *Group) getFromPeer(ctx context.Context, peer ProtoGetter, key string) (ByteView, error) {
req := &pb.GetRequest{
Group: &g.name,
Key: &key,
Group: g.name,
Key: key,
}
res := &pb.GetResponse{}
err := peer.Get(ctx, req, res)
Expand Down
12 changes: 6 additions & 6 deletions groupcache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,16 +24,15 @@ import (
"fmt"
"hash/crc32"
"math/rand"
"reflect"
"sync"
"testing"
"time"
"unsafe"

"github.com/golang/protobuf/proto"
"google.golang.org/protobuf/proto"

pb "github.com/golang/groupcache/groupcachepb"
testpb "github.com/golang/groupcache/testpb"
pb "github.com/adrian-lin-1-0-0/groupcache/groupcachepb"
testpb "github.com/adrian-lin-1-0-0/groupcache/testpb"
)

var (
Expand Down Expand Up @@ -153,11 +152,12 @@ func TestGetDupSuppressProto(t *testing.T) {
Name: proto.String("ECHO:Fluffy"),
City: proto.String("SOME-CITY"),
}

for i := 0; i < 2; i++ {
select {
case v := <-resc:
if !reflect.DeepEqual(v, want) {
t.Errorf(" Got: %v\nWant: %v", proto.CompactTextString(v), proto.CompactTextString(want))
if *v.Name != *want.Name || *v.City != *want.City {
t.Errorf(" Got: %v\nWant: %v", v, want)
}
case <-time.After(5 * time.Second):
t.Errorf("timeout waiting on getter #%d of 2", i+1)
Expand Down
Loading

0 comments on commit cc22915

Please sign in to comment.