Skip to content

Commit

Permalink
Merge pull request #1 from zeebe-io/meg-21817-add-ci
Browse files Browse the repository at this point in the history
Add Go Client CI
  • Loading branch information
megglos authored Sep 10, 2024
2 parents 9282e78 + 5a026ce commit b5679f1
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 59 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: Go Client CI
on:
push:
branches: main
pull_request: { }
workflow_dispatch: { }
jobs:
go-client:
name: Go client tests
runs-on: ubuntu-latest
timeout-minutes: 20
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true
- name: Build Go
shell: bash
id: build-go
working-directory: cmd/zbctl
run: ./build.sh
- name: Run Go tests
working-directory: .
run: go test -mod=vendor -v ./...
go-lint:
name: Go linting
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true
- name: golangci-lint
uses: golangci/golangci-lint-action@v4
with:
# fixed to avoid triggering false positive; see https://github.com/golangci/golangci-lint-action/issues/535
version: v1.55.2
# caching issues, see: https://github.com/golangci/golangci-lint-action/issues/244#issuecomment-1052190775
skip-pkg-cache: true
skip-build-cache: true
working-directory: .
go-apidiff:
if: github.event_name == 'pull_request'
name: Go Backwards Compatibility
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-go@v5
with:
go-version: '1.22'
cache: true
- uses: joelanford/go-apidiff@main
30 changes: 4 additions & 26 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,47 +1,25 @@
# Zeebe Go Client

> [!WARNING]
> The Zeebe Go Client will be officially deprecated with 8.6 release as part of our efforts to streamline the Camunda 8 API experience. This client will not get released with Camunda 8.6, thus no longer receive new features and will be transitioned to a community-maintained status.
### Why This Change?

The decision to deprecate the Go Client aligns with our broader API strategy and resource allocation priorities. The Go Client has seen limited adoption. Moving forward, we are focusing our efforts on the Camunda 8 REST API, which offers a unified, more widely-supported approach for interacting with Zeebe and other Camunda services.

### What Does This Mean for Users?

