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

[Internal] Bump staticcheck to 0.5.1 and add go 1.23 test coverage #1106

Merged
merged 2 commits into from
Jan 3, 2025
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
27 changes: 17 additions & 10 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ jobs:
- "1.20"
- "1.21"
- "1.22"
- "1.23"
steps:
- name: Checkout
uses: actions/checkout@v4
Expand All @@ -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

Expand All @@ -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

Expand All @@ -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
Expand All @@ -75,4 +83,3 @@ jobs:
run: |
# Exit with status code 1 if there are differences (i.e. unformatted files)
git diff --exit-code

10 changes: 2 additions & 8 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand All @@ -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
2 changes: 1 addition & 1 deletion httpclient/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion retries/retries.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions service/compute/ext_results.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package compute

import (
"fmt"
"errors"
"html"
"regexp"
"strings"
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion service/jobs/ext_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 != "" {
Expand Down
4 changes: 2 additions & 2 deletions service/sql/ext_utilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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())
}
Expand Down
Loading