diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index 810a3446..22d916c5 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -14,7 +14,7 @@ on: permissions: contents: read jobs: - test: + lint: runs-on: ubuntu-latest steps: - name: Checkout code diff --git a/.golangci.yaml b/.golangci.yaml index cb5f6dc4..ddc5719f 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -2,11 +2,28 @@ version: "2" linters: default: none enable: + - bodyclose + # - dogsled + - dupl # - errcheck - - govet + - gochecknoinits + - goconst + # - gocritic + # - gocyclo + # - godot + # - gosec + # - govet - ineffassign - - staticcheck - - unused + - misspell + - nakedret + # - prealloc + # - revive + # - staticcheck + - unconvert + # - unparam + # - unused + - whitespace + formatters: enable: - gofmt diff --git a/.mise.lock b/.mise.lock index fb481735..314684e6 100644 --- a/.mise.lock +++ b/.mise.lock @@ -11,6 +11,7 @@ version = "2.2.2" backend = "aqua:golangci/golangci-lint" [tools.golangci-lint.checksums] +"golangci-lint-2.2.2-darwin-arm64.tar.gz" = "sha256:d84d94d042c0d495fd1746f3d18948a75de163b17a14e8de3ef840928dd2df74" "golangci-lint-2.2.2-linux-amd64.tar.gz" = "sha256:c27fbde948a87d326feacd21df2f61a9c54dbd2e3bfa185c0a1cd6917a6f964f" [tools.protoc] diff --git a/Makefile b/Makefile index 8052dab3..0a2782a4 100644 --- a/Makefile +++ b/Makefile @@ -93,9 +93,17 @@ vet: format: go fmt ./... -.PHONY: lint -lint: - golangci-lint run +LINT_TARGETS := lint lint-and-fix +.PHONY: $(LINT_TARGETS) _lint +$(LINT_TARGETS): _lint +lint: ARGS= +lint-and-fix: ARGS=--fix +_lint: + golangci-lint run $(ARGS) + +# .PHONY: lint-and-fix +# lint-and-fix: lint +# ARGS="--fix" .PHONY: docs-image-push docs-image: diff --git a/experiment/syncer.go b/experiment/syncer.go index 244d99cb..21c88968 100644 --- a/experiment/syncer.go +++ b/experiment/syncer.go @@ -4,18 +4,19 @@ import ( "context" "errors" "fmt" + "log/slog" + "github.com/hashicorp/serf/serf" "github.com/ipfs/boxo/datastore/dshelp" dag "github.com/ipfs/boxo/ipld/merkledag" "github.com/ipfs/go-cid" ds "github.com/ipfs/go-datastore" ipld "github.com/ipfs/go-ipld-format" - "log/slog" ) // Implements the DAGService interface. // TODO: implement SessionDAGService to optimize node fetching. -// TOOD: persistentSerfDAG? +// TODO: persistentSerfDAG? type dagSyncer struct { // Persistent storage for the nodes. store ds.Datastore @@ -50,8 +51,7 @@ func (d *dagSyncer) Get(ctx context.Context, cid cid.Cid) (ipld.Node, error) { } slog.Debug("Queried node from peers", "cid", cid, "deadline", query.Deadline()) - responded := false - for !responded { + for { select { case resp, ok := <-query.ResponseCh(): if !ok { @@ -63,7 +63,6 @@ func (d *dagSyncer) Get(ctx context.Context, cid cid.Cid) (ipld.Node, error) { continue } slog.Debug("Received node from peer", "cid", cid, "peer", resp.From) - responded = true query.Close() node, err = nodeFromBytes(resp.Payload) diff --git a/pkg/client/compose/service.go b/pkg/client/compose/service.go index 5c55dede..7d2eff1b 100644 --- a/pkg/client/compose/service.go +++ b/pkg/client/compose/service.go @@ -88,7 +88,6 @@ func ServiceSpecFromCompose(project *types.Project, serviceName string) (api.Ser default: return spec, fmt.Errorf("unsupported deploy mode: '%s'", service.Deploy.Mode) } - } // TODO: can service.tmpfs be handled as tmpfs volume mounts as well? diff --git a/test/e2e/compose_build_test.go b/test/e2e/compose_build_test.go index d229945b..36006ec5 100644 --- a/test/e2e/compose_build_test.go +++ b/test/e2e/compose_build_test.go @@ -160,6 +160,5 @@ func TestComposeBuild(t *testing.T) { require.NoError(t, err) assert.Equal(t, tags, []string{"version2"}, "Tags for service service-second do not match") - }) } diff --git a/test/e2e/compose_deploy_test.go b/test/e2e/compose_deploy_test.go index e9bb95a5..3ae40908 100644 --- a/test/e2e/compose_deploy_test.go +++ b/test/e2e/compose_deploy_test.go @@ -97,7 +97,7 @@ func TestComposeDeployment(t *testing.T) { deploy, err := compose.NewDeployment(ctx, cli, project) require.NoError(t, err) - plan, err := deploy.Plan(ctx) + _, err = deploy.Plan(ctx) require.ErrorContains(t, err, "external volumes not found: 'test-compose-volumes-external'") externalVolumeOpts := volume.CreateOptions{Name: "test-compose-volumes-external"} @@ -108,7 +108,7 @@ func TestComposeDeployment(t *testing.T) { deploy, err = compose.NewDeployment(ctx, cli, project) require.NoError(t, err) - plan, err = deploy.Plan(ctx) + plan, err := deploy.Plan(ctx) require.NoError(t, err) assert.Len(t, plan.Operations, 5, "Expected 2 volumes creation and 3 services to deploy") diff --git a/test/e2e/service_test.go b/test/e2e/service_test.go index 4fd306cd..45d3039f 100644 --- a/test/e2e/service_test.go +++ b/test/e2e/service_test.go @@ -1119,7 +1119,7 @@ func TestServiceLifecycle(t *testing.T) { Entrypoint: []string{"///pause"}, Env: map[string]string{ "VAR": "value", - "EMTPY": "", + "EMPTY": "", "BOOL": "true", "": "ignored", },