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

Split the library into sub-modules #73

Merged
merged 6 commits into from
Sep 25, 2024
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
38 changes: 25 additions & 13 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,40 +12,52 @@ jobs:

build:
runs-on: ubuntu-latest
steps:
strategy:
matrix:
module: [".", "queue", "qtest", "broker/eventbridge", "broker/eventddb", "broker/events3", "broker/eventsqs", "broker/sqs", "broker/websocket"]

steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"

- uses: actions/checkout@v4

- name: go build
working-directory: ${{ matrix.module }}
run: |
go build ./...

- name: go test
working-directory: ${{ matrix.module }}
run: |
go test -v -coverprofile=profile.cov $(go list ./... | grep -v /examples/)
go test -coverprofile=profile.cov $(go list ./... | grep -v /examples/)
env:
## GOPATH required to build serverless app inside unittest
GOPATH: /home/runner/work/${{ github.event.repository.name }}/go

- uses: shogo82148/actions-goveralls@v1
continue-on-error: true
with:
working-directory: ${{ matrix.module }}
path-to-profile: profile.cov
flag-name: ${{ matrix.module }}
parallel: true

- uses: reecetech/[email protected]
id: version
with:
scheme: semver
increment: patch

- name: publish
- name: release
working-directory: ${{ matrix.module }}
run: |
git config user.name "GitHub Actions"
git config user.email "[email protected]"
git tag ${{ steps.version.outputs.v-version }}
git push origin -u ${{ steps.version.outputs.v-version }}

for mod in `grep -roh "const Version = \".*" * | grep -Eoh "([[:alnum:]]*/*){1,}v[0-9]*\.[0-9]*\.[0-9]*"`
do
git tag $mod 2> /dev/null && git push origin -u $mod 2> /dev/null && echo "[+] $mod" || echo "[ ] $mod"
done

finish:
needs: build
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true
25 changes: 0 additions & 25 deletions .github/workflows/check-code.yml

This file was deleted.

37 changes: 0 additions & 37 deletions .github/workflows/check-test.yml

This file was deleted.

59 changes: 59 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
##
## Unit Tests & Coverage
##
name: check
on:
pull_request:
types:
- opened
- synchronize

jobs:

unit:
runs-on: ubuntu-latest
strategy:
matrix:
module: [".", "queue", "qtest", "broker/eventbridge", "broker/eventddb", "broker/events3", "broker/eventsqs", "broker/sqs", "broker/websocket"]


steps:
- uses: actions/setup-go@v5
with:
go-version: "1.22"

- uses: actions/checkout@v4

- name: go build
working-directory: ${{ matrix.module }}
run: |
go build ./...

- name: go test
working-directory: ${{ matrix.module }}
run: |
go test -coverprofile=profile.cov $(go list ./... | grep -v /examples/)
env:
## GOPATH required to build serverless app inside unittest
GOPATH: /home/runner/work/${{ github.event.repository.name }}/go

- uses: shogo82148/actions-goveralls@v1
continue-on-error: true
with:
working-directory: ${{ matrix.module }}
path-to-profile: profile.cov
flag-name: ${{ matrix.module }}
parallel: true

- uses: dominikh/[email protected]
with:
install-go: false
working-directory: ${{ matrix.module }}

finish:
needs: unit
runs-on: ubuntu-latest
steps:
- uses: shogo82148/actions-goveralls@v1
with:
parallel-finished: true
4 changes: 2 additions & 2 deletions broker/eventbridge/awscdk_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ func TestEventBridgeCDK(t *testing.T) {
&eventbridge.SinkProps{
Source: []string{"swarm-example-eventbridge"},
Function: &scud.FunctionGoProps{
SourceCodeModule: "github.com/fogfish/swarm",
SourceCodeLambda: "examples/eventbridge/dequeue",
SourceCodeModule: "github.com/fogfish/swarm/broker/eventbridge",
SourceCodeLambda: "examples/dequeue",
},
},
)
Expand Down
2 changes: 1 addition & 1 deletion broker/eventbridge/eventbridge.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/eventbridge"
"github.com/aws/aws-sdk-go-v2/service/eventbridge/types"
"github.com/fogfish/swarm"
"github.com/fogfish/swarm/internal/kernel"
"github.com/fogfish/swarm/kernel"
)

// EventBridge declares the subset of interface from AWS SDK used by the lib.
Expand Down
6 changes: 1 addition & 5 deletions broker/eventbridge/eventbridge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import (
"github.com/aws/aws-sdk-go-v2/service/eventbridge"
"github.com/fogfish/swarm"
sut "github.com/fogfish/swarm/broker/eventbridge"
"github.com/fogfish/swarm/internal/qtest"
"github.com/fogfish/swarm/qtest"
"github.com/fogfish/swarm/queue"
)

Expand All @@ -37,9 +37,7 @@ func TestDequeueEventBridge(t *testing.T) {
qtest.TestDequeueEvent(t, newMockDequeue)
}

//
// Mock AWS EventBridge Enqueue
//
type mockEnqueue struct {
sut.EventBridge
expectCategory string
Expand Down Expand Up @@ -72,9 +70,7 @@ func (m *mockEnqueue) PutEvents(ctx context.Context, req *eventbridge.PutEventsI
}, nil
}

