Skip to content

Commit

Permalink
[TT-10673] Upgrading to Go 1.21 (#766)
Browse files Browse the repository at this point in the history
* upgrading to Go 1.21

* fixing loop issue

* removing comment

* linting

* add release 1.19 revert 1.18 req tests

* removing commented linters

* removing 1.19 branch from terraform

---------

Co-authored-by: Esteban Ricardo Mirizio <[email protected]>

(cherry picked from commit e2a7a3c)
  • Loading branch information
mativm02 authored and Tyk Bot committed Jan 17, 2024
1 parent 35e1e74 commit 7f1214f
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 22 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ jobs:
matrix:
redis-version: [5]
mongodb-version: [4.2]
go: [1.19]
go: [1.21]

steps:
- name: Checkout Tyk Pump
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/linter.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ jobs:
strategy:
fail-fast: false
matrix:
go: [1.19]
go: [1.21]
with:
go: ${{ matrix.go }}
redis: 5
Expand All @@ -34,7 +34,7 @@ jobs:
uses: TykTechnologies/github-actions/.github/workflows/golangci.yaml@main
with:
main_branch: "master"
go_version: 1.19
go_version: 1.21
sonarcloud:
if: ${{ always() }}
needs: [gotest, golangci]
Expand Down
14 changes: 7 additions & 7 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,9 @@ jobs:
fail-fast: false
matrix:
golang_cross:
- 1.19-bullseye
- 1.21-bullseye
include:
- golang_cross: 1.19-bullseye
- golang_cross: 1.21-bullseye
goreleaser: 'ci/goreleaser/goreleaser.yml'
cgo: 0
rpmvers: 'el/7 el/8 el/9 amazon/2 amazon/2023'
Expand Down Expand Up @@ -124,13 +124,13 @@ jobs:

- uses: aws-actions/amazon-ecr-login@v2
id: ecr
if: ${{ matrix.golang_cross == '1.19-bullseye' }}
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
with:
mask-password: 'true'

- name: Docker metadata for CI
id: metadata
if: ${{ matrix.golang_cross == '1.19-bullseye' }}
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
uses: docker/metadata-action@v5
with:
images: ${{ steps.ecr.outputs.registry }}/tyk-pump
Expand All @@ -144,7 +144,7 @@ jobs:
type=semver,pattern=v{{version}},prefix=v
- name: CI push
if: ${{ matrix.golang_cross == '1.19-bullseye' }}
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
shell: bash
env:
t: ${{ steps.metadata.outputs.tags }}
Expand All @@ -160,7 +160,7 @@ jobs:
done
- uses: actions/upload-artifact@v3
if: ${{ matrix.golang_cross == '1.19-bullseye' }}
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
with:
name: deb
retention-days: 1
Expand All @@ -169,7 +169,7 @@ jobs:
!dist/*PAYG*.deb
- uses: actions/upload-artifact@v3
if: ${{ matrix.golang_cross == '1.19-bullseye' }}
if: ${{ matrix.golang_cross == '1.21-bullseye' }}
with:
name: rpm
retention-days: 1
Expand Down
8 changes: 3 additions & 5 deletions .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,10 @@ linters:
- govet
- gosec
- ineffassign
# - lll
- misspell
- revive
- staticcheck
- whitespace
# - wsl

linters-settings:
auto-fix: true
Expand Down Expand Up @@ -65,7 +63,7 @@ linters-settings:
extra-rules: true

# Select the Go version to target.
lang-version: "1.19"
lang-version: "1.21"

goimports:
auto-fix: false
Expand All @@ -79,7 +77,7 @@ linters-settings:
enable-all: true

lll:
auto-fix: true
auto-fix: true
# Max line length; lines longer will be reported
# '\t' is counted as 1 character by default, and can be changed with the 'tab-width' option
line-length: 120
Expand All @@ -102,7 +100,7 @@ linters-settings:
# https://staticcheck.io/docs/options#checks
checks: ["all"]
# Select the Go version to target.
go: "1.19"
go: "1.21"

whitespace:
auto-fix: true
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/TykTechnologies/tyk-pump

go 1.19
go 1.21

require (
github.com/DataDog/datadog-go v4.7.0+incompatible
Expand Down
8 changes: 3 additions & 5 deletions main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"context"

"os"
"os/signal"
"sync"
Expand All @@ -28,9 +27,11 @@ func (p *MockedPump) GetName() string {
func (p *MockedPump) New() pumps.Pump {
return &MockedPump{}
}

func (p *MockedPump) Init(config interface{}) error {
return nil
}

func (p *MockedPump) WriteData(ctx context.Context, keys []interface{}) error {
for range keys {
p.CounterRequest++
Expand All @@ -44,7 +45,6 @@ func (p *MockedPump) Shutdown() error {
}

func TestFilterData(t *testing.T) {

mockedPump := &MockedPump{}

mockedPump.SetFilters(
Expand All @@ -62,12 +62,10 @@ func TestFilterData(t *testing.T) {
if len(keys) == len(filteredKeys) {
t.Fatal("keys and filtered keys have the same lenght")
}

}

// TestTrimData check the correct functionality of max_record_size
func TestTrimData(t *testing.T) {

loremIpsum := "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua"

tcs := []struct {
Expand Down Expand Up @@ -226,11 +224,11 @@ func TestWriteDataWithFilters(t *testing.T) {
}

for _, tc := range tcs {
tc := tc
t.Run(tc.testName, func(t *testing.T) {
t.Parallel()
assert.Equal(t, tc.expectedCounterRequest, tc.mockedPump.CounterRequest)
assert.Len(t, keys, 6)

})
}
}
Expand Down
2 changes: 1 addition & 1 deletion repo-policy/main.tf
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ module "tyk-pump" {
{ branch = "master",
reviewers = "1",
convos = "false",
required_tests = ["1.19-bullseye", "Go 1.19 tests", "api-tests (sha256, mongo44)", "api-tests (sha256, postgres15)", "api-tests (murmur64, mongo44)", "api-tests (murmur64, postgres15)"] },
required_tests = ["1.21-bullseye", "Go 1.21 tests", "api-tests (sha256, mongo44)", "api-tests (sha256, postgres15)", "api-tests (murmur64, mongo44)", "api-tests (murmur64, postgres15)"] },
{ branch = "release-1.8",
reviewers = "0",
convos = "false",
Expand Down

0 comments on commit 7f1214f

Please sign in to comment.