diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index 08daadc83..0ff9939cf 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -25,6 +25,7 @@ jobs: - "1.20" - "1.21" - "1.22" + - "1.23" steps: - name: Checkout uses: actions/checkout@v4 @@ -34,14 +35,6 @@ jobs: with: go-version: ${{ matrix.goVersion }} - - name: Set go env - run: | - echo "GOPATH=$(go env GOPATH)" >> $GITHUB_ENV - echo "$(go env GOPATH)/bin" >> $GITHUB_PATH - - - name: Pull external libraries - run: make vendor - - name: Run tests run: make test @@ -50,6 +43,21 @@ jobs: env: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} + lint: + runs-on: ubuntu-latest + + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Setup Go + uses: actions/setup-go@v5 + with: + go-version: "1.23" + + - name: Run linters + run: make lint + fmt: runs-on: ubuntu-latest @@ -60,7 +68,7 @@ jobs: - name: Setup Go uses: actions/setup-go@v5 with: - go-version: "1.22" + go-version: "1.23" # No need to download cached dependencies when running gofmt. cache: false @@ -75,4 +83,3 @@ jobs: run: | # Exit with status code 1 if there are differences (i.e. unformatted files) git diff --exit-code - \ No newline at end of file diff --git a/Makefile b/Makefile index 57bf25ddd..adbac53c8 100644 --- a/Makefile +++ b/Makefile @@ -12,9 +12,9 @@ fmt: lint: vendor @echo "✓ Linting source code with https://staticcheck.io/ ..." - @go run honnef.co/go/tools/cmd/staticcheck@v0.4.0 ./... + @go run honnef.co/go/tools/cmd/staticcheck@v0.5.1 ./... -test: lint +test: vendor @echo "✓ Running tests ..." @go run gotest.tools/gotestsum@latest --format pkgname-and-test-fails \ --no-summary=skipped --raw-command go test -v \ @@ -32,10 +32,4 @@ doc: @echo "Open http://localhost:6060" @go run golang.org/x/tools/cmd/godoc@latest -http=localhost:6060 -install-codegen: vendor - @go build -o ~/go/bin/oac openapi/gen/main.go - -gen: - @go run openapi/gen/main.go - .PHONY: fmt vendor fmt coverage test lint doc diff --git a/httpclient/request_test.go b/httpclient/request_test.go index 64b38d0cc..6b388af53 100644 --- a/httpclient/request_test.go +++ b/httpclient/request_test.go @@ -89,7 +89,7 @@ func TestMakeRequestBodyJsonError(t *testing.T) { type failingUrlEncode string func (fue failingUrlEncode) EncodeValues(key string, v *url.Values) error { - return fmt.Errorf(string(fue)) + return fmt.Errorf("%s", string(fue)) } func TestMakeRequestBodyQueryFailingEncode(t *testing.T) { diff --git a/retries/retries.go b/retries/retries.go index 8517e0e07..a0ce9354b 100644 --- a/retries/retries.go +++ b/retries/retries.go @@ -59,7 +59,7 @@ func Continue(err error) *Err { } func Continues(msg string) *Err { - return Continue(fmt.Errorf(msg)) + return Continue(fmt.Errorf("%s", msg)) } func Continuef(format string, err error, args ...interface{}) *Err { diff --git a/service/compute/ext_results.go b/service/compute/ext_results.go index d13024a0b..f7ec9d50a 100644 --- a/service/compute/ext_results.go +++ b/service/compute/ext_results.go @@ -1,7 +1,7 @@ package compute import ( - "fmt" + "errors" "html" "regexp" "strings" @@ -38,7 +38,7 @@ func (r *Results) Err() error { if !r.Failed() { return nil } - return fmt.Errorf(r.Error()) + return errors.New(r.Error()) } // Error returns error in a bit more friendly way diff --git a/service/jobs/ext_api.go b/service/jobs/ext_api.go index 42417150e..0b8f3ee80 100644 --- a/service/jobs/ext_api.go +++ b/service/jobs/ext_api.go @@ -12,7 +12,7 @@ func (a *JobsAPI) GetRun(ctx context.Context, request GetRunRequest) (*Run, erro // When querying a Job run, a page token is returned when there are more than 100 tasks. No iterations are defined for a Job run. Therefore, the next page in the response only includes the next page of tasks. // When querying a ForEach task run, a page token is returned when there are more than 100 iterations. Only a single task is returned, corresponding to the ForEach task itself. Therefore, the client only reads the iterations from the next page and not the tasks. - isPaginatingIterations := run.Iterations != nil && len(run.Iterations) > 0 + isPaginatingIterations := len(run.Iterations) > 0 pageToken := run.NextPageToken for pageToken != "" { diff --git a/service/sql/ext_utilities.go b/service/sql/ext_utilities.go index 4b85f8cc6..aedc83cf0 100644 --- a/service/sql/ext_utilities.go +++ b/service/sql/ext_utilities.go @@ -27,7 +27,7 @@ func (a *StatementExecutionAPI) ExecuteAndWait(ctx context.Context, request Exec if status.Error != nil { msg = fmt.Sprintf("%s: %s %s", msg, status.Error.ErrorCode, status.Error.Message) } - return nil, fmt.Errorf(msg) + return nil, fmt.Errorf("%s", msg) default: // TODO: parse request.WaitTimeout and use it here return retries.Poll[StatementResponse](ctx, 20*time.Minute, @@ -50,7 +50,7 @@ func (a *StatementExecutionAPI) ExecuteAndWait(ctx context.Context, request Exec if status.Error != nil { msg = fmt.Sprintf("%s: %s %s", msg, status.Error.ErrorCode, status.Error.Message) } - return nil, retries.Halt(fmt.Errorf(msg)) + return nil, retries.Halt(fmt.Errorf("%s", msg)) default: return nil, retries.Continues(status.State.String()) }