diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 7894cc3c..ca5e25a8 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -22,3 +22,11 @@ jobs: make GOOPTS=-buildvcs=false export PATH=$PATH:$HOME/go/bin make integration_tests + - name: lint + run: | + curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.58.2 + export PATH=$PATH:$HOME/go/bin + make lint + - name: gofmt + run: | + test -z $(gofmt -l .) diff --git a/Makefile b/Makefile index 5162ab12..df455929 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,9 @@ all: out_dir out_dir: mkdir -p $(output_dir) +lint: + golangci-lint --build-tags $(build_tags) run + integration_tests: ginkgo run -tags $(build_tags) --skip-package test ./... diff --git a/cmd/run.go b/cmd/run.go index fbc83740..6268e843 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -162,7 +162,10 @@ func doRun(flags *cobra.Command, args []string) error { var vmConsoleWg sync.WaitGroup vmConsoleWg.Add(1) go func() { - bootcVM.PrintConsole() + err := bootcVM.PrintConsole() + if err != nil { + logrus.Errorf("error printing VM console: %v", err) + } }() err = bootcVM.WaitForSSHToBeReady() diff --git a/pkg/vm/vm.go b/pkg/vm/vm.go index b9529681..c96eb5b1 100644 --- a/pkg/vm/vm.go +++ b/pkg/vm/vm.go @@ -92,12 +92,9 @@ type BootcVMCommon struct { cmd []string pidFile string imageID string - imageDigest string - noCredentials bool hasCloudInit bool cloudInitDir string cloudInitArgs string - bootcDisk bootc.BootcDisk cacheDirLock utils.CacheLock } diff --git a/pkg/vm/vm_test.go b/pkg/vm/vm_test.go index 08484b5f..a00d52b7 100644 --- a/pkg/vm/vm_test.go +++ b/pkg/vm/vm_test.go @@ -132,6 +132,7 @@ func deleteAllVMs() { var flags libvirt.ConnectListAllDomainsFlags domains, err := conn.ListAllDomains(flags) + Expect(err).To(Not(HaveOccurred())) for _, domain := range domains { err = domain.Destroy() Expect(err).To(Not(HaveOccurred())) @@ -140,11 +141,6 @@ func deleteAllVMs() { } } -func deleteCache() { - err := os.RemoveAll(testUser.CacheDir()) - Expect(err).To(Not(HaveOccurred())) -} - var _ = Describe("VM", func() { AfterEach(func() { deleteAllVMs() diff --git a/test/e2e/e2e_test.go b/test/e2e/e2e_test.go index 7cbc84bf..04c52797 100644 --- a/test/e2e/e2e_test.go +++ b/test/e2e/e2e_test.go @@ -57,7 +57,8 @@ var _ = Describe("E2E", func() { imagesListOutput, _, err := e2e.RunPodman("images", e2e.BaseImage, "--format", "json") Expect(err).To(Not(HaveOccurred())) imagesList := []map[string]interface{}{} - json.Unmarshal([]byte(imagesListOutput), &imagesList) + err = json.Unmarshal([]byte(imagesListOutput), &imagesList) + Expect(err).To(Not(HaveOccurred())) Expect(imagesList).To(HaveLen(1)) }) @@ -78,7 +79,8 @@ var _ = Describe("E2E", func() { It("should start an ssh session into the VM", func() { // Send a command to the VM and check the output - vm.SendCommand("echo 'hello'", "hello") + err := vm.SendCommand("echo 'hello'", "hello") + Expect(err).To(Not(HaveOccurred())) Expect(vm.StdOut[len(vm.StdOut)-1]).To(ContainSubstring("hello")) }) @@ -165,7 +167,10 @@ var _ = Describe("E2E", func() { AfterAll(func() { vm.StdIn.Close() - e2e.Cleanup() + err := e2e.Cleanup() + if err != nil { + Fail(err.Error()) + } }) }) @@ -304,7 +309,10 @@ var _ = Describe("E2E", func() { activeVM.StdIn.Close() inactiveVM.StdIn.Close() stoppedVM.StdIn.Close() - e2e.Cleanup() + err := e2e.Cleanup() + if err != nil { + Fail(err.Error()) + } }) }) }) diff --git a/test/e2e/test_vm.go b/test/e2e/test_vm.go index 1fa7116d..6a5252dc 100644 --- a/test/e2e/test_vm.go +++ b/test/e2e/test_vm.go @@ -50,7 +50,10 @@ func (w *TestVM) WaitForBoot() (err error) { // SendCommand sends a command to the VM's stdin and waits for the output func (w *TestVM) SendCommand(cmd string, output string) (err error) { - w.StdIn.Write([]byte(cmd + "\n")) + _, err = w.StdIn.Write([]byte(cmd + "\n")) + if err != nil { + return fmt.Errorf("unable to write to VM stdin: %w", err) + } timeout := 2 * time.Minute interval := 1 * time.Second