mirror of
https://github.com/psviderski/uncloud.git
synced 2026-08-26 11:03:34 +00:00
chore: Enable more linters
This commit is contained in:
@@ -14,7 +14,7 @@ on:
|
||||
permissions:
|
||||
contents: read
|
||||
jobs:
|
||||
test:
|
||||
lint:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout code
|
||||
|
||||
+20
-3
@@ -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
|
||||
|
||||
@@ -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]
|
||||
|
||||
@@ -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:
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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?
|
||||
|
||||
@@ -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")
|
||||
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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")
|
||||
|
||||
|
||||
@@ -1119,7 +1119,7 @@ func TestServiceLifecycle(t *testing.T) {
|
||||
Entrypoint: []string{"///pause"},
|
||||
Env: map[string]string{
|
||||
"VAR": "value",
|
||||
"EMTPY": "",
|
||||
"EMPTY": "",
|
||||
"BOOL": "true",
|
||||
"": "ignored",
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user