diff --git a/.github/workflows/dev.yml b/.github/workflows/dev.yml index 48d5d40..f7eabee 100644 --- a/.github/workflows/dev.yml +++ b/.github/workflows/dev.yml @@ -3,9 +3,7 @@ name: CI -on: - pull_request: - branches: [ "main" ] +on: [push, pull_request] env: GO_VERSION: "1.22.5" @@ -19,10 +17,11 @@ jobs: - uses: actions/setup-go@v5 with: go-version: ${{ env.GO_VERSION }} + - run: go mod tidy - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - version: v1.60 + version: latest build: env: diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000..359c882 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,6 @@ +issues: + exclude-rules: + - path: internal/server/server\.go + linters: + - staticcheck + text: "SA1019:.*deprecated" diff --git a/go.mod b/go.mod index d81d606..86c9b48 100644 --- a/go.mod +++ b/go.mod @@ -57,6 +57,6 @@ require ( ) replace ( - github.com/Project-HAMi/HAMi v0.0.0 => github.com/Project-HAMi/HAMi v0.0.0-20250107033239-d04fc8baaad6 + github.com/Project-HAMi/HAMi v0.0.0 => github.com/Project-HAMi/HAMi v0.0.0-20250901013025-61c6cbe7d480 huawei.com/npu-exporter/v6 => gitee.com/ascend/ascend-npu-exporter/v6 v6.0.0-RC3 ) diff --git a/internal/server/server.go b/internal/server/server.go index e67ff2a..33489ca 100644 --- a/internal/server/server.go +++ b/internal/server/server.go @@ -25,6 +25,7 @@ import ( "path" "time" + "github.com/Project-HAMi/HAMi/pkg/device" "github.com/Project-HAMi/HAMi/pkg/device/ascend" "github.com/Project-HAMi/HAMi/pkg/util" "github.com/Project-HAMi/HAMi/pkg/util/nodelock" @@ -190,10 +191,10 @@ func (ps *PluginServer) registerKubelet() error { func (ps *PluginServer) registerHAMi() error { devs := ps.mgr.GetDevices() - apiDevices := make([]*util.DeviceInfo, 0, len(devs)) + apiDevices := make([]*device.DeviceInfo, 0, len(devs)) // hami currently believes that the index starts from 0 and is continuous. for i, dev := range devs { - apiDevices = append(apiDevices, &util.DeviceInfo{ + apiDevices = append(apiDevices, &device.DeviceInfo{ Index: uint(i), ID: dev.UUID, Count: int32(ps.mgr.VDeviceCount()), @@ -205,7 +206,7 @@ func (ps *PluginServer) registerHAMi() error { }) } annos := make(map[string]string) - annos[ps.registerAnno] = util.MarshalNodeDevices(apiDevices) + annos[ps.registerAnno] = device.MarshalNodeDevices(apiDevices) annos[ps.handshakeAnno] = "Reported_" + time.Now().Add(time.Duration(*reportTimeOffset)*time.Second).Format("2006.01.02 15:04:05") node, err := util.GetNode(ps.nodeName) if err != nil {