Skip to content

Commit 256613e

Browse files
authored
ci: add arm arch runner in github actions (#5187)
* add arm arch runner in github actions Signed-off-by: trafalgarzzz <trafalgarz@outlook.com> * make pkg/ddc/alluxio/operations unit tests support arm arch powered by lingma Signed-off-by: trafalgarzzz <trafalgarz@outlook.com> * test(ddc.alluxio): fix unit tests on arm arch Signed-off-by: TzZtzt <trafalgarz@outlook.com> * Separate binary build and unit tests in gha Signed-off-by: TzZtzt <trafalgarz@outlook.com> * fix comments Signed-off-by: TzZtzt <trafalgarz@outlook.com> * refactor(build): simplify architecture detection in Makefile - Consolidate aarch64 and arm64 architecture checks into a single condition Signed-off-by: TzZtzt <trafalgarz@outlook.com> --------- Signed-off-by: trafalgarzzz <trafalgarz@outlook.com> Signed-off-by: TzZtzt <trafalgarz@outlook.com>
1 parent 7d9f486 commit 256613e

5 files changed

Lines changed: 41 additions & 23 deletions

File tree

.github/workflows/project-check.yml

Lines changed: 27 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -74,14 +74,17 @@ jobs:
7474
find ./charts | grep Chart.yaml | xargs dirname | xargs helm lint
7575
7676
build:
77+
strategy:
78+
fail-fast: false
79+
matrix:
80+
runner: ["ubuntu-latest", "ubuntu-24.04-arm"]
7781
env:
7882
GOPATH: ${{ github.workspace }}
7983
GO111MODULE: auto
80-
CI_TEST_FLAGS: -race -coverprofile=coverage.txt -covermode=atomic
8184
defaults:
8285
run:
8386
working-directory: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
84-
runs-on: ubuntu-latest
87+
runs-on: ${{ matrix.runner }}
8588
steps:
8689
- name: Set up Go
8790
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
@@ -93,17 +96,32 @@ jobs:
9396
with:
9497
path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
9598

96-
- name: CI Preparation
99+
- name: CI script
97100
run: |
98-
arch=$(go env GOARCH)
99-
os=$(go env GOOS)
100-
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/
101-
sudo mv /tmp/kubebuilder_2.3.1_${os}_${arch} /usr/local/kubebuilder
102-
export PATH=$PATH:/usr/local/kubebuilder/bin
101+
make build
102+
103+
unittest:
104+
runs-on: ubuntu-latest
105+
env:
106+
GOPATH: ${{ github.workspace }}
107+
GO111MODULE: auto
108+
CI_TEST_FLAGS: -race -coverprofile=coverage.txt -covermode=atomic
109+
defaults:
110+
run:
111+
working-directory: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
112+
steps:
113+
- name: Set up Go
114+
uses: actions/setup-go@44694675825211faa026b3c33043df3e48a5fa00 # v6.0.0
115+
with:
116+
go-version: ${{ env.GO_VERSION }}
117+
118+
- name: Checkout code
119+
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
120+
with:
121+
path: ${{ env.GOPATH }}/src/github.com/fluid-cloudnative/fluid
103122

104123
- name: CI script
105124
run: |
106-
make build
107125
make test
108126
109127
- name: Upload coverage to Codecov

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@ PACKAGE := github.com/fluid-cloudnative/fluid
1212
# Go and build settings
1313
GO_MODULE ?= off
1414
GC_FLAGS ?= -gcflags="all=-N -l"
15-
LOCAL_FLAGS ?= -gcflags=-l
15+
LOCAL_FLAGS ?= -gcflags="all=-N -l"
1616
CGO_ENABLED ?= 0
17-
GOOS ?= linux
17+
GOOS ?= $(shell go env GOOS)
1818
GOBIN := $(shell if [ -z "$(shell go env GOBIN)" ]; then echo "$(shell go env GOPATH)/bin"; else echo "$(shell go env GOBIN)"; fi)
1919

2020
# Architecture detection
2121
UNAME := $(shell uname -m)
22-
ifeq ($(UNAME), aarch64)
23-
ARCH := arm64
22+
ifeq ($(UNAME),$(filter $(UNAME),aarch64 arm64))
23+
ARCH := arm64
2424
else
2525
ARCH := amd64
2626
endif

pkg/ddc/alluxio/operations/base.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func (a AlluxioFileUtils) GetMountedAlluxioPaths() ([]string, error) {
321321
return mountedPaths, err
322322
}
323323

324-
func (a AlluxioFileUtils) FindUnmountedAlluxioPaths(alluxioPaths []string) ([]string, error) {
324+
func (a *AlluxioFileUtils) FindUnmountedAlluxioPaths(alluxioPaths []string) ([]string, error) {
325325
mountedPaths, err := a.GetMountedAlluxioPaths()
326326
if err != nil {
327327
return []string{}, err

pkg/ddc/alluxio/operations/base_test.go

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -642,26 +642,26 @@ func TestAlluxioFileUtils_MasterPodName(t *testing.T) {
642642
}
643643

644644
func TestAlluxioFileUtils_ExecMountScripts(t *testing.T) {
645-
ExecCommon := func(a AlluxioFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) {
645+
ExecCommon := func(command []string, verbose bool) (stdout string, stderr string, err error) {
646646
return strings.Join(command, " "), "", nil
647647
}
648-
ExecErr := func(a AlluxioFileUtils, command []string, verbose bool) (stdout string, stderr string, err error) {
648+
ExecErr := func(command []string, verbose bool) (stdout string, stderr string, err error) {
649649
return "", "", errors.New("fail to run the command")
650650
}
651651

652-
// 修复Windows环境下gomonkey.ApplyMethod的问题
653-
patches := gomonkey.ApplyPrivateMethod(reflect.TypeOf(AlluxioFileUtils{}), "exec", ExecErr)
654-
defer patches.Reset()
655-
656652
a := &AlluxioFileUtils{log: fake.NullLogger()}
653+
patch1 := gomonkey.ApplyPrivateMethod(*a, "exec", ExecErr)
654+
657655
err := a.ExecMountScripts()
658656
if err == nil {
659657
t.Error("check failure, want err, got nil")
660658
}
659+
patch1.Reset()
661660

662-
patches.ApplyPrivateMethod(reflect.TypeOf(AlluxioFileUtils{}), "exec", ExecCommon)
661+
patch2 := gomonkey.ApplyPrivateMethod(*a, "exec", ExecCommon)
663662
err = a.ExecMountScripts()
664663
if err != nil {
665664
t.Errorf("check failure, want nil, got err: %v", err)
666665
}
666+
patch2.Reset()
667667
}

pkg/ddc/alluxio/ufs_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -657,12 +657,12 @@ func TestFindUnmountedUFS(t *testing.T) {
657657
mockClient := fake.NewFakeClientWithScheme(s, &runtime, &dataset)
658658

659659
var afsUtils operations.AlluxioFileUtils
660-
patch1 := gomonkey.ApplyMethod(reflect.TypeOf(afsUtils), "Ready", func(_ operations.AlluxioFileUtils) bool {
660+
patch1 := gomonkey.ApplyMethod(afsUtils, "Ready", func(_ operations.AlluxioFileUtils) bool {
661661
return true
662662
})
663663
defer patch1.Reset()
664664

665-
patch2 := gomonkey.ApplyMethod(reflect.TypeOf(afsUtils), "FindUnmountedAlluxioPaths", func(_ operations.AlluxioFileUtils, alluxioPaths []string) ([]string, error) {
665+
patch2 := gomonkey.ApplyMethod(&afsUtils, "FindUnmountedAlluxioPaths", func(_ *operations.AlluxioFileUtils, alluxioPaths []string) ([]string, error) {
666666
return alluxioPaths, nil
667667
})
668668
defer patch2.Reset()

0 commit comments

Comments
 (0)