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

Bump ci to go 1.18 #70

Merged
merged 4 commits into from
Feb 27, 2023
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
18 changes: 9 additions & 9 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ jobs:
contents: read
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: '1.13'
go-version: '1.18.x'
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: lint
run: make lint
test:
Expand All @@ -23,11 +23,11 @@ jobs:
contents: read
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: '1.13'
go-version: '1.18.x'
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: install hwdata -yq
run: sudo apt-get install hwdata -yq
- name: test
Expand All @@ -39,10 +39,10 @@ jobs:
contents: read
steps:
- name: Set up Go 1.x
uses: actions/setup-go@v2
uses: actions/setup-go@v3
with:
go-version: '1.13'
go-version: '1.18.x'
- name: checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: build
run: make build
10 changes: 5 additions & 5 deletions .github/workflows/release-ubi.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,25 +15,25 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v4
with:
images: mellanox/k8s-rdma-shared-dev-plugin-ubi

- name: Build and push UBI Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v4
with:
context: .
push: true
file: Dockerfile.ubi
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
labels: ${{ steps.meta.outputs.labels }}
8 changes: 4 additions & 4 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,22 +15,22 @@ jobs:
runs-on: ubuntu-latest
steps:
- name: Check out the repo
uses: actions/checkout@v2
uses: actions/checkout@v3

- name: Log in to Docker Hub
uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@98669ae865ea3cffbcbaa878cf57c20bbf1c6c38
uses: docker/metadata-action@v4
with:
images: mellanox/k8s-rdma-shared-dev-plugin

- name: Build and push Docker image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
uses: docker/build-push-action@v4
with:
context: .
push: true
Expand Down
11 changes: 3 additions & 8 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,11 @@ linters-settings:
min-complexity: 30
goimports:
local-prefixes: github.com/Mellanox/k8s-rdma-shared-dev-plugin
golint:
min-confidence: 0
gomnd:
settings:
mnd:
# don't include the "operation" and "assign"
checks: argument,case,condition,return
checks: [argument,case,condition,return]
govet:
check-shadowing: true
settings:
Expand All @@ -55,19 +53,18 @@ linters:
disable-all: true
enable:
- bodyclose
- deadcode
- depguard
- dogsled
- dupl
- errcheck
- exportloopref
- funlen
- gochecknoinits
- goconst
- gocritic
- gocognit
- gofmt
- goimports
- golint
- gomnd
- goprintffuncname
- gosec
Expand All @@ -78,16 +75,14 @@ linters:
- misspell
- nakedret
- prealloc
- revive
- rowserrcheck
- scopelint
- staticcheck
- structcheck
- stylecheck
- typecheck
- unconvert
- unparam
- unused
- varcheck
- whitespace

