Skip to content
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
142 changes: 0 additions & 142 deletions .circleci/config.yml

This file was deleted.

66 changes: 66 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: test

on:
push:
branches: [master]
pull_request:

permissions:
contents: read

jobs:
test:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [oldstable, stable]
# Each directory is a separate Go module, so `go test ./...` at the repo
# root does not reach them. Add new modules here when they're created.
module:
- .
- cmd/subee
- middlewares/logging/zap
- middlewares/recovery
- stats/newrelic
- subscribers/cloudpubsub
- _examples/your-first-cloudpubsub-app
name: test (${{ matrix.module }}, ${{ matrix.go }})
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go }}
cache-dependency-path: ${{ matrix.module }}/go.sum
- run: go test -race -v ./...
working-directory: ${{ matrix.module }}

e2e:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
go: [oldstable, stable]
name: e2e (${{ matrix.go }})
env:
PUBSUB_EMULATOR_HOST: localhost:8085
steps:
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0
with:
go-version: ${{ matrix.go }}
cache-dependency-path: _tests/cloudpubsub/go.sum
# `services:` cannot override the image's command, and this image does
# not start the emulator on its own.
- name: Start Pub/Sub emulator
run: |
cid=$(docker run -d -p 8085:8085 \
gcr.io/google.com/cloudsdktool/google-cloud-cli:emulators \
gcloud beta emulators pubsub start --host-port=0.0.0.0:8085)
echo "PUBSUB_EMULATOR_CID=$cid" >> "$GITHUB_ENV"
timeout 60 bash -c 'until curl -sf http://localhost:8085 >/dev/null; do sleep 1; done'
- run: go test -race -v ./...
working-directory: _tests/cloudpubsub
- name: Show Pub/Sub emulator logs
if: failure()
run: docker logs "$PUBSUB_EMULATOR_CID"
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
![subee](docs/subee.png)

