diff --git a/.changelog/unreleased/dependencies/35-bump-go.md b/.changelog/unreleased/dependencies/35-bump-go.md new file mode 100644 index 0000000..730a5e6 --- /dev/null +++ b/.changelog/unreleased/dependencies/35-bump-go.md @@ -0,0 +1,2 @@ +- bump Go version from 1.20 to 1.22 + ([\#35](https://github.com/cometbft/cometbft-load-test/pull/35)) diff --git a/.codespellrc b/.codespellrc new file mode 100644 index 0000000..65862f8 --- /dev/null +++ b/.codespellrc @@ -0,0 +1,3 @@ +[codespell] +skip = *.sum,go.mod +quiet-level = 2 diff --git a/.editorconfig b/.editorconfig new file mode 100644 index 0000000..481621f --- /dev/null +++ b/.editorconfig @@ -0,0 +1,16 @@ +# top-most EditorConfig file +root = true + +# Unix-style newlines with a newline ending every file +[*] +charset = utf-8 +end_of_line = lf +insert_final_newline = true +trim_trailing_whitespace = true + +[*.{sh,Makefile}] +indent_style = tab + +[*.proto] +indent_style = space +indent_size = 2 diff --git a/.github/CODEOWNERS b/.github/CODEOWNERS new file mode 100644 index 0000000..57019cb --- /dev/null +++ b/.github/CODEOWNERS @@ -0,0 +1,10 @@ +# CODEOWNERS: https://help.github.com/articles/about-codeowners/ + +# Everything goes through the following "global owners" by default. +# Unless a later match takes precedence, these three will be +# requested for review when someone opens a PR. +# Note that the last matching pattern takes precedence, so +# global owners are only requested if there isn't a more specific +# codeowner specified below. For this reason, the global codeowners +# are often repeated in package-level definitions. +* @cometbft/engineering @cometbft/devrel diff --git a/.github/workflows/go-version.env b/.github/workflows/go-version.env index ccf0177..329aef0 100644 --- a/.github/workflows/go-version.env +++ b/.github/workflows/go-version.env @@ -1,2 +1,2 @@ # .github/workflows/go-version.env -GO_VERSION=1.20.14 +GO_VERSION=1.22.6 diff --git a/.gitignore b/.gitignore index e8f1042..cd873ec 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,5 @@ __pycache__ venv/ /deployment/hosts coverage.txt + +dist/ diff --git a/.goreleaser.yaml b/.goreleaser.yaml new file mode 100644 index 0000000..c98a43e --- /dev/null +++ b/.goreleaser.yaml @@ -0,0 +1,50 @@ +# This is an example .goreleaser.yml file with some sensible defaults. +# Make sure to check the documentation at https://goreleaser.com + +# The lines below are called `modelines`. See `:help modeline` +# Feel free to remove those if you don't want/need to use them. +# yaml-language-server: $schema=https://goreleaser.com/static/schema.json +# vim: set ts=2 sw=2 tw=0 fo=cnqoj + +version: 2 + +before: + hooks: + # You may remove this if you don't use go modules. + - go mod tidy + +builds: + - main: ./cmd/cometbft-load-test/main.go + env: + - CGO_ENABLED=0 + goos: + - linux + - windows + - darwin + goarch: + - amd64 + - arm + - arm64 + +archives: + - format: tar.gz + # this name template makes the OS and Arch compatible with the results of `uname`. + name_template: >- + {{ .ProjectName }}_ + {{- title .Os }}_ + {{- if eq .Arch "amd64" }}x86_64 + {{- else if eq .Arch "386" }}i386 + {{- else }}{{ .Arch }}{{ end }} + {{- if .Arm }}v{{ .Arm }}{{ end }} + # use zip for windows archives + format_overrides: + - goos: windows + format: zip + files: + - LICENSE + - README.md + - CHANGELOG.md + +release: + prerelease: auto + name_template: "v{{.Version}}" diff --git a/.goreleaser.yml b/.goreleaser.yml deleted file mode 100644 index e677a00..0000000 --- a/.goreleaser.yml +++ /dev/null @@ -1,29 +0,0 @@ -project_name: cometbft-load-test - -env: - # Require use of Go modules. - - GO111MODULE=on - -builds: - - main: ./cmd/cometbft-load-test/main.go - goos: - - linux - - darwin - - windows - goarch: - - amd64 - -checksum: - name_template: SHA256SUMS-{{.Version}}.txt - algorithm: sha256 - -release: - header: | - See the CHANGELOG for details regarding this release. - name_template: "v{{.Version}}" - -archives: - - files: - - LICENSE - - README.md - - CHANGELOG.md diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 0000000..ae37bdb --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,30 @@ +--- +# Details: https://pre-commit.com/#new-hooks + +repos: + # golangci-lint + - repo: https://github.com/golangci/golangci-lint + rev: v1.58.0 + hooks: + - id: golangci-lint-full + args: [--timeout, 10m] # for CI + + # gofumpt (does not have .pre-commmit-hooks.yaml) + - repo: local + hooks: + - id: gofumpt + name: "gofumpt" + additional_dependencies: + - mvdan.cc/gofumpt@v0.6.0 + entry: "gofumpt" + language: golang + args: [-w, .] + types: [go] + pass_filenames: false + + # codespell + - repo: https://github.com/codespell-project/codespell + rev: v2.2.6 + hooks: + - id: codespell + args: [-w] diff --git a/Makefile b/Makefile index b538e39..0d3a865 100644 --- a/Makefile +++ b/Makefile @@ -56,14 +56,26 @@ bench: go test -bench="Benchmark" -run="notests" ./... .PHONY: bench -lint: - go run github.com/golangci/golangci-lint/cmd/golangci-lint@latest run -.PHONY: lint - clean: rm -rf $(BUILD_DIR) .PHONY: clean +############################################################################### +### Formatting, linting, and vetting ### +############################################################################### + +#? lint: Lint, format and fix typos +lint: pre-commit + @pre-commit run +.PHONY: lint + +#? vulncheck: Run latest govulncheck vulncheck: @go run golang.org/x/vuln/cmd/govulncheck@latest ./... .PHONY: vulncheck + +#? pre-commit: Create pre-commit hook using the pre-commit framework. +pre-commit: + @which pre-commit || pip3 install pre-commit + @pre-commit install +.PHONY: pre-commit diff --git a/go.mod b/go.mod index 8b37278..9af4bfd 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/cometbft/cometbft-load-test -go 1.20 +go 1.22 require ( github.com/google/uuid v1.6.0 diff --git a/go.sum b/go.sum index a982b2d..be46d86 100644 --- a/go.sum +++ b/go.sum @@ -7,6 +7,7 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs 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/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= @@ -16,10 +17,12 @@ github.com/inconshreveable/mousetrap v1.1.0/go.mod h1:vpF70FUmC8bwa3OWnCshd2FqLf github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -33,6 +36,7 @@ github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65 github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= +github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/russross/blackfriday/v2 v2.1.0/go.mod h1:+Rmxgy9KzJVeS9/2gXHxylqXiyQDYRxCVz55jmeOWTM= github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ= github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ= @@ -51,6 +55,7 @@ google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6h google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/internal/logging/logging.go b/internal/logging/logging.go index c86879e..bcfcf22 100644 --- a/internal/logging/logging.go +++ b/internal/logging/logging.go @@ -29,8 +29,10 @@ type LogrusLogger struct { type NoopLogger struct{} // LogrusLogger implements Logger -var _ Logger = (*LogrusLogger)(nil) -var _ Logger = (*NoopLogger)(nil) +var ( + _ Logger = (*LogrusLogger)(nil) + _ Logger = (*NoopLogger)(nil) +) // // LogrusLogger diff --git a/pkg/loadtest/cli.go b/pkg/loadtest/cli.go index 2a77f9b..0107114 100644 --- a/pkg/loadtest/cli.go +++ b/pkg/loadtest/cli.go @@ -12,7 +12,7 @@ import ( ) // CLIVersion must be manually updated as new versions are released. -const CLIVersion = "v0.1.0" +const CLIVersion = "v0.2.0" // cliVersionCommitID must be set through linker settings. See // https://stackoverflow.com/a/11355611/1156132 for details.