Skip to content
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
36 changes: 27 additions & 9 deletions .github/workflows/project-check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,17 @@ jobs:
find ./charts | grep Chart.yaml | xargs dirname | xargs helm lint

build:
strategy:
fail-fast: false
matrix:
runner: ["ubuntu-latest", "ubuntu-24.04-arm"]
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: auto
CI_TEST_FLAGS: -race -coverprofile=coverage.txt -covermode=atomic
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
runs-on: ubuntu-latest
runs-on: ${{ matrix.runner }}
steps:
- name: Set up Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
Expand All @@ -93,17 +96,32 @@ jobs:
with:
path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid

- name: CI Preparation
- name: CI script
run: |
arch=$(go env GOARCH)
os=$(go env GOOS)
curl -L https://github.com/kubernetes-sigs/kubebuilder/releases/download/v2.3.1/kubebuilder_2.3.1_${os}_${arch}.tar.gz | tar -xz -C /tmp/
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
export PATH=$PATH:/usr/local/kubebuilder/bin
make build

unittest:
runs-on: ubuntu-latest
env:
GOPATH: ${{ github.workspace }}
GO111MODULE: auto
CI_TEST_FLAGS: -race -coverprofile=coverage.txt -covermode=atomic
defaults:
run:
working-directory: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
steps:
- name: Set up Go
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
with:
go-version: ${{ env.GO_VERSION }}

- name: Checkout code
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid

- name: CI script
run: |
make build
make test

- name: Upload coverage to Codecov
Expand Down
8 changes: 4 additions & 4 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@ PACKAGE := github.com/fluid-cloudnative/fluid
# Go and build settings
GO_MODULE ?= off
GC_FLAGS ?= -gcflags="all=-N -l"
LOCAL_FLAGS ?= -gcflags=-l
LOCAL_FLAGS ?= -gcflags="all=-N -l"
CGO_ENABLED ?= 0
GOOS ?= linux
GOOS ?= $(shell go env GOOS)
GOBIN := $(shell if [ -z "$(shell go env GOBIN)" ]; then echo "$(shell go env GOPATH)/bin"; else echo "$(shell go env GOBIN)"; fi)

# Architecture detection
UNAME := $(shell uname -m)
ifeq ($(UNAME), aarch64)
ARCH := arm64
ifeq ($(UNAME),$(filter $(UNAME),aarch64 arm64))
ARCH := arm64
else
ARCH := amd64
endif
Expand Down
2 changes: 1 addition & 1 deletion pkg/ddc/alluxio/operations/base.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,7 +321,7 @@ func (a AlluxioFileUtils) GetMountedAlluxioPaths() ([]string, error) {
return mountedPaths, err
}

func (a AlluxioFileUtils) FindUnmountedAlluxioPaths(alluxioPaths []string) ([]string, error) {
func (a *AlluxioFileUtils) FindUnmountedAlluxioPaths(alluxioPaths []string) ([]string, error) {
mountedPaths, err := a.GetMountedAlluxioPaths()
if err != nil {
return []string{}, err
Expand Down
14 changes: 7 additions & 7 deletions pkg/ddc/alluxio/operations/base_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -642,26 +642,26 @@ func TestAlluxioFileUtils_MasterPodName(t *testing.T) {
}

func TestAlluxioFileUtils_ExecMountScripts(t *testing.T) {
ExecCommon := func(a AlluxioFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) {
ExecCommon := func(command []string, verbose bool) (stdout string, stderr string, err error) {
return strings.Join(command, " "), "", nil
}
ExecErr := func(a AlluxioFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) {
ExecErr := func(command []string, verbose bool) (stdout string, stderr string, err error) {
return "", "", errors.New("fail to run the command")
}

// 修复Windows环境下gomonkey.ApplyMethod的问题
Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@xliuqq Would you like to have a double check here? I'm not sure if it may cause problems on Windows.

Copy link
Copy Markdown
Collaborator

@xliuqq xliuqq Nov 18, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

checked, no problems on windows.
It's generated by AI, you can delete it directly.

patches := gomonkey.ApplyPrivateMethod(reflect.TypeOf(AlluxioFileUtils{}), "exec", ExecErr)
defer patches.Reset()

a := &AlluxioFileUtils{log: fake.NullLogger()}
patch1 := gomonkey.ApplyPrivateMethod(*a, "exec", ExecErr)

err := a.ExecMountScripts()
if err == nil {
t.Error("check failure, want err, got nil")
}
patch1.Reset()

patches.ApplyPrivateMethod(reflect.TypeOf(AlluxioFileUtils{}), "exec", ExecCommon)
patch2 := gomonkey.ApplyPrivateMethod(*a, "exec", ExecCommon)
err = a.ExecMountScripts()
if err != nil {
t.Errorf("check failure, want nil, got err: %v", err)
}
patch2.Reset()
}
4 changes: 2 additions & 2 deletions pkg/ddc/alluxio/ufs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -657,12 +657,12 @@ func TestFindUnmountedUFS(t *testing.T) {
mockClient := fake.NewFakeClientWithScheme(s, &runtime, &dataset)

var afsUtils operations.AlluxioFileUtils
patch1 := gomonkey.ApplyMethod(reflect.TypeOf(afsUtils), "Ready", func(_ operations.AlluxioFileUtils) bool {
patch1 := gomonkey.ApplyMethod(afsUtils, "Ready", func(_ operations.AlluxioFileUtils) bool {
return true
})
defer patch1.Reset()

patch2 := gomonkey.ApplyMethod(reflect.TypeOf(afsUtils), "FindUnmountedAlluxioPaths", func(_ operations.AlluxioFileUtils, alluxioPaths []string) ([]string, error) {
patch2 := gomonkey.ApplyMethod(&afsUtils, "FindUnmountedAlluxioPaths", func(_ *operations.AlluxioFileUtils, alluxioPaths []string) ([]string, error) {
return alluxioPaths, nil
})
defer patch2.Reset()
Expand Down
Loading