Skip to content

Commit aa3f1e9

Browse files
committed
lint: Add linter to CI, fix existing lint issues
Signed-off-by: Chris Kyrouac <[email protected]>
1 parent c7ee261 commit aa3f1e9

File tree

7 files changed

+32
-14
lines changed

7 files changed

+32
-14
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,11 @@ jobs:
2222
make GOOPTS=-buildvcs=false
2323
export PATH=$PATH:$HOME/go/bin
2424
make integration_tests
25+
- name: lint
26+
run: |
27+
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin v1.58.2
28+
export PATH=$PATH:$HOME/go/bin
29+
make lint
30+
- name: gofmt
31+
run: |
32+
test -z $(gofmt -l .)

Makefile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@ all: out_dir
88
out_dir:
99
mkdir -p $(output_dir)
1010

11+
lint:
12+
golangci-lint --build-tags $(build_tags) run
13+
1114
integration_tests:
1215
ginkgo run -tags $(build_tags) --skip-package test ./...
1316

cmd/run.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,10 @@ func doRun(flags *cobra.Command, args []string) error {
162162
var vmConsoleWg sync.WaitGroup
163163
vmConsoleWg.Add(1)
164164
go func() {
165-
bootcVM.PrintConsole()
165+
err := bootcVM.PrintConsole()
166+
if err != nil {
167+
logrus.Errorf("error printing VM console: %v", err)
168+
}
166169
}()
167170

168171
err = bootcVM.WaitForSSHToBeReady()

pkg/vm/vm.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -92,12 +92,9 @@ type BootcVMCommon struct {
9292
cmd []string
9393
pidFile string
9494
imageID string
95-
imageDigest string
96-
noCredentials bool
9795
hasCloudInit bool
9896
cloudInitDir string
9997
cloudInitArgs string
100-
bootcDisk bootc.BootcDisk
10198
cacheDirLock utils.CacheLock
10299
}
103100

pkg/vm/vm_test.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ func deleteAllVMs() {
132132

133133
var flags libvirt.ConnectListAllDomainsFlags
134134
domains, err := conn.ListAllDomains(flags)
135+
Expect(err).To(Not(HaveOccurred()))
135136
for _, domain := range domains {
136137
err = domain.Destroy()
137138
Expect(err).To(Not(HaveOccurred()))
@@ -140,11 +141,6 @@ func deleteAllVMs() {
140141
}
141142
}
142143

143-
func deleteCache() {
144-
err := os.RemoveAll(testUser.CacheDir())
145-
Expect(err).To(Not(HaveOccurred()))
146-
}
147-
148144
var _ = Describe("VM", func() {
149145
AfterEach(func() {
150146
deleteAllVMs()

test/e2e/e2e_test.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,8 @@ var _ = Describe("E2E", func() {
5757
imagesListOutput, _, err := e2e.RunPodman("images", e2e.BaseImage, "--format", "json")
5858
Expect(err).To(Not(HaveOccurred()))
5959
imagesList := []map[string]interface{}{}
60-
json.Unmarshal([]byte(imagesListOutput), &imagesList)
60+
err = json.Unmarshal([]byte(imagesListOutput), &imagesList)
61+
Expect(err).To(Not(HaveOccurred()))
6162
Expect(imagesList).To(HaveLen(1))
6263
})
6364

@@ -78,7 +79,8 @@ var _ = Describe("E2E", func() {
7879

7980
It("should start an ssh session into the VM", func() {
8081
// Send a command to the VM and check the output
81-
vm.SendCommand("echo 'hello'", "hello")
82+
err := vm.SendCommand("echo 'hello'", "hello")
83+
Expect(err).To(Not(HaveOccurred()))
8284
Expect(vm.StdOut[len(vm.StdOut)-1]).To(ContainSubstring("hello"))
8385
})
8486

@@ -165,7 +167,10 @@ var _ = Describe("E2E", func() {
165167

166168
AfterAll(func() {
167169
vm.StdIn.Close()
168-
e2e.Cleanup()
170+
err := e2e.Cleanup()
171+
if err != nil {
172+
Fail(err.Error())
173+
}
169174
})
170175
})
171176

@@ -304,7 +309,10 @@ var _ = Describe("E2E", func() {
304309
activeVM.StdIn.Close()
305310
inactiveVM.StdIn.Close()
306311
stoppedVM.StdIn.Close()
307-
e2e.Cleanup()
312+
err := e2e.Cleanup()
313+
if err != nil {
314+
Fail(err.Error())
315+
}
308316
})
309317
})
310318
})

test/e2e/test_vm.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,10 @@ func (w *TestVM) WaitForBoot() (err error) {
5050

5151
// SendCommand sends a command to the VM's stdin and waits for the output
5252
func (w *TestVM) SendCommand(cmd string, output string) (err error) {
53-
w.StdIn.Write([]byte(cmd + "\n"))
53+
_, err = w.StdIn.Write([]byte(cmd + "\n"))
54+
if err != nil {
55+
return fmt.Errorf("unable to write to VM stdin: %w", err)
56+
}
5457

5558
timeout := 2 * time.Minute
5659
interval := 1 * time.Second

0 commit comments

Comments
 (0)