Skip to content

Commit

Permalink
Fix pipelines
Browse files Browse the repository at this point in the history
  • Loading branch information
nhatthm committed Jan 23, 2023
1 parent 134996b commit e9a6331
Show file tree
Hide file tree
Showing 8 changed files with 61 additions and 22 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}

- id: get-lint-version
- id: vars
run: |
make golangci-lint-version
make $GITHUB_OUTPUT
- name: lint
uses: golangci/golangci-lint-action@v3
with:
# Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version.
version: ${{ steps.get-lint-version.outputs.GOLANGCI_LINT_VERSION }}
version: ${{ steps.vars.outputs.GOLANGCI_LINT_VERSION }}

# Optional: working directory, useful for monorepos
# working-directory: somedir
Expand Down
10 changes: 9 additions & 1 deletion .github/workflows/update-registry.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ name: 'update-registry'

on:
push:
branches:
- master
tags:
- v*
workflow_dispatch:
Expand All @@ -17,11 +19,17 @@ jobs:
matrix:
registry: [ go.nhat.io, go-staging.nhat.io ]
steps:
- uses: actions/checkout@v3

- id: vars
run: |
make $GITHUB_OUTPUT
- name: notify ${{ matrix.registry }}
uses: benc-uk/workflow-dispatch@v121
with:
workflow: build
repo: nhatthm/${{ matrix.registry }}
token: ${{ secrets.REGISTRY_TOKEN }}
inputs: '{"modules": "${{ env.MODULE_NAME }}"}'
inputs: '{"modules": "${{ steps.vars.outputs.MODULE_NAME }}"}'
ref: 'master'
18 changes: 13 additions & 5 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,17 +1,24 @@
BUILD_DIR ?= out
MODULE_NAME=grpcmock

VENDOR_DIR = vendor

GOLANGCI_LINT_VERSION ?= v1.48.0
GOLANGCI_LINT_VERSION ?= v1.50.1

GO ?= go
GOLANGCI_LINT ?= $(shell go env GOPATH)/bin/golangci-lint-$(GOLANGCI_LINT_VERSION)

GITHUB_OUTPUT ?= /dev/null

.PHONY: $(VENDOR_DIR)
$(VENDOR_DIR):
@mkdir -p $(VENDOR_DIR)
@$(GO) mod vendor
@$(GO) mod tidy

.PHONY: tidy
tidy:
@$(GO) mod tidy

.PHONY: lint
lint: $(GOLANGCI_LINT) $(VENDOR_DIR)
@$(GOLANGCI_LINT) run -c .golangci.yaml
Expand All @@ -35,9 +42,10 @@ gen:
@rm -rf test/grpctest
@protoc --go_out=. --go-grpc_out=. resources/protobuf/service.proto

.PHONY: golangci-lint-version
golangci-lint-version:
@echo "::set-output name=GOLANGCI_LINT_VERSION::$(GOLANGCI_LINT_VERSION)"
.PHONY: $(GITHUB_OUTPUT)
$(GITHUB_OUTPUT):
@echo "MODULE_NAME=$(MODULE_NAME)" >> "$@"
@echo "GOLANGCI_LINT_VERSION=$(GOLANGCI_LINT_VERSION)" >> "$@"

$(GOLANGCI_LINT):
@echo "$(OK_COLOR)==> Installing golangci-lint $(GOLANGCI_LINT_VERSION)$(NO_COLOR)"; \
Expand Down
2 changes: 1 addition & 1 deletion assert/assert.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,5 +57,5 @@ func JSONEq(t assert.TestingT, expected, actual interface{}, msgAndArgs ...inter
}

func sanitizeErrorMessage(msg string) string {
return strings.ReplaceAll(msg, "\\00a0", " ")
return strings.ReplaceAll(msg, "\u00a0", " ")
}
37 changes: 30 additions & 7 deletions go.sum

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion reflect/reflect_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"go.nhat.io/grpcmock/test/grpctest"
)

type testServer interface {
type testServer interface { //nolint: interfacebloat
// RPC Methods.
GetItem(context.Context, getItemRequest) (getItemResponse, error)

Expand Down
2 changes: 1 addition & 1 deletion request/server_stream.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (r *ServerStreamRequest) ReturnFile(filePath string) {
// ReturnError(codes.Internal, "stream error")
//
// See: ServerStreamRequest.Return(), ServerStreamRequest.Returnf(), ServerStreamRequest.ReturnJSON(), ServerStreamRequest.ReturnFile().
func (r *ServerStreamRequest) ReturnStream() *serverStreamHandler {
func (r *ServerStreamRequest) ReturnStream() *serverStreamHandler { //nolint: revive
h := &serverStreamHandler{}

r.ReturnCode(codes.OK)
Expand Down
6 changes: 3 additions & 3 deletions request/stream_step.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ func stepSend(expectedType reflect.Type, msg interface{}) streamStepFunc {

switch resp := msg.(type) {
case []byte, string:
out := xreflect.New(expectedType).(proto.Message)
out := xreflect.New(expectedType).(proto.Message) //nolint: errcheck

if err := protojson.Unmarshal([]byte(value.String(resp)), out); err != nil {
return status.Error(codes.Internal, err.Error())
Expand All @@ -67,7 +67,7 @@ func stepSend(expectedType reflect.Type, msg interface{}) streamStepFunc {
}
}

func stepSendMany(msgType reflect.Type, msg interface{}) streamStepFunc {
func stepSendMany(msgType reflect.Type, msg interface{}) streamStepFunc { //nolint: cyclop
return func(_ context.Context, s grpc.ServerStream) error {
expectedType := reflect.SliceOf(msgType)

Expand Down Expand Up @@ -110,7 +110,7 @@ func stepSendMany(msgType reflect.Type, msg interface{}) streamStepFunc {
}

for _, m := range msgs {
out := xreflect.New(msgType).(proto.Message)
out := xreflect.New(msgType).(proto.Message) //nolint: errcheck

if err := protojson.Unmarshal(m, out); err != nil {
return status.Error(codes.Internal, err.Error())
Expand Down

0 comments on commit e9a6331

Please sign in to comment.