mirror of
https://github.com/gogf/gf.git
synced 2025-04-05 11:18:50 +08:00
ci test
This commit is contained in:
parent
f6f0c8fd1e
commit
df3ae386cb
66
.github/workflows/gf.yml
vendored
66
.github/workflows/gf.yml
vendored
@ -117,43 +117,43 @@ jobs:
|
||||
echo "gofmt check pass."
|
||||
sudo echo "127.0.0.1 local" | sudo tee -a /etc/hosts
|
||||
|
||||
- name: CLI Build & Test
|
||||
run: |
|
||||
cd cmd/gf
|
||||
go mod tidy
|
||||
go build ./...
|
||||
GOARCH=386 go test ./... || exit 1
|
||||
GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
||||
|
||||
- name: Example Build & Test
|
||||
run: |
|
||||
cd example
|
||||
go mod tidy
|
||||
go build ./...
|
||||
GOARCH=386 go test ./... || exit 1
|
||||
GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
||||
|
||||
- name: Contrib Build & Test
|
||||
run: |
|
||||
cd contrib
|
||||
for file in `find . -name go.mod`; do
|
||||
dirpath=$(dirname $file)
|
||||
# Ignore oracle database driver build&test.
|
||||
if [ "oracle" = $(basename $dirpath) ]; then
|
||||
continue 1
|
||||
fi
|
||||
cd $dirpath
|
||||
go mod tidy
|
||||
go build ./...
|
||||
GOARCH=386 go test ./... || exit 1
|
||||
GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
||||
cd -
|
||||
done
|
||||
# - name: CLI Build & Test
|
||||
# run: |
|
||||
# cd cmd/gf
|
||||
# go mod tidy
|
||||
# go build ./...
|
||||
# GOARCH=386 go test ./... || exit 1
|
||||
# GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
||||
#
|
||||
# - name: Example Build & Test
|
||||
# run: |
|
||||
# cd example
|
||||
# go mod tidy
|
||||
# go build ./...
|
||||
# GOARCH=386 go test ./... || exit 1
|
||||
# GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
||||
#
|
||||
# - name: Contrib Build & Test
|
||||
# run: |
|
||||
# cd contrib
|
||||
# for file in `find . -name go.mod`; do
|
||||
# dirpath=$(dirname $file)
|
||||
# # Ignore oracle database driver build&test.
|
||||
# if [ "oracle" = $(basename $dirpath) ]; then
|
||||
# continue 1
|
||||
# fi
|
||||
# cd $dirpath
|
||||
# go mod tidy
|
||||
# go build ./...
|
||||
# GOARCH=386 go test ./... || exit 1
|
||||
# GOARCH=amd64 go test ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
||||
# cd -
|
||||
# done
|
||||
|
||||
- name: Main Build & Test
|
||||
run: |
|
||||
go build ./...
|
||||
GOARCH=386 go test -v ./... || exit 1
|
||||
# GOARCH=386 go test -v ./... || exit 1
|
||||
GOARCH=amd64 go test -v ./... -race -coverprofile=coverage.txt -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1
|
||||
|
||||
# - name: Merge Coverage
|
||||
|
@ -207,10 +207,12 @@ func (c *AdapterFile) Available(ctx context.Context, fileName ...string) bool {
|
||||
} else {
|
||||
usedFileName = c.defaultName
|
||||
}
|
||||
if path, _ := c.GetFilePath(usedFileName); path != "" {
|
||||
// Custom configuration content exists.
|
||||
if c.GetContent(usedFileName) != "" {
|
||||
return true
|
||||
}
|
||||
if c.GetContent(usedFileName) != "" {
|
||||
// Configuration file exists in system path.
|
||||
if path, _ := c.GetFilePath(usedFileName); path != "" {
|
||||
return true
|
||||
}
|
||||
return false
|
||||
@ -258,7 +260,7 @@ func (c *AdapterFile) getJson(fileName ...string) (configJson *gjson.Json, err e
|
||||
return nil
|
||||
}
|
||||
if file := gres.Get(filePath); file != nil {
|
||||
fmt.Println("retrieve config content from gres:", filePath)
|
||||
fmt.Println("retrieve file content from gres:", filePath)
|
||||
content = string(file.Content())
|
||||
} else {
|
||||
content = gfile.GetContents(filePath)
|
||||
|
@ -19,7 +19,7 @@ import (
|
||||
"github.com/gogf/gf/v2/test/gtest"
|
||||
)
|
||||
|
||||
func Test_PackToGoFile(t *testing.T) {
|
||||
func Test_PackFolderToGoFile(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
srcPath = gtest.DataPath("files")
|
||||
@ -32,6 +32,23 @@ func Test_PackToGoFile(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_PackMultiFilesToGoFile(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
srcPath = gtest.DataPath("files")
|
||||
goFilePath = gfile.Temp(gtime.TimestampNanoStr(), "data.go")
|
||||
pkgName = "data"
|
||||
array, err = gfile.ScanDir(srcPath, "*", false)
|
||||
)
|
||||
t.AssertNil(err)
|
||||
err = gres.PackToGoFile(strings.Join(array, ","), goFilePath, pkgName)
|
||||
t.AssertNil(err)
|
||||
defer gfile.Remove(goFilePath)
|
||||
|
||||
t.AssertNil(gfile.CopyFile(goFilePath, gtest.DataPath("data/data.go")))
|
||||
})
|
||||
}
|
||||
|
||||
func Test_Pack(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
@ -65,21 +82,6 @@ func Test_PackToFile(t *testing.T) {
|
||||
})
|
||||
}
|
||||
|
||||
func Test_PackMulti(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
srcPath = gtest.DataPath("files")
|
||||
goFilePath = gfile.Temp(gtime.TimestampNanoStr(), "data.go")
|
||||
pkgName = "data"
|
||||
array, err = gfile.ScanDir(srcPath, "*", false)
|
||||
)
|
||||
t.AssertNil(err)
|
||||
err = gres.PackToGoFile(strings.Join(array, ","), goFilePath, pkgName)
|
||||
t.AssertNil(err)
|
||||
_ = gfile.Remove(goFilePath)
|
||||
})
|
||||
}
|
||||
|
||||
func Test_PackWithPrefix1(t *testing.T) {
|
||||
gtest.C(t, func(t *gtest.T) {
|
||||
var (
|
||||
|
2
os/gres/testdata/data/data.go
vendored
Normal file → Executable file
2
os/gres/testdata/data/data.go
vendored
Normal file → Executable file
File diff suppressed because one or more lines are too long
Loading…
x
Reference in New Issue
Block a user