Skip to content

Commit

Permalink
Housekeeping (update SDK, CI actions, linter, paramgen...) (#119)
Browse files Browse the repository at this point in the history
* various housekeeping

* update SDK to v0.10.0

* update golangci-lint, nats dependencies

* paramgen

* update docker compose file

* go mod tidy, extend start period of test containers

* enable monitoring port in all nats test containers

* limit start period again

* remove validator, enable containedctx linter

* go mod tidy

* enable errorlint

* enable remaining linters

* remove prerequisites in readme

* Update common/config.go

Co-authored-by: Maha Hajja <[email protected]>

* Update common/config.go

Co-authored-by: Maha Hajja <[email protected]>

* make generate

---------

Co-authored-by: Maha Hajja <[email protected]>
  • Loading branch information
lovromazgon and maha-hajja authored Sep 12, 2024
1 parent ea05157 commit da9748f
Show file tree
Hide file tree
Showing 37 changed files with 1,068 additions and 1,788 deletions.
1 change: 0 additions & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,4 +27,3 @@ jobs:
uses: golangci/golangci-lint-action@v6
with:
version: ${{ steps.golangci-lint-version.outputs.v }}
args: --timeout=2m
11 changes: 11 additions & 0 deletions .github/workflows/project-management.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
name: project-management

on:
issues:
types: [opened]

jobs:
project-mgmt:
uses: ConduitIO/automation/.github/workflows/project-automation.yml@main
secrets:
project-automation-token: ${{ secrets.PROJECT_AUTOMATION }}
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ jobs:
with:
distribution: goreleaser
version: latest
args: release --rm-dist
args: release
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
6 changes: 3 additions & 3 deletions .github/workflows/build.yml → .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
name: build
name: test

on:
push:
branches: [ main ]
pull_request:

jobs:
build:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -17,4 +17,4 @@ jobs:
go-version-file: 'go.mod'

- name: Test
run: make test GOTEST_FLAGS="-v -count=1 -race"
run: make test GOTEST_FLAGS="-v -count=1"
23 changes: 23 additions & 0 deletions .github/workflows/validate-generated-files.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: validate-generated-files

on:
push:
branches: [ main ]
pull_request:

jobs:
validate-generated-files:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version-file: 'go.mod'

- name: Check generated files
run: |
export PATH=$PATH:$(go env GOPATH)/bin
make install-tools generate
git diff --exit-code --numstat
129 changes: 77 additions & 52 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,100 +1,125 @@
run:
timeout: 5m

linters-settings:
gofmt:
simplify: false
govet:
check-shadowing: false
nolintlint:
allow-unused: false # report any unused nolint directives
require-explanation: true # require an explanation for nolint directives
require-specific: true # require nolint directives to mention the specific linter being suppressed
gocyclo:
min-complexity: 20
goconst:
ignore-tests: true
wrapcheck:
ignoreSigs:
- .Errorf(
- errors.New(
- errors.Unwrap(
- errors.Join(
- .Wrap(
- .Wrapf(
- .WithMessage(
- .WithMessagef(
- .WithStack(
- (context.Context).Err()
goheader:
template-path: '.golangci.goheader.template'
values:
regexp:
copyright-year: 20[2-9]\d
lll:
line-length: 120

issues:
exclude-rules:
- path: _test\.go
linters:
- dogsled
- gosec
- gocognit
- errcheck
- forcetypeassert
- funlen
- err113
- dupl
- maintidx

linters:
# please, do not use `enable-all`: it's deprecated and will be removed soon.
# inverted configuration with `enable-all` and `disable` is not scalable during updates of golangci-lint
disable-all: true
enable:
- asasalint
- asciicheck
- bidichk
- bodyclose
- containedctx
- contextcheck
- copyloopvar
- decorder
# - depguard
- dogsled
- dupl
- dupword
- durationcheck
- errcheck
- errchkjson
- errname
# - errorlint
# - exhaustive
# - exhaustivestruct
- exportloopref
- errorlint
- exhaustive
# - forbidigo
# - forcetypeassert
# - funlen
# - gochecknoinits
- forcetypeassert
- funlen
- gci
- ginkgolinter
- gocheckcompilerdirectives
- gochecknoinits
- gocognit
- goconst
- gocritic
- gocyclo
# - cyclop # not interested in package complexities at the moment
- godot
- err113
- gofmt
# - gofumpt
- gofumpt
- goheader
- goimports
- revive
# - gomnd
- gomoddirectives
- gomodguard
- goprintffuncname
- gosec
- gosimple
- gosmopolitan
- govet
# - ifshort
- grouper
- importas
- ineffassign
# - importas
- lll
# - misspell
- interfacebloat
# - ireturn # Doesn't have correct support for generic types https://github.com/butuzov/ireturn/issues/37
- loggercheck
- maintidx
- makezero
# - nakedret
# - nilerr
# - nilnil
- nlreturn
- mirror
- misspell
- musttag
- nakedret
- nestif
- nilerr
- nilnil
- noctx
- nolintlint
- paralleltest
- nosprintfhostport
- prealloc
- predeclared
- promlinter
- reassign
- revive
- rowserrcheck
- sqlclosecheck
- staticcheck
- stylecheck
- sqlclosecheck
# - tagliatelle
# - tenv
# - thelper
# - tparallel
- typecheck
- tenv
- testableexamples
- thelper
- unconvert
# - unparam
- unparam
- unused
- usestdlibvars
- wastedassign
- whitespace
# - wrapcheck
# - wsl

# don't enable:
# - asciicheck
# - dupl
# - gochecknoglobals
# - gocognit
# - godox
# - goerr113
# - maligned
# - nestif
# - prealloc
# - testpackage
# - wsl
- wrapcheck
- zerologlint
10 changes: 7 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,15 @@ build:

.PHONY: test
test:
docker-compose -f test/docker-compose.yml up --quiet-pull -d
go test $(GOTEST_FLAGS) ./...; ret=$$?; \
docker-compose -f test/docker-compose.yml down; \
docker compose -f test/docker-compose.yml up --quiet-pull -d --wait
go test $(GOTEST_FLAGS) -race ./...; ret=$$?; \
docker compose -f test/docker-compose.yml down; \
exit $$ret

.PHONY: generate
generate:
go generate ./...

.PHONY: lint
lint:
golangci-lint run
Expand Down
6 changes: 0 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,6 @@

The [NATS](https://nats.io/) PubSub connector is one of [Conduit](https://github.com/ConduitIO/conduit) plugins. It provides both, a source and a destination NATS PubSub connector.

### Prerequisites

- [Go](https://go.dev/) 1.21
- (optional) [golangci-lint](https://github.com/golangci/golangci-lint) 1.55.2
- [NATS](https://nats.io/download/) 2.8.4

### How to build it

Run `make`.
Expand Down
18 changes: 10 additions & 8 deletions acceptance_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@ import (
"testing"

"github.com/brianvoe/gofakeit"
"github.com/conduitio-labs/conduit-connector-nats-pubsub/config"
"github.com/conduitio-labs/conduit-connector-nats-pubsub/destination"
"github.com/conduitio-labs/conduit-connector-nats-pubsub/test"
"github.com/conduitio/conduit-commons/opencdc"
sdk "github.com/conduitio/conduit-connector-sdk"
"github.com/google/uuid"
)
Expand All @@ -29,19 +30,19 @@ type driver struct {
sdk.ConfigurableAcceptanceTestDriver
}

func (d driver) ReadFromDestination(_ *testing.T, records []sdk.Record) []sdk.Record {
func (d driver) ReadFromDestination(_ *testing.T, records []opencdc.Record) []opencdc.Record {
return records
}

func (d driver) GenerateRecord(_ *testing.T, operation sdk.Operation) sdk.Record {
func (d driver) GenerateRecord(_ *testing.T, operation opencdc.Operation) opencdc.Record {
id := gofakeit.Int32()

return sdk.Record{
return opencdc.Record{
Position: nil,
Operation: operation,
Metadata: nil,
Payload: sdk.Change{
After: sdk.RawData([]byte(
Payload: opencdc.Change{
After: opencdc.RawData([]byte(
fmt.Sprintf(`"id":%d,"name":"%s"`, id, gofakeit.FirstName()),
)),
},
Expand All @@ -51,7 +52,7 @@ func (d driver) GenerateRecord(_ *testing.T, operation sdk.Operation) sdk.Record
//nolint:paralleltest // we don't need the paralleltest here
func TestAcceptance(t *testing.T) {
cfg := map[string]string{
config.KeyURLs: test.TestURL,
destination.ConfigUrls: test.TestURL,
}

sdk.AcceptanceTest(t, driver{
Expand All @@ -61,8 +62,9 @@ func TestAcceptance(t *testing.T) {
SourceConfig: cfg,
DestinationConfig: cfg,
BeforeTest: func(t *testing.T) {
t.Helper()
subject := t.Name() + uuid.New().String()
cfg[config.KeySubject] = subject
cfg[destination.ConfigSubject] = subject
},
Skip: []string{
// NATS PubSub doesn't handle position
Expand Down
Loading

0 comments on commit da9748f

Please sign in to comment.