issues:
Expand Down
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ GOLANGCI_LINT = $(GOBIN)/golangci-lint
# golangci-lint version should be updated periodically
# we keep it fixed to avoid it from unexpectedly failing on the project
# in case of a version bump
GOLANGCI_LINT_VER = v1.23.8
GOLANGCI_LINT_VER = v1.51.2
TIMEOUT = 15
Q = $(if $(filter 1,$V),,@)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ require (
github.com/pkg/errors v0.8.0
github.com/stretchr/testify v1.4.0
github.com/vishvananda/netlink v1.1.0
golang.org/x/net v0.0.0-20201021035429-f5854403a974
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4
google.golang.org/grpc v1.26.0
k8s.io/kubelet v0.17.2
)
Expand Down
6 changes: 5 additions & 1 deletion go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,9 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20191004110552-13f9640d40b9/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
golang.org/x/net v0.0.0-20201021035429-f5854403a974 h1:IX6qOQeG5uLjB/hjjwjedwfjND0hgjPMMyO1RoIXQNI=
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4 h1:4nGaVu0QrbjT/AK2PRLuQfQuh6DJve+pELhqTdAj3x0=
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U=
golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
Expand All @@ -148,6 +149,9 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w
golang.org/x/sys v0.0.0-20190606203320-7fc4e5ec1444/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk=
Expand Down
4 changes: 2 additions & 2 deletions pkg/resources/resources_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ package resources
import (
"encoding/json"
"fmt"
"io/ioutil"
"log"
"os"
"regexp"
"strconv"
"time"
Expand Down Expand Up @@ -74,7 +74,7 @@ func NewResourceManager() types.ResourceManager {
// ReadConfig to read configs
func (rm *resourceManager) ReadConfig() error {
log.Println("Reading", rm.configFile)
raw, err := ioutil.ReadFile(rm.configFile)
raw, err := os.ReadFile(rm.configFile)
if err != nil {
return err
}
Expand Down
12 changes: 7 additions & 5 deletions pkg/utils/testing.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ type FakeFilesystem struct {
}

// Use function creates entire files structure and returns a function to tear it down. Example usage: defer fs.Use()()
//
//nolint:gomnd
func (fs *FakeFilesystem) Use() func() {
// create the new fake fs root dir in /tmp/sriov...
tmpDir, err := ioutil.TempDir("", "k8s-rdma-shared-dev-plugin-")
Expand All @@ -25,13 +27,13 @@ func (fs *FakeFilesystem) Use() func() {
fs.RootDir = tmpDir

for _, dir := range fs.Dirs {
osErr := os.MkdirAll(path.Join(fs.RootDir, dir), 0755)
osErr := os.MkdirAll(path.Join(fs.RootDir, dir), 0700)
if osErr != nil {
panic(fmt.Errorf("error creating fake directory: %s", osErr.Error()))
}
}
for filename, body := range fs.Files {
ioErr := ioutil.WriteFile(path.Join(fs.RootDir, filename), body, 0644)
ioErr := os.WriteFile(path.Join(fs.RootDir, filename), body, 0600)
if ioErr != nil {
panic(fmt.Errorf("error creating fake file: %s", ioErr.Error()))
}
Expand All @@ -42,19 +44,19 @@ func (fs *FakeFilesystem) Use() func() {
panic(fmt.Errorf("error creating fake symlink: %s", osErr.Error()))
}
}
err = os.MkdirAll(path.Join(fs.RootDir, "usr/share/hwdata"), 0755)
err = os.MkdirAll(path.Join(fs.RootDir, "usr/share/hwdata"), 0700)
if err != nil {
panic(fmt.Errorf("error creating fake directory: %s", err.Error()))
}

// TODO: Remove writing pci.ids file once ghw is mocked
// This is to fix the CI failure where ghw lib fails to
// unzip pci.ids file downloaded from internet.
pciData, err := ioutil.ReadFile("/usr/share/hwdata/pci.ids")
pciData, err := os.ReadFile("/usr/share/hwdata/pci.ids")
if err != nil {
panic(fmt.Errorf("error reading file: %s", err.Error()))
}
err = ioutil.WriteFile(path.Join(fs.RootDir, "usr/share/hwdata/pci.ids"), pciData, 0644)
err = os.WriteFile(path.Join(fs.RootDir, "usr/share/hwdata/pci.ids"), pciData, 0600)
if err != nil {
panic(fmt.Errorf("error creating fake file: %s", err.Error()))
}
Expand Down
3 changes: 1 addition & 2 deletions pkg/utils/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package utils

import (
"fmt"
"io/ioutil"
"os"
"path"
"path/filepath"
Expand Down Expand Up @@ -72,7 +71,7 @@ func GetNetNames(pciAddr string) ([]string, error) {
return nil, fmt.Errorf("no net directory under pci device %s: %q", pciAddr, err)
}

fInfos, err := ioutil.ReadDir(netDir)
fInfos, err := os.ReadDir(netDir)
if err != nil {
return nil, fmt.Errorf("failed to read net directory %s: %q", netDir, err)
}
Expand Down