From 0e2521e0b465d2a8d6c863c28d6004f4b1b5c7b4 Mon Sep 17 00:00:00 2001 From: Vladimir Dementyev Date: Wed, 10 Jan 2024 12:38:21 -0800 Subject: [PATCH] chore: upgrade to Go 1.21 --- .github/workflows/benchmark.yml | 9 +++---- .github/workflows/lint.yml | 8 +++--- .github/workflows/release-binaries.yml | 4 +-- .github/workflows/release-docker.yml | 6 ++--- .github/workflows/test.yml | 37 ++++++++++++-------------- Makefile | 2 +- go.mod | 2 +- go.sum | 4 +++ utils/gopool.go | 15 ++--------- 9 files changed, 37 insertions(+), 50 deletions(-) diff --git a/.github/workflows/benchmark.yml b/.github/workflows/benchmark.yml index d67b49d5..acce6176 100644 --- a/.github/workflows/benchmark.yml +++ b/.github/workflows/benchmark.yml @@ -13,9 +13,6 @@ on: jobs: benchmark: timeout-minutes: 10 - strategy: - matrix: - go-version: [1.20.x] runs-on: ubuntu-latest env: GO111MODULE: on @@ -26,10 +23,10 @@ jobs: ports: ["6379:6379"] options: --health-cmd="redis-cli ping" --health-interval 1s --health-timeout 3s --health-retries 30 steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 with: - go-version: ${{ matrix.go-version }} + go-version-file: go.mod - name: Install system deps run: | sudo apt-get update diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 12f4ec35..5a14570d 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -10,12 +10,12 @@ jobs: lint: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 with: - go-version: 1.20.x + go-version-file: go.mod - name: golangci-lint uses: golangci/golangci-lint-action@v3 with: - version: v1.52.2 + version: v1.55.2 args: --timeout 3m diff --git a/.github/workflows/release-binaries.yml b/.github/workflows/release-binaries.yml index 94ca3a70..65f78d8f 100644 --- a/.github/workflows/release-binaries.yml +++ b/.github/workflows/release-binaries.yml @@ -33,7 +33,7 @@ jobs: run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' - uses: actions/setup-go@v4 with: - go-version: 1.20.x + go-version-file: go.mod - name: Set VERSION (if any) if: ${{ contains(github.ref, 'refs/tags/v') }} id: version @@ -88,7 +88,7 @@ jobs: run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' - uses: actions/setup-go@v4 with: - go-version: 1.20.x + go-version-file: go.mod - name: Set VERSION (if any) if: ${{ contains(github.ref, 'refs/tags/v') }} id: version diff --git a/.github/workflows/release-docker.yml b/.github/workflows/release-docker.yml index f6f5450f..44bd18b5 100644 --- a/.github/workflows/release-docker.yml +++ b/.github/workflows/release-docker.yml @@ -12,7 +12,7 @@ jobs: CGO_ENABLED: "0" GOFLAGS: "-mod=vendor" steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v4 - name: Install system deps run: | sudo apt-get update @@ -26,9 +26,9 @@ jobs: - run: go mod vendor - name: Build mruby run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' - - uses: actions/setup-go@v2 + - uses: actions/setup-go@v4 with: - go-version: 1.20.x + go-version-file: go.mod - name: Set VERSION (if any) if: ${{ contains(github.ref, 'refs/tags/v') }} id: version diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8f0323ba..4a340ed2 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -9,9 +9,6 @@ on: jobs: test: if: "!contains(github.event.head_commit.message, '[ci skip tests]')" - strategy: - matrix: - go-version: [1.20.x] runs-on: ubuntu-20.04 env: GO111MODULE: on @@ -24,7 +21,7 @@ jobs: ports: ["6379:6379"] options: --health-cmd="redis-cli ping" --health-interval 1s --health-timeout 3s --health-retries 30 steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - name: Install system deps run: | sudo apt-get update @@ -38,9 +35,9 @@ jobs: - run: go mod vendor - name: Build mruby run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' - - uses: actions/setup-go@v3 + - uses: actions/setup-go@v4 with: - go-version: ${{ matrix.go-version }} + go-version-file: go.mod - name: Run tests run: make test - name: Report coverage @@ -50,11 +47,10 @@ jobs: parallel: true flag-name: ${{ matrix.go-version }}-ubuntu - name: Build - if: matrix['go-version'] == '1.20.x' run: | make build - name: Upload linux build - if: matrix['go-version'] == '1.20.x' && (github.ref == 'refs/head/master' || contains(github.event.pull_request.body, '[Build]')) + if: (github.ref == 'refs/head/master' || contains(github.event.pull_request.body, '[Build]')) uses: actions/upload-artifact@v1 with: name: anycable-go-Linux-x86_64 @@ -62,19 +58,16 @@ jobs: test-macos: if: "!contains(github.event.head_commit.message, '[ci skip tests]')" - strategy: - matrix: - go-version: [1.20.x] - runs-on: macos-11 + runs-on: macos-latest env: GO111MODULE: on GOFLAGS: "-mod=vendor" COVERAGE: "true" steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v2 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 with: - go-version: ${{ matrix.go-version }} + go-version-file: go.mod - name: Install system deps run: | brew install bison @@ -84,6 +77,11 @@ jobs: key: vendor-${{ hashFiles('**/go.sum') }} restore-keys: | vendor- + - uses: ruby/setup-ruby@v1 + with: + # Use <3.0 since go-mruby's Rakefile has some problems with keyword arguments compatibility + ruby-version: 2.7 + bundler-cache: true - run: go mod vendor - name: Build mruby run: bash -c '(cd vendor/github.com/mitchellh/go-mruby && MRUBY_CONFIG=../../../../../../etc/build_config.rb make libmruby.a)' @@ -96,11 +94,10 @@ jobs: parallel: true flag-name: ${{ matrix.go-version }}-macos - name: Build - if: matrix['go-version'] == '1.20.x' run: | make build - name: Upload MacOS build - if: matrix['go-version'] == '1.20.x' && (github.ref == 'refs/head/master' || contains(github.event.pull_request.body, '[Build]')) + if: (github.ref == 'refs/head/master' || contains(github.event.pull_request.body, '[Build]')) uses: actions/upload-artifact@v1 with: name: anycable-go-Darwin-x86_64 @@ -143,10 +140,10 @@ jobs: image: nats:alpine ports: ["4222:4222"] steps: - - uses: actions/checkout@v3 - - uses: actions/setup-go@v3 + - uses: actions/checkout@v4 + - uses: actions/setup-go@v4 with: - go-version: 1.20.x + go-version-file: go.mod - name: Install system deps run: | sudo apt-get update diff --git a/Makefile b/Makefile index 3125288c..8507c2d1 100644 --- a/Makefile +++ b/Makefile @@ -178,7 +178,7 @@ gen-ssl: bin/golangci-lint: @test -x $$(go env GOPATH)/bin/golangci-lint || \ - curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.52.2 + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.55.2 lint: bin/golangci-lint $$(go env GOPATH)/bin/golangci-lint run diff --git a/go.mod b/go.mod index 23b091c9..ce2da9c8 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/anycable/anycable-go -go 1.20 +go 1.21 require ( github.com/FZambia/sentinel v1.1.0 diff --git a/go.sum b/go.sum index cadd7deb..08812ed4 100644 --- a/go.sum +++ b/go.sum @@ -129,6 +129,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.9 h1:O2Tfq5qg4qc4AmwVlvv0oLiVAGB7enBSJ2x2DqQFi38= +github.com/google/go-cmp v0.5.9/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-github/v28 v28.1.1/go.mod h1:bsqJWQX05omyWVmc00nEUql9mhQyv38lDZ8kPZcQVoM= github.com/google/go-querystring v1.0.0/go.mod h1:odCYkC5MyYFN7vkCjXpyrEuKhc/BUO6wN/zVPAxq5ck= github.com/google/go-replayers/grpcreplay v0.1.0/go.mod h1:8Ig2Idjpr6gifRd6pNVggX6TC1Zw6Jx74AKp7QNH2QE= @@ -200,6 +201,7 @@ github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/lib/pq v1.1.1/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/magiconair/properties v1.8.0/go.mod h1:PppfXfuXeibc/6YijjN8zIbojt8czPbwD3XqdrwzmxQ= github.com/matoous/go-nanoid v1.5.0 h1:VRorl6uCngneC4oUQqOYtO3S0H5QKFtKuKycFG3euek= @@ -241,6 +243,7 @@ github.com/oklog/ulid v1.3.1/go.mod h1:CirwcVhetQ6Lv90oh/F+FBtV6XMibvdAFo93nm5qn github.com/onsi/ginkgo v1.6.0/go.mod h1:lLunBs/Ym6LB5Z9jYTR76FiuTmxDTDusOGeTQH+WWjE= github.com/onsi/gomega v1.5.0/go.mod h1:ex+gbHU/CVuBBDIJjb2X0qEXbFg53c61hWP/1CpauHY= github.com/onsi/gomega v1.27.10 h1:naR28SdDFlqrG6kScpT8VWpu1xWY5nJRCF3XaYyBjhI= +github.com/onsi/gomega v1.27.10/go.mod h1:RsS8tutOdbdgzbPtzzATp12yT7kM5I5aElG3evPbQ0M= github.com/op/go-logging v0.0.0-20160315200505-970db520ece7/go.mod h1:HzydrMdWErDVzsI23lYNej1Htcns9BCg93Dk0bBINWk= github.com/pelletier/go-toml v1.2.0/go.mod h1:5z9KED0ma1S8pY6P1sdut58dfprrGBbd/94hg7ilaic= github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= @@ -252,6 +255,7 @@ github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZN github.com/posthog/posthog-go v0.0.0-20221221115252-24dfed35d71a h1:Ey0XWvrg6u6hyIn1Kd/jCCmL+bMv9El81tvuGBbxZGg= github.com/posthog/posthog-go v0.0.0-20221221115252-24dfed35d71a/go.mod h1:oa2sAs9tGai3VldabTV0eWejt/O4/OOD7azP8GaikqU= github.com/prashantv/gostub v1.1.0 h1:BTyx3RfQjRHnUWaGF9oQos79AlQ5k8WNktv7VGvVH4g= +github.com/prashantv/gostub v1.1.0/go.mod h1:A5zLQHz7ieHGG7is6LLXLz7I8+3LZzsrV0P1IAHhP5U= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v0.9.3/go.mod h1:/TN21ttK/J9q6uSwhBd54HahCDft0ttaMvbicHlPoso= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= diff --git a/utils/gopool.go b/utils/gopool.go index be7befd1..2753fc02 100644 --- a/utils/gopool.go +++ b/utils/gopool.go @@ -33,20 +33,9 @@ func AllPools() []*GoPool { // Start size defaults to 20% of the max size but not greater than 1024. // Queue size defaults to 50% of the max size. func NewGoPool(name string, size int) *GoPool { - spawn := size / 5 - queue := size / 2 + queue := min(size/2, 1) - if spawn <= 0 { - spawn = 1 - } - - if spawn > 1024 { - spawn = 1024 - } - - if queue <= 0 { - queue = 1 - } + spawn := min(max(size/5, 1), 1024) p := &GoPool{ name: name,