From 9d6e7970b66bff05e0342f06ce0db5beb60f7949 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Wed, 21 Jul 2021 11:38:07 -0500 Subject: [PATCH 1/3] go: support go modules Add go.mod file to support Golang 1.16.x Signed-off-by: Julio Montes --- go.mod | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 go.mod diff --git a/go.mod b/go.mod new file mode 100644 index 0000000000..377ac043fd --- /dev/null +++ b/go.mod @@ -0,0 +1,3 @@ +module github.com/kata-containers/govmm + +go 1.16 From 61b6378749e333238d77bc85926ddca5c13ab90f Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Wed, 21 Jul 2021 11:40:11 -0500 Subject: [PATCH 2/3] .github/workflows: reimplement github actions CI * Remove golang 1.13 and 1.14, add golang 1.16 * gometalinter has been deprecated, use golangci-lint instead Signed-off-by: Julio Montes --- .github/workflows/main.yml | 45 ++++++++++++-------------------------- .golangci.yml | 35 +++++++++++++++++++++++++++++ 2 files changed, 49 insertions(+), 31 deletions(-) create mode 100644 .golangci.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 0ced8ae572..912d3d225d 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -4,37 +4,20 @@ jobs: test: strategy: matrix: - go-version: [1.13.x, 1.14.x, 1.15.x] + go-version: [1.15.x, 1.16.x] os: [ubuntu-latest] runs-on: ${{ matrix.os }} - env: - GO111MODULE: off steps: - - name: Install Go - uses: actions/setup-go@v2 - with: - go-version: ${{ matrix.go-version }} - - name: Setup GOPATH - run: | - gopath_org=$(go env GOPATH)/src/github.com/kata-containers/ - mkdir -p ${gopath_org} - ln -s ${PWD} ${gopath_org} - - name: Checkout code - uses: actions/checkout@v2 - - name: Install gometalinter - run: | - go get github.com/alecthomas/gometalinter - $(go env GOPATH)/bin/gometalinter --install - - name: Running gometalinter - run: | - gopath_repo=$(go env GOPATH)/src/github.com/kata-containers/govmm - pushd ${gopath_repo} - $(go env GOPATH)/bin/gometalinter --tests --vendor --disable-all --enable=misspell --enable=vet --enable=ineffassign --enable=gofmt --enable=gocyclo --cyclo-over=15 --enable=golint --enable=errcheck --enable=deadcode --enable=staticcheck -enable=gas ./... - - name: Send coverage - env: - COVERALLS_TOKEN: ${{ secrets.GITHUB_TOKEN }} - run: | - gopath_repo=$(go env GOPATH)/src/github.com/kata-containers/govmm - pushd ${gopath_repo} - go get github.com/mattn/goveralls - $(go env GOPATH)/bin/goveralls -v -service=github + - name: Install Go + uses: actions/setup-go@v2 + with: + go-version: ${{ matrix.go-version }} + - name: Checkout code + uses: actions/checkout@v2 + - name: golangci-lint + uses: golangci/golangci-lint-action@v2 + with: + version: latest + args: -c .golangci.yml -v + - name: go test + run: go test ./... diff --git a/.golangci.yml b/.golangci.yml new file mode 100644 index 0000000000..6b7fcdebe9 --- /dev/null +++ b/.golangci.yml @@ -0,0 +1,35 @@ +# Copyright (c) 2021 Intel Corporation +# +# SPDX-License-Identifier: Apache-2.0 + +run: + concurrency: 4 + deadline: 600s + skip-dirs: + - vendor +# Ignore auto-generated protobuf code. + skip-files: + - ".*\\.pb\\.go$" + +linters: + disable-all: true + enable: + - deadcode + - gocyclo + - gofmt + - gosimple + - govet + - ineffassign + - misspell + - staticcheck + - structcheck + - typecheck + - unconvert + - unused + - varcheck + +linters-settings: + gocyclo: + min_complexity: 15 + unused: + check-exported: true From 335fa81667344214041348224ecabf1cf9b217d6 Mon Sep 17 00:00:00 2001 From: Julio Montes Date: Wed, 21 Jul 2021 15:08:12 -0500 Subject: [PATCH 3/3] qemu: fix golangci-lint errors fix golangci-lint errors Signed-off-by: Julio Montes --- qemu/qemu.go | 6 +++--- qemu/qemu_test.go | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/qemu/qemu.go b/qemu/qemu.go index 7c4563fa49..585eb712b4 100644 --- a/qemu/qemu.go +++ b/qemu/qemu.go @@ -1153,7 +1153,7 @@ func (blkdev BlockDevice) QemuParams(config *Config) []string { } if blkdev.ShareRW { - deviceParams = append(deviceParams, fmt.Sprintf("share-rw=on")) + deviceParams = append(deviceParams, "share-rw=on") } deviceParams = append(deviceParams, fmt.Sprintf("serial=%s", blkdev.ID)) @@ -1905,7 +1905,7 @@ func (vsock VSOCKDevice) QemuParams(config *Config) []string { var qemuParams []string driver := vsock.deviceName(config) - deviceParams = append(deviceParams, string(driver)) + deviceParams = append(deviceParams, driver) if s := vsock.Transport.disableModern(config, vsock.DisableModern); s != "" { deviceParams = append(deviceParams, s) } @@ -2080,7 +2080,7 @@ func (b BalloonDevice) QemuParams(config *Config) []string { deviceParams = append(deviceParams, "deflate-on-oom=off") } if s := b.Transport.disableModern(config, b.DisableModern); s != "" { - deviceParams = append(deviceParams, string(s)) + deviceParams = append(deviceParams, s) } qemuParams = append(qemuParams, "-device") qemuParams = append(qemuParams, strings.Join(deviceParams, ",")) diff --git a/qemu/qemu_test.go b/qemu/qemu_test.go index 34a9abb8f0..96a111b09b 100644 --- a/qemu/qemu_test.go +++ b/qemu/qemu_test.go @@ -391,7 +391,7 @@ func TestAppendVirtioRng(t *testing.T) { ROMFile: romfile, } - deviceString += "-" + string(rngDevice.Transport.getName(nil)) + ",rng=rng0" + deviceString += "-" + rngDevice.Transport.getName(nil) + ",rng=rng0" if romfile != "" { deviceString = deviceString + ",romfile=efi-virtio.rom" }