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

chore: bump go version to 1.22 #1112

Merged
merged 6 commits into from
Oct 15, 2024
Merged
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
75 changes: 0 additions & 75 deletions .drone.yml

This file was deleted.

53 changes: 53 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
name: CI Pipeline

on:
push:
branches:
- main
pull_request:

permissions:
contents: read

env:
GOLANGCI_LINT_VERSION: v1.61.0

jobs:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a problem using one job for lint, build and test? Now it creates one check per job on the PR, would simplify to only have one job with multiple steps when configuring branch protection rules, e.g. which checks to be required
image

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was recommended by the golangci-lint docs to use separate job - https://github.com/golangci/golangci-lint-action?tab=readme-ov-file#how-to-use

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Though it works in the single job.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm okay 🤔 Guess it depends on if you want to run lint in parallel with build/test vs all three synchronously. No strong opinions really, it was more convenient for having one required check and configuring the branch protection

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merged into single job.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ready to rumble. ✔️

lint-build-test:
name: Lint, Build, and Test
runs-on: ubuntu-latest
s4kh marked this conversation as resolved.
Show resolved Hide resolved
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup go
uses: actions/setup-go@v5
with:
go-version-file: ./go.mod

- name: Run golangci-lint
uses: golangci/golangci-lint-action@v6
with:
version: ${{env.GOLANGCI_LINT_VERSION}}
args: |
"./..." --timeout=7m
skip-cache: true
install-mode: binary

- name: Setup Mage
uses: magefile/mage-action@v3
with:
install-only: true

- name: Build
run: |
mage -v build

- name: Install test dependencies
run: |
sudo apt update
sudo apt install -y gcc

- name: Test
run: |
CGO_ENABLED=1 mage -v testRace
11 changes: 8 additions & 3 deletions .golangci.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[run]
skip-files = ["data/.*\\.gen\\.go", "data/generic_nullable_vector\\.go", "data/generic_vector\\.go"]
[issues]
exclude-files = ["data/.*\\.gen\\.go", "data/generic_nullable_vector\\.go", "data/generic_vector\\.go"]