//
// Mock AWS EventBridge Dequeue
//
func newMockDequeue(
loopback chan string,
queueName string,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import (

"github.com/fogfish/swarm"
"github.com/fogfish/swarm/broker/eventbridge"
"github.com/fogfish/swarm/internal/qtest"
"github.com/fogfish/swarm/queue"
"github.com/fogfish/swarm/queue/events"
)
Expand All @@ -41,8 +40,6 @@ func (EventNote) HKT1(swarm.EventType) {}
func (EventNote) HKT2(*Note) {}

func main() {
qtest.NewLogger()

q := queue.Must(eventbridge.New("swarm-example-eventbridge", swarm.WithLogStdErr()))

go actor[User]("user").handle(queue.Dequeue[User](q))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ package main
import (
"github.com/fogfish/swarm"
"github.com/fogfish/swarm/broker/eventbridge"
"github.com/fogfish/swarm/internal/qtest"
"github.com/fogfish/swarm/queue"
"github.com/fogfish/swarm/queue/events"
)
Expand All @@ -37,8 +36,6 @@ func (EventNote) HKT1(swarm.EventType) {}
func (EventNote) HKT2(*Note) {}

func main() {
qtest.NewLogger()

q := queue.Must(eventbridge.New("swarm-example-eventbridge",
swarm.WithSource("swarm-example-eventbridge"),
swarm.WithLogStdErr(),
Expand Down
59 changes: 59 additions & 0 deletions broker/eventbridge/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
module github.com/fogfish/swarm/broker/eventbridge

go 1.22

replace github.com/fogfish/swarm => ../../

replace github.com/fogfish/swarm/queue => ../../queue

replace github.com/fogfish/swarm/qtest => ../../qtest

require (
github.com/aws/aws-cdk-go/awscdk/v2 v2.160.0
github.com/aws/aws-lambda-go v1.47.0
github.com/aws/aws-sdk-go-v2 v1.31.0
github.com/aws/aws-sdk-go-v2/config v1.27.37
github.com/aws/aws-sdk-go-v2/service/eventbridge v1.34.1
github.com/aws/constructs-go/constructs/v10 v10.3.0
github.com/aws/jsii-runtime-go v1.103.1
github.com/fogfish/scud v0.10.1
github.com/fogfish/swarm v0.0.0-00010101000000-000000000000
github.com/fogfish/swarm/qtest v0.0.0-00010101000000-000000000000
github.com/fogfish/swarm/queue v0.0.0-00010101000000-000000000000
)

require (
github.com/Masterminds/semver/v3 v3.2.1 // indirect
github.com/aws/aws-sdk-go-v2/credentials v1.17.35 // indirect
github.com/aws/aws-sdk-go-v2/feature/ec2/imds v1.16.14 // indirect
github.com/aws/aws-sdk-go-v2/internal/configsources v1.3.18 // indirect
github.com/aws/aws-sdk-go-v2/internal/endpoints/v2 v2.6.18 // indirect
github.com/aws/aws-sdk-go-v2/internal/ini v1.8.1 // indirect
github.com/aws/aws-sdk-go-v2/internal/v4a v1.3.18 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/accept-encoding v1.11.5 // indirect
github.com/aws/aws-sdk-go-v2/service/internal/presigned-url v1.11.20 // indirect
github.com/aws/aws-sdk-go-v2/service/sso v1.23.1 // indirect
github.com/aws/aws-sdk-go-v2/service/ssooidc v1.27.1 // indirect
github.com/aws/aws-sdk-go-v2/service/sts v1.31.1 // indirect
github.com/aws/smithy-go v1.21.0 // indirect
github.com/cdklabs/awscdk-asset-awscli-go/awscliv1/v2 v2.2.202 // indirect
github.com/cdklabs/awscdk-asset-kubectl-go/kubectlv20/v2 v2.1.2 // indirect
github.com/cdklabs/awscdk-asset-node-proxy-agent-go/nodeproxyagentv6/v2 v2.1.0 // indirect
github.com/cdklabs/cloud-assembly-schema-go/awscdkcloudassemblyschema/v38 v38.0.1 // indirect
github.com/fatih/color v1.17.0 // indirect
github.com/fogfish/curie v1.8.2 // indirect
github.com/fogfish/faults v0.2.0 // indirect
github.com/fogfish/golem/hseq v1.2.0 // indirect
github.com/fogfish/golem/optics v0.13.0 // indirect
github.com/fogfish/golem/pure v0.10.1 // indirect
github.com/fogfish/guid/v2 v2.0.4 // indirect
github.com/fogfish/it/v2 v2.0.2 // indirect
github.com/mattn/go-colorable v0.1.13 // indirect
github.com/mattn/go-isatty v0.0.20 // indirect
github.com/yuin/goldmark v1.5.3 // indirect
golang.org/x/lint v0.0.0-20210508222113-6edffad5e616 // indirect
golang.org/x/mod v0.20.0 // indirect
golang.org/x/sync v0.8.0 // indirect
golang.org/x/sys v0.23.0 // indirect
golang.org/x/tools v0.24.0 // indirect
)
Loading
Loading