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

[WIP] Miscellaneous improvements #54

Draft
wants to merge 12 commits into
base: main
Choose a base branch
from
Draft
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
3 changes: 0 additions & 3 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,5 @@ jobs:
with:
go-version-file: 'go.mod'

- name: Build NoOp destination plugin
run: make plugins/noop-dest

- name: Build tool
run: make build
12 changes: 10 additions & 2 deletions .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,16 @@ jobs:
with:
go-version-file: 'go.mod'

# This step sets up the variable steps.golangci-lint-version.outputs.v
# to contain the version of golangci-lint (e.g. v1.54.2).
# The version is taken from go.mod.
- name: Golangci-lint version
id: golangci-lint-version
run: |
GOLANGCI_LINT_VERSION=$( go list -m -f '{{.Version}}' github.com/golangci/golangci-lint )
echo "v=$GOLANGCI_LINT_VERSION" >> "$GITHUB_OUTPUT"

- name: golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: v1.51.2
args: --timeout=2m
version: ${{ steps.golangci-lint-version.outputs.v }}
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ plugins/
workloads-*.csv
.DS_Store
conduit-test-file

# todo find better way
workloads/*/connectors/*
workloads/*/data/conduit-test-file
136 changes: 80 additions & 56 deletions .golangci.yml
Original file line number Diff line number Diff line change
@@ -1,98 +1,122 @@
run:
timeout: 5m

linters-settings:
gofmt:
simplify: false
govet:
check-shadowing: false
funlen:
lines: 70
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
goheader:
template-path: '.golangci.goheader.template'
values:
regexp:
copyright-year: 20[2-9]\d
wrapcheck:
ignoreSigs:
- .Errorf(
- errors.New(
- errors.Unwrap(
- errors.Join(
- .Wrap(
- .Wrapf(
- .WithMessage(
- .WithMessagef(
- .WithStack(
- (context.Context).Err()

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
- 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
61 changes: 53 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,28 +1,73 @@
.PHONY: build-local build-noop-dest run-local run-latest run-latest-nightly print-results
# Define variables
VERSION := 1.3.1
OS := $(shell uname -s | tr A-Z a-z)
ARCH := $(shell uname -m | sed 's/x86_64/amd64/')

# Define the installation directory
NODE_EXPORTER_DIR := $(HOME)/node_exporter

# todo following two are duplicates

.PHONY: build
build:
go build main.go

scripts/benchmark:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o scripts/benchmark main.go

.PHONY: install-tools
install-tools:
@echo Installing tools from tools.go
@go list -e -f '{{ join .Imports "\n" }}' tools.go | xargs -I % go list -f "%@{{.Module.Version}}" % | xargs -tI % go install %
@go mod tidy

# Builds a fresh Docker image, so we're not limited on the GA and nightly builds
.PHONY: build-local
build-local:
@cd ../conduit && docker build -t conduit:local .

plugins/noop-dest:
GOOS=linux GOARCH=amd64 CGO_ENABLED=0 go build -o plugins/noop-dest noopdest/main.go

run-local: plugins/noop-dest
.PHONY: run-local
run-local: scripts/benchmark
scripts/run-docker-all.sh conduit:local

run-latest: plugins/conduit-connector-noop-dest
.PHONY: run-latest
run-latest: scripts/benchmark
docker pull ghcr.io/conduitio/conduit:latest
scripts/run-docker-all.sh ghcr.io/conduitio/conduit:latest

run-latest-nightly: plugins/conduit-connector-noop-dest
.PHONY: run-latest-nightly
run-latest-nightly: scripts/benchmark
docker pull ghcr.io/conduitio/conduit:latest-nightly
scripts/run-docker-all.sh ghcr.io/conduitio/conduit:latest-nightly

.PHONY: fmt
fmt:
gofumpt -l -w .

.PHONY: lint
lint:
golangci-lint run
golangci-lint run -v

.PHONY: install-node-exporter
install-node-exporter:
@if [ -f "$(NODE_EXPORTER_DIR)/node_exporter" ]; then \
echo "node_exporter is already installed."; \
else \
echo "Installing node_exporter..."; \
curl -sSL -o node_exporter-$(VERSION).$(OS)-$(ARCH).tar.gz \
https://github.com/prometheus/node_exporter/releases/download/v$(VERSION)/node_exporter-$(VERSION).$(OS)-$(ARCH).tar.gz || \
{ echo "curl download failed, installation aborted."; exit 1; }; \
tar xvfz node_exporter-*.$(OS)-$(ARCH).tar.gz; \
mkdir -p $(NODE_EXPORTER_DIR); \
mv node_exporter-$(VERSION).$(OS)-$(ARCH)/node_exporter $(NODE_EXPORTER_DIR)/; \
rm -rf node_exporter-*.$(OS)-$(ARCH).tar.gz node_exporter-$(VERSION).$(OS)-$(ARCH); \
echo "node_exporter has been installed to $(NODE_EXPORTER_DIR)"; \
fi

.PHONY: run-node-exporter
run-node-exporter:
@if [ -f "$(NODE_EXPORTER_DIR)/node_exporter" ]; then \
$(NODE_EXPORTER_DIR)/node_exporter; \
else \
echo "node_exporter is not installed. Please run 'make install-node-exporter' first."; \
fi
Loading