Skip to content

Commit

Permalink
ci: bump golangci-lint to v1.62.2 (#194)
Browse files Browse the repository at this point in the history
Signed-off-by: Austin Vazquez <[email protected]>
  • Loading branch information
austinvazquez authored Dec 26, 2024
1 parent 0cb4534 commit c08fc48
Show file tree
Hide file tree
Showing 27 changed files with 9 additions and 55 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@ jobs:
# Pin the version in case all the builds start to fail at the same time.
# There may not be an automatic way (e.g., dependabot) to update a specific parameter of a Github Action,
# so we will just update it manually whenever it makes sense (e.g., a feature that we want is added).
version: v1.51.2
version: v1.62.2
args: --fix=false
4 changes: 2 additions & 2 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ linters-settings:
goheader:
template-path: copyright_header
goimports:
local-prefixes: github.com/runfinch/tests
local-prefixes: github.com/runfinch/common-tests
gosec:
config:
G306: "0o644"
Expand All @@ -23,9 +23,9 @@ linters-settings:
checks: ["all", "-ST1003"]
linters:
enable:
- copyloopvar
- errname
- errorlint
- exportloopref
- forcetypeassert
- gocritic
- godot
Expand Down
1 change: 1 addition & 0 deletions command/remove.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package command

import (
"github.com/onsi/ginkgo/v2"

"github.com/runfinch/common-tests/option"
)

Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/runfinch/common-tests

go 1.20
go 1.22

require (
github.com/onsi/ginkgo/v2 v2.20.0
Expand Down
3 changes: 0 additions & 3 deletions tests/build.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func Build(o *option.Option) {
})

for _, tag := range []string{"-t", "--tag"} {
tag := tag
ginkgo.It(fmt.Sprintf("build basic alpine image with %s option", tag), func() {
command.Run(o, "build", tag, testImageName, buildContext)
imageShouldExist(o, testImageName)
Expand All @@ -57,7 +56,6 @@ func Build(o *option.Option) {
})

for _, file := range []string{"-f", "--file"} {
file := file
ginkgo.It(fmt.Sprintf("build an image with %s option", file), func() {
stdErr := command.Stderr(o, "build", "--no-cache", file, dockerFilePath, buildContext)
gomega.Expect(stdErr).Should(gomega.ContainSubstring("built from AnotherDockerfile"))
Expand Down Expand Up @@ -170,7 +168,6 @@ func Build(o *option.Option) {
}

for _, test := range negativeTests {
test := test
ginkgo.It("should not successfully build a container", func() {
dockerFilePath := filepath.Join(buildContext, test.fileName)
ffs.WriteFile(dockerFilePath, test.instructions)
Expand Down
2 changes: 1 addition & 1 deletion tests/compose_down.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"github.com/runfinch/common-tests/command"
"github.com/runfinch/common-tests/ffs"
"github.com/runfinch/common-tests/option"
Expand Down Expand Up @@ -46,7 +47,6 @@ func ComposeDown(o *option.Option) {
})

for _, volumes := range []string{"-v", "--volumes"} {
volumes := volumes
ginkgo.It(fmt.Sprintf("should stop compose services and delete volumes by specifying %s flag", volumes), func() {
volumes := volumes
output := command.StdoutStr(o, "compose", "down", volumes, "--file", composeFilePath)
Expand Down
2 changes: 0 additions & 2 deletions tests/compose_kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,9 +44,7 @@ func ComposeKill(o *option.Option) {
// With PID=1, `sleep infinity` will only exit when receiving SIGKILL. Default signal for kill is SIGKILL.
// https://stackoverflow.com/questions/45148381/why-cant-i-ctrl-c-a-sleep-infinity-in-docker-when-it-runs-as-pid-1
for _, signal := range []string{"-s", "--signal"} {
signal := signal
for _, term := range []string{"SIGTERM", "TERM"} {
term := term
ginkgo.It(fmt.Sprintf("should not kill running containers with %s %s", signal, term), func() {
command.Run(o, "compose", "kill", signal, term, "--file", composeFilePath)
containerShouldBeRunning(o, containerNames...)
Expand Down
1 change: 0 additions & 1 deletion tests/compose_logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ func ComposeLogs(o *option.Option) {
})

for _, tFlag := range []string{"-t", "--timestamps"} {
tFlag := tFlag
ginkgo.It(fmt.Sprintf("should show the logs with timestamp with no prefixes and no color [flag %s]", tFlag), func() {
// Log format: YYYY-MM-DDThh:mm:ss.000000000Z LOG MSG
timestampMatcher := gomega.MatchRegexp("^[0-9]{1,4}-[0-9]{1,2}-[0-9]{1,2}T[0-9]{1,2}:[0-9]{1,2}:[0-9]{1,2}.*")
Expand Down
1 change: 0 additions & 1 deletion tests/cp.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ func Cp(o *option.Option) {
})

for _, link := range []string{"-L", "--follow-link"} {
link := link
ginkgo.It(fmt.Sprintf("with %s flag, should be able to copy file from host to container and follow symbolic link",
link), func() {
path := ffs.CreateTempFile(filename, content)
Expand Down
6 changes: 0 additions & 6 deletions tests/exec.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ func Exec(o *option.Option) {
})

for _, interactive := range []string{"-i", "--interactive", "-i=true", "--interactive=true"} {
interactive := interactive
ginkgo.It(fmt.Sprintf("should output string by piping if %s flag keeps STDIN open", interactive), func() {
want := []byte("hello")
got := command.New(o, "exec", interactive, testContainerName, "cat").
Expand All @@ -49,7 +48,6 @@ func Exec(o *option.Option) {
}

for _, detach := range []string{"-d", "--detach", "-d=true", "--detach=true"} {
detach := detach
ginkgo.It(fmt.Sprintf("should execute command in detached mode with %s flag", detach), func() {
command.Run(o, "exec", detach, testContainerName, "nc", "-l")
processes := command.StdoutStr(o, "exec", testContainerName, "ps", "aux")
Expand All @@ -58,7 +56,6 @@ func Exec(o *option.Option) {
}

for _, workDir := range []string{"-w", "--workdir"} {
workDir := workDir
ginkgo.It(fmt.Sprintf("should execute command under directory specified by %s flag", workDir), func() {
dir := "/tmp"
output := command.StdoutStr(o, "exec", workDir, dir, testContainerName, "pwd")
Expand All @@ -67,7 +64,6 @@ func Exec(o *option.Option) {
}

for _, env := range []string{"-e", "--env"} {
env := env
ginkgo.It(fmt.Sprintf("should set the environment variable with %s flag", env), func() {
const envPair = "ENV=1"
lines := command.StdoutAsLines(o, "exec", env, envPair, testContainerName, "env")
Expand All @@ -85,7 +81,6 @@ func Exec(o *option.Option) {
})

for _, privilegedFlag := range []string{"--privileged", "--privileged=true"} {
privilegedFlag := privilegedFlag
ginkgo.It(fmt.Sprintf("should execute command in privileged mode with %s flag", privilegedFlag), func() {
command.RunWithoutSuccessfulExit(o, "exec", testContainerName, "ip", "link", "add", "dummy1", "type", "dummy")
command.Run(o, "exec", privilegedFlag, testContainerName, "ip", "link", "add", "dummy1", "type", "dummy")
Expand All @@ -95,7 +90,6 @@ func Exec(o *option.Option) {
}

for _, user := range []string{"-u", "--user"} {
user := user
ginkgo.It(fmt.Sprintf("should output user id according to user name specified by %s flag", user), func() {
testCases := map[string][]string{
"1000": {"uid=1000 gid=0(root)", "uid=1000 gid=0(root) groups=0(root)"},
Expand Down
1 change: 0 additions & 1 deletion tests/image_history.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func ImageHistory(o *option.Option) {
})

for _, quiet := range []string{"-q", "--quiet"} {
quiet := quiet
ginkgo.It(fmt.Sprintf("should only display snapshot ID with %s flag", quiet), func() {
ids := removeMissingID(command.StdoutAsLines(o, "image", "history", quiet, localImages[defaultImage]))
gomega.Expect(ids).Should(gomega.HaveEach(gomega.MatchRegexp(sha256RegexFull)))
Expand Down
1 change: 0 additions & 1 deletion tests/image_prune.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func ImagePrune(o *option.Option) {
})

for _, force := range []string{"-f", "--force"} {
force := force
ginkgo.It(fmt.Sprintf("with %s flag, should remove unused images without prompting a confirmation", force), func() {
imageShouldExist(o, localImages[defaultImage])
command.Run(o, "image", "prune", "-a", "-f")
Expand Down
2 changes: 0 additions & 2 deletions tests/kill.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,9 @@ func Kill(o *option.Option) {
})

for _, signal := range []string{"-s", "--signal"} {
signal := signal
// With PID=1, `sleep infinity` will only exit when receiving SIGKILL. Default signal for kill is SIGKILL.
// https://stackoverflow.com/questions/45148381/why-cant-i-ctrl-c-a-sleep-infinity-in-docker-when-it-runs-as-pid-1
for _, term := range []string{"SIGTERM", "TERM"} {
term := term
ginkgo.It(fmt.Sprintf("should not kill the running container with %s %s", signal, term), func() {
containerShouldBeRunning(o, testContainerName)
command.Run(o, "kill", signal, term, testContainerName)
Expand Down
1 change: 0 additions & 1 deletion tests/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func Load(o *option.Option) {
// TODO: add test for input redirection sign
// REF issue: https://github.com/lima-vm/lima/issues/1078
for _, inputOption := range []string{"-i", "--input"} {
inputOption := inputOption
ginkgo.It(fmt.Sprintf("should load an image with %s option", inputOption), func() {
command.Run(o, "save", "-o", tarFilePath, localImages[defaultImage])

Expand Down
1 change: 0 additions & 1 deletion tests/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ func Login(o *option.Option) {
})
for _, username := range []string{"-u", "--username"} {
for _, password := range []string{"-p", "--password"} {
username, password := username, password
ginkgo.It("should push an image after successfully logging in the registry with a correct credential", func() {
command.Run(o, "login", registry, username, testUser, password, testPassword)
ginkgo.DeferCleanup(func() {
Expand Down
3 changes: 0 additions & 3 deletions tests/logs.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,6 @@ func Logs(o *option.Option) {
})

for _, timestamps := range []string{"-t", "--timestamps"} {
timestamps := timestamps
ginkgo.It(fmt.Sprintf("should include timestamp with %s flag", timestamps), func() {
output := command.StdoutStr(o, "logs", timestamps, testContainerName)
// `logs --timestamps` command will add an RFC3339Nano timestamp,
Expand Down Expand Up @@ -76,7 +75,6 @@ func Logs(o *option.Option) {
})

for _, tail := range []string{"-n", "--tail"} {
tail := tail
ginkgo.It(fmt.Sprintf("should show number of lines from end of the logs with %s flag", tail), func() {
expectedOutput := fmt.Sprintf("%s\n%s", foo, bar)
output := command.StdoutStr(o, "logs", tail, "1", testContainerName)
Expand All @@ -93,7 +91,6 @@ func Logs(o *option.Option) {
})

for _, follow := range []string{"-f", "--follow"} {
follow := follow
ginkgo.It(fmt.Sprintf("should follow log output with %s flag", follow), func() {
const newLog = "hello"
session := command.RunWithoutWait(o, "logs", follow, testContainerName)
Expand Down
3 changes: 0 additions & 3 deletions tests/network_create.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,7 @@ func NetworkCreate(o *option.Option) {
})

for _, driverFlag := range []string{"-d", "--driver"} {
driverFlag := driverFlag
for _, driver := range []string{"macvlan", "ipvlan"} {
driver := driver
ginkgo.It(fmt.Sprintf("should create %s network with %s flag", driver, driverFlag), func() {
command.Run(o, "network", "create", driverFlag, driver, testNetwork)
netType := command.StdoutStr(o, "network", "inspect", testNetwork, "--mode=native",
Expand All @@ -91,7 +89,6 @@ func NetworkCreate(o *option.Option) {
}

for _, opt := range []string{"-o", "--opt"} {
opt := opt
ginkgo.It(fmt.Sprintf("should set the containers network MTU with %s flag", opt), func() {
command.Run(o, "network", "create", opt, "com.docker.network.driver.mtu=500", testNetwork)
mtu := command.StdoutStr(o, "network", "inspect", testNetwork, "--mode=native", "--format", "{{(index .CNI.plugins 0).mtu}}")
Expand Down
1 change: 0 additions & 1 deletion tests/network_ls.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ func NetworkLs(o *option.Option) {
})

for _, quiet := range []string{"-q", "--quiet"} {
quiet := quiet
ginkgo.It(fmt.Sprintf("should only display network id with %s flag", quiet), func() {
output := command.StdoutStr(o, "network", "ls", quiet)
gomega.Expect(output).ShouldNot(gomega.BeEmpty())
Expand Down
7 changes: 1 addition & 6 deletions tests/ps.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import (

"github.com/onsi/ginkgo/v2"
"github.com/onsi/gomega"

"github.com/runfinch/common-tests/command"
"github.com/runfinch/common-tests/option"
)
Expand Down Expand Up @@ -41,7 +42,6 @@ func Ps(o *option.Option) {
})

for _, flag := range []string{"-a", "--all"} {
flag := flag
ginkgo.It(fmt.Sprintf("should list all containers [%s flag]", flag), func() {
psOutput := command.StdoutAsLines(o, "ps", "--format", "{{.Names}}", flag)
gomega.Expect(psOutput).Should(gomega.ContainElements(containerNames))
Expand Down Expand Up @@ -70,7 +70,6 @@ func Ps(o *option.Option) {
})

for _, flag := range []string{"-q", "--quiet"} {
flag := flag
ginkgo.It(fmt.Sprintf("should list truncated container IDs [%s flag]", flag), func() {
psOutput := command.StdoutAsLines(o, "ps", flag)
gomega.Expect(psOutput).ShouldNot(gomega.BeEmpty())
Expand All @@ -85,15 +84,13 @@ func Ps(o *option.Option) {
})

for _, flag := range []string{"-s", "--size"} {
flag := flag
ginkgo.It(fmt.Sprintf("should list container size [%s flag]", flag), func() {
psOutput := command.StdoutStr(o, "ps", "--format", "{{.Size}}", flag)
gomega.Expect(psOutput).ShouldNot(gomega.BeEmpty())
})
}

for _, flag := range []string{"-n", "--last"} {
flag := flag
ginkgo.It(fmt.Sprintf("should list last 1 containers [%s flag]", flag), func() {
psOutput := command.StdoutAsLines(o, "ps", "--format", "{{.Names}}", flag, "1")
gomega.Expect(psOutput).ShouldNot(gomega.ContainElement(containerNames[0]))
Expand All @@ -102,7 +99,6 @@ func Ps(o *option.Option) {
}

for _, flag := range []string{"-l", "--latest"} {
flag := flag
ginkgo.It(fmt.Sprintf("should list last 1 containers [%s flag]", flag), func() {
psOutput := command.StdoutAsLines(o, "ps", "--format", "{{.Names}}", flag)
gomega.Expect(psOutput).ShouldNot(gomega.ContainElement(containerNames[0]))
Expand Down Expand Up @@ -208,7 +204,6 @@ func Ps(o *option.Option) {
}

for _, test := range filterTests {
test := test
ginkgo.It(fmt.Sprintf(" should list container with filter %s", test.filter), func() {
output := command.StdoutAsLines(o, "ps", "-a", "--format", "{{.Names}}", "--filter", test.filter)
gomega.Expect(output).Should(gomega.ContainElements(test.expectedOutput))
Expand Down
2 changes: 0 additions & 2 deletions tests/rm.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ func Rm(o *option.Option) {
})

for _, force := range []string{"-f", "--force"} {
force := force
ginkgo.It(fmt.Sprintf("should be able to remove the container with %s flag", force), func() {
command.Run(o, "rm", force, testContainerName)
err := containerShouldNotExist(o, testContainerName)
Expand All @@ -54,7 +53,6 @@ func Rm(o *option.Option) {

ginkgo.Context("when a volume is used by the container", func() {
for _, volumes := range []string{"-v", "--volumes"} {
volumes := volumes
ginkgo.It(fmt.Sprintf("with %s flag, should remove the container and the anonymous volume used by the container", volumes),
func() {
command.Run(o, "run", "-v", "/usr/share", "--name", testContainerName, localImages[defaultImage])
Expand Down
1 change: 0 additions & 1 deletion tests/rmi.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ func Rmi(o *option.Option) {
})

for _, force := range []string{"-f", "--force"} {
force := force
ginkgo.It(fmt.Sprintf("should be able to remove the image with %s flag", force), func() {
command.Run(o, "rmi", force, localImages[defaultImage])
imageShouldNotExist(o, localImages[defaultImage])
Expand Down
Loading

0 comments on commit c08fc48

Please sign in to comment.