[![CircleCI](https://circleci.com/gh/wantedly/subee/tree/master.svg?style=svg)](https://circleci.com/gh/wantedly/subee/tree/master)
[![test](https://github.com/wantedly/subee/actions/workflows/test.yml/badge.svg)](https://github.com/wantedly/subee/actions/workflows/test.yml)
[![latest](https://img.shields.io/github/release/wantedly/subee.svg)](https://github.com/wantedly/subee/releases/latest)
[![GoDoc](https://godoc.org/github.com/wantedly/subee?status.svg)](https://godoc.org/github.com/wantedly/subee)
[![Go Report Card](https://goreportcard.com/badge/github.com/wantedly/subee)](https://goreportcard.com/report/github.com/wantedly/subee)
Expand Down
18 changes: 14 additions & 4 deletions cmd/subee/go.mod
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
module github.com/wantedly/subee/cmd/subee

go 1.13
go 1.25.0

require (
github.com/bradleyjkemp/cupaloy v2.3.0+incompatible
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365
github.com/logrusorgru/aurora v0.0.0-20191017060258-dc85c304c434
github.com/pkg/errors v0.8.1
github.com/spf13/cobra v0.0.5
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e
golang.org/x/text v0.3.2
golang.org/x/tools v0.0.0-20191017035025-0abb09c987dd
golang.org/x/sync v0.22.0
golang.org/x/text v0.41.0
golang.org/x/tools v0.49.0
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated
)

require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/inconshreveable/mousetrap v1.0.0 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/spf13/pflag v1.0.3 // indirect
golang.org/x/mod v0.39.0 // indirect
golang.org/x/tools/go/expect v0.1.0-deprecated // indirect
)
26 changes: 14 additions & 12 deletions cmd/subee/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ github.com/cpuguy83/go-md2man v1.0.10/go.mod h1:SmD6nW6nTyfqj6ABTjUi3V3JVMnlJmwc
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/fsnotify/fsnotify v1.4.7/go.mod h1:jwhsz4b93w/PPRr/qN1Yymfu8t87LnFCMoQvtojpjFo=
github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI=
github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY=
github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ=
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365 h1:ECW73yc9MY7935nNYXUkK7Dz17YuSUI9yqRqYS8aBww=
github.com/iancoleman/strcase v0.0.0-20190422225806-e506e3ef7365/go.mod h1:SK73tn/9oHe+/Y0h39VT4UCxmurVJkR5NA7kMEAOgSE=
Expand Down Expand Up @@ -37,19 +39,19 @@ github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXf
github.com/ugorji/go/codec v0.0.0-20181204163529-d75b2dcb6bc8/go.mod h1:VFNgLljTbGfSG7qAOspJ7OScBnGdDN/yBr0sguwnwf0=
github.com/xordataexchange/crypt v0.0.3-0.20170626215501-b2862e3d0a77/go.mod h1:aYKd//L2LvnjZzWKhF00oedf4jCCReLcmhLdhm1A27Q=
golang.org/x/crypto v0.0.0-20181203042331-505ab145d0a9/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4=
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e h1:vcxGaoTs7kV8m5Np9uUNQin4BrLOthgV7252N8V+FwY=
golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/mod v0.39.0 h1:UF5zwQdCRRUpHfyPwr7d4UrGiVeldIsogtzWVnczL74=
golang.org/x/mod v0.39.0/go.mod h1:bvIbwjQ0HUFFf5AKukeeYQG4ZBUG9yxQbR9aEweIwYY=
golang.org/x/sync v0.22.0 h1:SZjpbeLmrCk4xhRSZFNZW5gFUeCeFgjekvI/+gfScek=
golang.org/x/sync v0.22.0/go.mod h1:9xrNwdLfx4jkKbNva9FpL6vEN7evnE43NNNJQ2LF3+0=
golang.org/x/sys v0.0.0-20181205085412-a5c9d58dba9a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2 h1:tW2bmiBqwgJj/UpqtC8EpXEZVYOwU0yG4iWbprSVAcs=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ=
golang.org/x/tools v0.0.0-20191017035025-0abb09c987dd h1:05UlZ/D8j3ueatR0iMtGQ8BOUKChM5b0XY/c50tSFe4=
golang.org/x/tools v0.0.0-20191017035025-0abb09c987dd/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo=
golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0=
golang.org/x/text v0.41.0 h1:vz/seA0lnX87Othu2f/0L24RcgrXD9/YFTSuGjj3rH8=
golang.org/x/text v0.41.0/go.mod h1:jvf1O8ajNzZqhSrQBPbutR/EB83Cc0CFrezNQIwbb5M=
golang.org/x/tools v0.49.0 h1:3NI7VXzL9+1WZD52Dx2ttoPwD5DWrFGpl9mFZDlmisI=
golang.org/x/tools v0.49.0/go.mod h1:SJNXV9DBKT0UbdttsQjbfJlAE/q+y36++zo3uL3N0Oo=
golang.org/x/tools/go/expect v0.1.0-deprecated h1:jY2C5HGYR5lqex3gEniOQL0r7Dq5+VGVgY1nudX5lXY=
golang.org/x/tools/go/expect v0.1.0-deprecated/go.mod h1:eihoPOH+FgIqa3FpoTwguz/bVUSGBlGQU67vpBeOrBY=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated h1:1h2MnaIAIXISqTFKdENegdpAgUXz6NrPEsbIeWaBRvM=
golang.org/x/tools/go/packages/packagestest v0.1.1-deprecated/go.mod h1:RVAQXBGNv1ib0J382/DPCRS/BPnsGebyM1Gj5VSDpG8=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI=
8 changes: 8 additions & 0 deletions cmd/subee/internal/generator/subscriber.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,13 @@ func (g *subscriberGeneratorImpl) Generate(ctx context.Context, params *Subscrib
return errors.Errorf("invalid packages.LoadMode: %v", g.pkgCfg.Mode)
}

// Not every generated file references subee directly (e.g. the with-adapter
// consumer interface only deals with the concrete message type). imports.Process
// resolves missing third-party imports via the local module cache, so it can
// silently fail to add this one on a clean cache (e.g. CI); add it
// unconditionally and let imports.Process prune it where it ends up unused.
params.Imports = append(params.Imports, Package{Path: "github.com/wantedly/subee"})

if params.IsWithAdapter() {
pkgs, err := packages.Load(g.pkgCfg, params.Package.Path)
if err != nil {
Expand Down Expand Up @@ -184,6 +191,7 @@ func main() {
import (
"github.com/srvc/appctx"
"github.com/pkg/errors"
"github.com/wantedly/subee"
)

func run() error {
Expand Down
8 changes: 8 additions & 0 deletions engine_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,13 @@ func TestEngine(t *testing.T) {

ctx, cancel := context.WithCancel(context.Background())

var mu sync.Mutex
var cur int
subscriber := subee_testing.NewFakeSubscriber()
consumer := subee.ConsumerFunc(func(ctx context.Context, msg subee.Message) error {
mu.Lock()
defer mu.Unlock()

r := &Result{
tc: cases[cur],
msg: msg.(*subee_testing.FakeMessage),
Expand Down Expand Up @@ -168,9 +172,13 @@ func TestEngineWithBatchConsumer(t *testing.T) {

ctx, cancel := context.WithCancel(context.Background())

var mu sync.Mutex
var cur int
subscriber := subee_testing.NewFakeSubscriber()
consumer := subee.BatchConsumerFunc(func(ctx context.Context, msgs []subee.Message) error {
mu.Lock()
defer mu.Unlock()

r := &Result{tc: cases[cur]}
for _, m := range msgs {
r.msgs = append(r.msgs, m.(*subee_testing.FakeMessage))
Expand Down