[linters-settings.golint]
min-confidence = 1
Expand Down Expand Up @@ -39,7 +39,7 @@ enable = [
"misspell",
"nakedret",
"rowserrcheck",
"exportloopref",
"copyloopvar",
"staticcheck",
"stylecheck",
"typecheck",
Expand All @@ -59,3 +59,8 @@ enable = [
[[issues.exclude-rules]]
linters = ["errorlint"]
text = "non-wrapping format verb for fmt.Errorf"
[[issues.exclude-rules]]
linters = ["staticcheck"]
text = "SA1019"
[linters-settings.gosec]
excludes = ["G115"]
4 changes: 2 additions & 2 deletions backend/json.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package backend

import (
"fmt"
"errors"
"sort"
"unsafe"

Expand Down Expand Up @@ -166,7 +166,7 @@ func readDataResponseJSON(rsp *DataResponse, iter *jsoniter.Iterator) {
for l2Field := iter.ReadObject(); l2Field != ""; l2Field = iter.ReadObject() {
switch l2Field {
case "error":
rsp.Error = fmt.Errorf(iter.ReadString())
rsp.Error = errors.New(iter.ReadString())

case "status":
rsp.Status = Status(iter.ReadInt32())
Expand Down
6 changes: 3 additions & 3 deletions data/frame_json_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -511,7 +511,7 @@ func readNullable{{.Type}}VectorJSON(iter *jsoniter.Iterator, size int) (*nullab
tname := caser.String(tstr)
tuppr := strings.ToUpper(tstr)

fmt.Printf(" case arrow." + tuppr + ":\n\t\tent = writeArrowData" + tname + "(stream, col)\n")
fmt.Printf(" case arrow.%s:\n\t\tent = writeArrowData%s(stream, col)\n", tuppr, tname)
}

for _, tstr := range types {
Expand Down Expand Up @@ -550,8 +550,8 @@ func readNullable{{.Type}}VectorJSON(iter *jsoniter.Iterator, size int) (*nullab

for _, tstr := range types {
tname := caser.String(tstr)
fmt.Printf(" case FieldType" + tname + ": return read" + tname + "VectorJSON(iter, size)\n")
fmt.Printf(" case FieldTypeNullable" + tname + ": return readNullable" + tname + "VectorJSON(iter, size)\n")
fmt.Printf(" case FieldType%s: return read%sVectorJSON(iter, size)\n", tname, tname)
fmt.Printf(" case FieldTypeNullable%s: return readNullable%sVectorJSON(iter, size)\n", tname, tname)
}

assert.FailNow(t, "fail so we see the output")
Expand Down
4 changes: 2 additions & 2 deletions data/sqlutil/converter.go
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ type Converter struct {
func DefaultConverterFunc(t reflect.Type) func(in interface{}) (interface{}, error) {
return func(in interface{}) (interface{}, error) {
inType := reflect.TypeOf(in)
if inType == reflect.PtrTo(t) {
if inType == reflect.PointerTo(t) {
n := reflect.ValueOf(in)

return n.Elem().Interface(), nil
Expand Down Expand Up @@ -180,7 +180,7 @@ func NewDefaultConverter(name string, nullable bool, t reflect.Type) Converter {

v := reflect.New(t)
var fieldType data.FieldType
if v.Type() == reflect.PtrTo(t) {
if v.Type() == reflect.PointerTo(t) {
v = v.Elem()
fieldType = data.FieldTypeFor(v.Interface())
} else {
Expand Down
2 changes: 1 addition & 1 deletion data/sqlutil/converter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ func TestDefaultConverter(t *testing.T) {
assert.Equal(t, reflect.TypeOf(value).String(), v.Type.String())
} else {
// nullable fields should not exactly match
kind := reflect.PtrTo(v.Type).String()
kind := reflect.PointerTo(v.Type).String()
valueKind := reflect.TypeOf(value).String()
if !strings.HasPrefix(kind, "*sql.Null") {
assert.Equal(t, valueKind, kind)
Expand Down
2 changes: 1 addition & 1 deletion data/time_series.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func (t TimeSeriesType) String() string {
func (f *Frame) TimeSeriesSchema() TimeSeriesSchema {
var tsSchema TimeSeriesSchema
tsSchema.Type = TimeSeriesTypeNot
if f.Fields == nil || len(f.Fields) == 0 {
if len(f.Fields) == 0 {
return tsSchema
}

Expand Down
4 changes: 2 additions & 2 deletions data/time_series_field_sort_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ func TestSortWideFrameFields(t *testing.T) {
require.NoError(t, err)
if diff := cmp.Diff(tt.frameToSort, tt.afterSort, FrameTestCompareOptions()...); diff != "" {
t.Errorf("Result mismatch (-want +got):\n%s", diff)
t.Logf(tt.frameToSort.StringTable(-1, -1))
t.Log(tt.frameToSort.StringTable(-1, -1))
}
})
}
Expand Down Expand Up @@ -210,7 +210,7 @@ func TestSortWideFrameFields_MixedLabels(t *testing.T) {
require.NoError(t, err)
if diff := cmp.Diff(tt.frameToSort, tt.afterSort, FrameTestCompareOptions()...); diff != "" {
t.Errorf("Result mismatch (-want +got):\n%s", diff)
t.Logf(tt.frameToSort.StringTable(-1, -1))
t.Log(tt.frameToSort.StringTable(-1, -1))
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion experimental/concurrent/concurrent.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package concurrent

import (
"context"
"errors"
"fmt"
"net/http"

Expand Down Expand Up @@ -52,7 +53,7 @@ func QueryData(ctx context.Context, req *backend.QueryDataRequest, fn QueryDataF
if theErr, ok := r.(error); ok {
err = theErr
} else if theErrString, ok := r.(string); ok {
err = fmt.Errorf(theErrString)
err = errors.New(theErrString)
} else {
err = fmt.Errorf("unexpected error - %w", err)
}
Expand Down
4 changes: 2 additions & 2 deletions experimental/e2e/config/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,14 @@ func LoadConfig(path string) (*Config, error) {
cfg.Address = "127.0.0.1:9999"
}

if cfg.Storage == nil || len(cfg.Storage) == 0 {
if len(cfg.Storage) == 0 {
cfg.Storage = []*StorageConfig{{
Type: StorageTypeHAR,
Path: "fixtures/e2e.har",
}}
}

if cfg.Hosts == nil || len(cfg.Hosts) == 0 {
if len(cfg.Hosts) == 0 {
cfg.Hosts = make([]string, 0)
}

Expand Down
4 changes: 3 additions & 1 deletion experimental/golden_response_checker.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ package experimental

import (
"bufio"
"errors"

// ignoring the G505 so that the checksum matches git hash
// nolint:gosec
"crypto/sha1"
Expand Down Expand Up @@ -69,7 +71,7 @@ func CheckGoldenDataResponse(path string, dr *backend.DataResponse, updateFile b
}

if len(errorString) > 0 {
return errorAfterUpdate(fmt.Errorf(errorString), path, dr, updateFile)
return errorAfterUpdate(errors.New(errorString), path, dr, updateFile)
}

return nil // OK
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/grafana/grafana-plugin-sdk-go

go 1.21
go 1.22

require (
github.com/apache/arrow/go/v15 v15.0.2
Expand Down