* No New Features or Updates: Starting with Camunda 8.6, the Go Client will no longer receive new features, updates, or official support from Camunda.
* The official Go client and zbctl will only remain available and maintained for supported minor versions up to Camunda 8.5.
* Community Maintenance: The Go Client will be moved to [Camunda Community Hub](https://github.com/camunda-community-hub) and can be maintained by the community. We encourage contributions from users who wish to continue using and improving this client.
* Transition to REST API: We recommend users transition to the Camunda 8 REST API for all future development. The REST API provides comprehensive functionality and is supported by tools such as cURL, Postman, and OpenAPI.

### Future Considerations

We value feedback from our community. Based on user input, we may explore developing a new client for the Camunda 8 REST API, based on a different technology that aligns with our strategic goals and internal expertise.
For more information on the deprecation and our API strategy, please refer to the official [Camunda blog](https://camunda.com/blog/).
The Zeebe Go client is a Go wrapper implementation around the GRPC (https://github.com/grpc/grpc) generated Zeebe client. It makes it possible to communicate with Zeebe Broker via the GRPC protocol, see the [Zeebe documentation](https://docs.zeebe.io/) for more information about the Zeebe project.

# Development

If we had a gateway-protocol change we need to make sure that we regenerate the protobuf file, which is used by the go client.
In order to do this please follow [this guide](../../gateway-protocol-impl/README.md).

## Testing

### gRPC Mock

To regenerate the gateway mock `internal/mock_pb/mock_gateway.go` run [`mockgen`](https://github.com/golang/mock#installation) from the root of this module (`clients/go`):
To regenerate the gateway mock `internal/mock_pb/mock_gateway.go` run [`mockgen`](https://github.com/golang/mock#installation) from the root of this project:

```
mockgen -source=pkg/pb/gateway.pb.go GatewayClient,Gateway_ActivateJobsClient > internal/mock_pb/mock_gateway.go
```

### Integration tests

To run the integration tests, a Docker image for Zeebe must be built with the tag 'current-test'.
To do that you can run the following command from the root of this repository:

```
docker build --build-arg DIST=build -t camunda/zeebe:current-test .
```
Integration tests run zeebe in a container to test the client against. The version of Zeebe used is managed via
a constant in [`internal/containersuite/containerSuite.go`](internal/containersuite/containerSuite.go#L36).

To add new zbctl tests, you must generate a golden file with the expected output of the command you are testing. The tests ignore numbers so you can leave any keys or timestamps in your golden file, even though these will most likely be different from test command's output. However, non-numeric variables are not ignored. For instance, the help menu contains:

Expand Down
3 changes: 1 addition & 2 deletions cmd/zbctl/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,8 +251,7 @@ func TestZbctlWithInsecureGateway(t *testing.T) {
suite.Run(t,
&integrationTestSuite{
ContainerSuite: &containersuite.ContainerSuite{
WaitTime: time.Second,
ContainerImage: "camunda/zeebe:current-test",
WaitTime: time.Second,
Env: map[string]string{
"ZEEBE_BROKER_GATEWAY_LONGPOLLING_ENABLED": "false",
},
Expand Down
28 changes: 3 additions & 25 deletions internal/containersuite/containerSuite.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ import (
"github.com/camunda/camunda/clients/go/v8/internal/utils"
"github.com/camunda/camunda/clients/go/v8/pkg/pb"
"github.com/camunda/camunda/clients/go/v8/pkg/zbc"
"github.com/docker/docker/client"
"github.com/docker/go-connections/nat"
"github.com/stretchr/testify/suite"
"github.com/testcontainers/testcontainers-go"
Expand All @@ -34,6 +33,8 @@ import (
"google.golang.org/grpc/status"
)

const dockerImageName = "camunda/zeebe:8.6.0-alpha5"

type zeebeWaitStrategy struct {
waitTime time.Duration
}
Expand Down Expand Up @@ -153,8 +154,6 @@ func isStable(res *pb.TopologyResponse) bool {
type ContainerSuite struct {
// WaitTime specifies the wait period before checking if the container is up
WaitTime time.Duration
// ContainerImage is the ID of docker image to be used
ContainerImage string
// GatewayAddress is the contact point of the spawned Zeebe container specified in the format 'host:port'
GatewayAddress string
GatewayHost string
Expand Down Expand Up @@ -199,7 +198,7 @@ func (s *ContainerSuite) SetupSuite() {
var err error
req := testcontainers.GenericContainerRequest{
ContainerRequest: testcontainers.ContainerRequest{
Image: s.ContainerImage,
Image: dockerImageName,
ExposedPorts: []string{"26500/tcp", "9600/tcp"},
WaitingFor: zeebeWaitStrategy{waitTime: s.WaitTime},
Env: map[string]string{
Expand All @@ -216,10 +215,6 @@ func (s *ContainerSuite) SetupSuite() {
}

ctx := context.Background()
err = validateImageExists(ctx, s.ContainerImage)
if err != nil {
s.T().Fatal(err)
}

s.container, err = testcontainers.GenericContainer(ctx, req)
if err != nil {
Expand Down Expand Up @@ -258,20 +253,3 @@ func (s *ContainerSuite) TearDownSuite() {
s.T().Fatal(err)
}
}

func validateImageExists(ctx context.Context, image string) error {
dockerClient, err := client.NewClientWithOpts(client.FromEnv, client.WithAPIVersionNegotiation())
if err != nil {
return fmt.Errorf("failed creating docker client: %w", err)
}

_, _, err = dockerClient.ImageInspectWithRaw(ctx, image)
if err != nil {
if client.IsErrNotFound(err) {
return fmt.Errorf("a Docker image containing Zeebe must be built and named '%s'", image)
}

return err
}
return nil
}
8 changes: 2 additions & 6 deletions test/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,6 @@ import (
"github.com/stretchr/testify/suite"
)

const dockerImageName = "camunda/zeebe:current-test"

type integrationTestSuite struct {
*containersuite.ContainerSuite
client zbc.Client
Expand All @@ -42,8 +40,7 @@ type integrationTestSuite struct {
func TestIntegration(t *testing.T) {
suite.Run(t, &integrationTestSuite{
ContainerSuite: &containersuite.ContainerSuite{
WaitTime: time.Second,
ContainerImage: dockerImageName,
WaitTime: time.Second,
},
})
}
Expand Down Expand Up @@ -451,8 +448,7 @@ func TestSlowWorker(t *testing.T) {
suite.Run(t, &slowWorkerSuite{
integrationTestSuite: &integrationTestSuite{
ContainerSuite: &containersuite.ContainerSuite{
WaitTime: time.Second,
ContainerImage: dockerImageName,
WaitTime: time.Second,
Env: map[string]string{
"ZEEBE_DEBUG": "true",
"ZEEBE_LOG_LEVEL": "debug",
Expand Down

0 comments on commit b5679f1

Please sign in to comment.