Skip to content
Snippets Groups Projects
Commit 5756f1ea authored by Cameron Swords's avatar Cameron Swords :ghost:
Browse files

Use consistent order for imports

parent 8bf13621
No related branches found
No related tags found
1 merge request!78Use consistent order for imports
Showing
with 57 additions and 26 deletions
......@@ -11,11 +11,9 @@ stages:
go-fmt:
stage: test
image: $GO_IMAGE
script: |
if [[ -n $(gofmt -l .) ]]; then
gofmt -d .
exit 1
fi
script:
- make go-fmt
- git diff --exit-code
go-lint:
stage: test
......
......@@ -21,6 +21,9 @@ PROTO_GEN := $(wildcard proto/*.pb.go)
SCHEMA_SRC := $(shell find schema/v1 -name "*.go")
SCHEMA_GEN := $(wildcard schema/v1/*.json)
GOIMPORTS := goimports
GOIMPORTS_VERSION := v0.23.0
.PHONY: build
build: $(PROTO_GEN) $(SCHEMA_GEN)
go build .
......@@ -38,6 +41,7 @@ $(SCHEMA_GEN): $(SCHEMA_SRC)
.PHONY: .generate-proto
.generate-proto: $(PROTOC) $(PROTOC_GEN_GO) $(PROTOC_GEN_GO_GRPC) $(PROTOVALIDATE_DIST)
go generate ./proto
@$(MAKE) DIRECTORY=./proto go-fmt
.PHONY: generate
generate:
......@@ -91,3 +95,12 @@ image:
check-generated: generate
@git --no-pager diff --compact-summary --exit-code && \
git --no-pager diff --compact-summary --cached --exit-code
.PHONY: $(GOIMPORTS)
$(GOIMPORTS):
@go install golang.org/x/tools/cmd/goimports@$(GOIMPORTS_VERSION)
.PHONY: go-fmt
go-fmt: DIRECTORY := .
go-fmt: $(GOIMPORTS)
goimports -w -local gitlab.com/gitlab-org/step-runner $(DIRECTORY)
......@@ -9,13 +9,14 @@ import (
"slices"
"github.com/spf13/cobra"
"google.golang.org/protobuf/encoding/protojson"
"gopkg.in/yaml.v3"
"gitlab.com/gitlab-org/step-runner/pkg/cache"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"gitlab.com/gitlab-org/step-runner/pkg/runner"
"gitlab.com/gitlab-org/step-runner/pkg/step"
"gitlab.com/gitlab-org/step-runner/schema/v1"
"google.golang.org/protobuf/encoding/protojson"
"gopkg.in/yaml.v3"
)
var Cmd = &cobra.Command{
......
......@@ -10,9 +10,10 @@ import (
"syscall"
"github.com/spf13/cobra"
"gitlab.com/gitlab-org/step-runner/pkg/api/service"
"google.golang.org/grpc"
"gitlab.com/gitlab-org/step-runner/pkg/api/service"
"gitlab.com/gitlab-org/step-runner/proto"
)
......
......@@ -15,11 +15,12 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/step-runner/pkg/jobs"
"gitlab.com/gitlab-org/step-runner/proto"
"google.golang.org/grpc"
"google.golang.org/grpc/credentials/insecure"
"google.golang.org/grpc/test/bufconn"
"gitlab.com/gitlab-org/step-runner/pkg/jobs"
"gitlab.com/gitlab-org/step-runner/proto"
)
const (
......
......@@ -2,10 +2,12 @@ package expression
import (
"fmt"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"strings"
"golang.org/x/exp/slices"
"google.golang.org/protobuf/types/known/structpb"
"strings"
"gitlab.com/gitlab-org/step-runner/pkg/context"
)
func Evaluate(obj any, s string) (*context.Variable, error) {
......
......@@ -3,9 +3,10 @@ package expression
import (
"bytes"
"errors"
"testing"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"gitlab.com/gitlab-org/step-runner/proto"
"testing"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/structpb"
......
......@@ -2,9 +2,11 @@ package expression
import (
"fmt"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"google.golang.org/protobuf/types/known/structpb"
"regexp"
"google.golang.org/protobuf/types/known/structpb"
"gitlab.com/gitlab-org/step-runner/pkg/context"
)
const InterpolateOpen = "${{"
......
......@@ -2,9 +2,10 @@ package expression
import (
"errors"
"gitlab.com/gitlab-org/step-runner/proto"
"testing"
"gitlab.com/gitlab-org/step-runner/proto"
"github.com/stretchr/testify/require"
"google.golang.org/protobuf/types/known/structpb"
)
......
......@@ -7,10 +7,11 @@ import (
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"gitlab.com/gitlab-org/step-runner/proto"
protobuf "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"gitlab.com/gitlab-org/step-runner/proto"
)
func TestOutput(t *testing.T) {
......
......@@ -10,6 +10,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/step-runner/proto"
)
......
......@@ -6,6 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/step-runner/proto"
)
......
......@@ -6,6 +6,7 @@ import (
"testing"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/step-runner/proto"
)
......
......@@ -3,17 +3,19 @@ package runner
import (
"bytes"
ctx "context"
"gitlab.com/gitlab-org/step-runner/pkg/cache"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"gitlab.com/gitlab-org/step-runner/pkg/step"
"maps"
"os"
"testing"
"gitlab.com/gitlab-org/step-runner/pkg/cache"
"gitlab.com/gitlab-org/step-runner/pkg/context"
"gitlab.com/gitlab-org/step-runner/pkg/step"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/step-runner/proto"
protobuf "google.golang.org/protobuf/proto"
"google.golang.org/protobuf/types/known/structpb"
"gitlab.com/gitlab-org/step-runner/proto"
)
type runnerTest struct {
......
......@@ -6,9 +6,10 @@ import (
"strconv"
"strings"
"google.golang.org/protobuf/types/known/structpb"
"gitlab.com/gitlab-org/step-runner/proto"
schema "gitlab.com/gitlab-org/step-runner/schema/v1"
"google.golang.org/protobuf/types/known/structpb"
)
func CompileSteps(steps *schema.StepDefinition) (*proto.SpecDefinition, error) {
......
......@@ -4,9 +4,10 @@ import (
"testing"
"github.com/stretchr/testify/require"
protobuf "google.golang.org/protobuf/proto"
"gitlab.com/gitlab-org/step-runner/proto"
schema "gitlab.com/gitlab-org/step-runner/schema/v1"
protobuf "google.golang.org/protobuf/proto"
)
func TestCompile(t *testing.T) {
......
......@@ -7,6 +7,7 @@ import (
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
"gitlab.com/gitlab-org/step-runner/proto"
)
......
......@@ -7,12 +7,13 @@
package proto
import (
reflect "reflect"
sync "sync"
_ "buf.build/gen/go/bufbuild/protovalidate/protocolbuffers/go/buf/validate"
protoreflect "google.golang.org/protobuf/reflect/protoreflect"
protoimpl "google.golang.org/protobuf/runtime/protoimpl"
structpb "google.golang.org/protobuf/types/known/structpb"
reflect "reflect"
sync "sync"
)
const (
......
......@@ -8,6 +8,7 @@ package proto
import (
context "context"
grpc "google.golang.org/grpc"
codes "google.golang.org/grpc/codes"
status "google.golang.org/grpc/status"
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment