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

ci: fix mssql docker service failed in ci #3792

Merged
merged 2 commits into from
Sep 23, 2024
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
13 changes: 7 additions & 6 deletions .github/workflows/ci-main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,24 @@ for file in `find . -name go.mod`; do
dirpath=$(dirname $file)
echo $dirpath

# ignore mssql tests as its docker service failed
# TODO remove this ignoring codes after the mssql docker service OK
if [ "mssql" = $(basename $dirpath) ]; then
continue 1
fi

if [[ $file =~ "/testdata/" ]]; then
echo "ignore testdata path $file"
continue 1
fi

# package kuhecm needs golang >= v1.19
# package kuhecm was moved to sub ci procedure.
if [ "kubecm" = $(basename $dirpath) ]; then
continue 1
if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then
echo "ignore kubecm as go version: $(go version)"
continue 1
fi
fi

# package consul needs golang >= v1.19
if [ "consul" = $(basename $dirpath) ]; then
continue 1
if ! go version|grep -qE "go1.19|go1.[2-9][0-9]"; then
echo "ignore consul as go version: $(go version)"
continue 1
Expand Down
34 changes: 18 additions & 16 deletions .github/workflows/ci-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,22 +108,24 @@ jobs:
# -e MSSQL_USER=root \
# -e MSSQL_PASSWORD=LoremIpsum86 \
# loads/mssqldocker:14.0.3391.2
mssql:
image: loads/mssqldocker:14.0.3391.2
env:
ACCEPT_EULA: Y
SA_PASSWORD: LoremIpsum86
MSSQL_DB: test
MSSQL_USER: root
MSSQL_PASSWORD: LoremIpsum86
ports:
- 1433:1433
options: >-
--health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1"
--health-start-period 10s
--health-interval 10s
--health-timeout 5s
--health-retries 10

# TODO mssql docker failed, will be enabled later after it is OK in github action.
# mssql:
# image: loads/mssqldocker:14.0.3391.2
# env:
# ACCEPT_EULA: Y
# SA_PASSWORD: LoremIpsum86
# MSSQL_DB: test
# MSSQL_USER: root
# MSSQL_PASSWORD: LoremIpsum86
# ports:
# - 1433:1433
# options: >-
# --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1"
# --health-start-period 10s
# --health-interval 10s
# --health-timeout 5s
# --health-retries 10

# ClickHouse backend server.
# docker run -d --name clickhouse \
Expand Down
2 changes: 1 addition & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ linters-settings:
# Checks the number of lines in a function.
# If lower than 0, disable the check.
# Default: 60
lines: 330
lines: 340
# Checks the number of statements in a function.
# If lower than 0, disable the check.
# Default: 40
Expand Down
8 changes: 5 additions & 3 deletions cmd/gf/internal/cmd/gendao/gendao.go
Original file line number Diff line number Diff line change
Expand Up @@ -208,9 +208,11 @@ type (
NoModelComment bool `name:"noModelComment" short:"m" brief:"{CGenDaoBriefNoModelComment}" orphan:"true"`
Clear bool `name:"clear" short:"a" brief:"{CGenDaoBriefClear}" orphan:"true"`

TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenDaoBriefTypeMapping}" orphan:"true"`
FieldMapping map[DBTableFieldName]CustomAttributeType `name:"fieldMapping" short:"fm" brief:"{CGenDaoBriefFieldMapping}" orphan:"true"`
genItems *CGenDaoInternalGenItems
TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenDaoBriefTypeMapping}" orphan:"true"`
FieldMapping map[DBTableFieldName]CustomAttributeType `name:"fieldMapping" short:"fm" brief:"{CGenDaoBriefFieldMapping}" orphan:"true"`

// internal usage purpose.
genItems *CGenDaoInternalGenItems
}
CGenDaoOutput struct{}

Expand Down
2 changes: 1 addition & 1 deletion net/gclient/gclient_observability.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ func internalMiddlewareObservability(c *Client, r *http.Request) (response *Resp
if response == nil || response.Response == nil {
return
}

// TODO ignore binary content ReadAll, for example downloading request.
reqBodyContentBytes, _ := io.ReadAll(response.Body)
response.Body = utils.NewReadCloser(reqBodyContentBytes, false)

Expand Down
4 changes: 4 additions & 0 deletions util/gconv/gconv.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ var (
}
)

// IUnmarshalValue is the interface for custom defined types customizing value assignment.
// Note that only pointer can implement interface IUnmarshalValue.
type IUnmarshalValue = localinterface.IUnmarshalValue

func init() {
// register common converters for internal usage.
structcache.RegisterCommonConverter(structcache.CommonConverter{
Expand Down
28 changes: 28 additions & 0 deletions util/gconv/gconv_z_unit_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
// Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://github.com/gogf/gf.

package gconv_test

import (
"testing"

"github.com/gogf/gf/v2/test/gtest"
"github.com/gogf/gf/v2/util/gconv"
)

type impUnmarshalValue struct{}

func (*impUnmarshalValue) UnmarshalValue(interface{}) error {
return nil
}

func TestIUnmarshalValue(t *testing.T) {
gtest.C(t, func(t *gtest.T) {
var v any = &impUnmarshalValue{}
_, ok := (v).(gconv.IUnmarshalValue)
t.AssertEQ(ok, true)
})
}
16 changes: 8 additions & 8 deletions util/gconv/internal/localinterface/localinterface.go
Original file line number Diff line number Diff line change
Expand Up @@ -89,24 +89,24 @@ type IMapStrAny interface {
MapStrAny() map[string]interface{}
}

// IUnmarshalValue is the interface for custom defined types customizing value assignment.
// Note that only pointer can implement interface iUnmarshalValue.
type IUnmarshalValue interface {
UnmarshalValue(interface{}) error
}

// IUnmarshalText is the interface for custom defined types customizing value assignment.
// Note that only pointer can implement interface iUnmarshalText.
// Note that only pointer can implement interface IUnmarshalText.
type IUnmarshalText interface {
UnmarshalText(text []byte) error
}

// IUnmarshalJSON is the interface for custom defined types customizing value assignment.
// Note that only pointer can implement interface iUnmarshalJSON.
// Note that only pointer can implement interface IUnmarshalJSON.
type IUnmarshalJSON interface {
UnmarshalJSON(b []byte) error
}

// IUnmarshalValue is the interface for custom defined types customizing value assignment.
// Note that only pointer can implement interface IUnmarshalValue.
type IUnmarshalValue interface {
UnmarshalValue(interface{}) error
}

// ISet is the interface for custom value assignment.
type ISet interface {
Set(value interface{}) (old interface{})
Expand Down
5 changes: 5 additions & 0 deletions util/gvalid/gvalid_validator_check_struct.go
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,7 @@ func (v *Validator) doCheckStruct(ctx context.Context, object interface{}) Error
case reflect.Map, reflect.Ptr, reflect.Slice, reflect.Array:
// Nothing to do.
continue
default:
}
}
v.doCheckValueRecursively(ctx, doCheckValueRecursivelyInput{
Expand All @@ -272,6 +273,7 @@ func (v *Validator) doCheckStruct(ctx context.Context, object interface{}) Error
ErrorMaps: errorMaps,
ResultSequenceRules: &resultSequenceRules,
})
default:
}
}
if v.bail && len(errorMaps) > 0 {
Expand All @@ -284,6 +286,7 @@ func (v *Validator) doCheckStruct(ctx context.Context, object interface{}) Error

// The following logic is the same as some of CheckMap but with sequence support.
for _, checkRuleItem := range checkRules {
// it ignores Meta object.
if !checkRuleItem.IsMeta {
value = getPossibleValueFromMap(
inputParamMap, checkRuleItem.Name, fieldToAliasNameMap[checkRuleItem.Name],
Expand All @@ -300,6 +303,7 @@ func (v *Validator) doCheckStruct(ctx context.Context, object interface{}) Error
if gconv.String(value) == emptyJsonArrayStr {
value = ""
}
default:
}
}
// It checks each rule and its value in loop.
Expand All @@ -322,6 +326,7 @@ func (v *Validator) doCheckStruct(ctx context.Context, object interface{}) Error
required := false
// rule => error
for ruleKey := range errorItem {
// it checks whether current rule is kind of required rule.
if required = v.checkRuleRequired(ruleKey); required {
break
}
Expand Down
Loading