Skip to content
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
31 changes: 3 additions & 28 deletions .github/workflows/go.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,40 +15,15 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
go-version: [1.23.x, 1.24.x]
go-version: [1.24.x, 1.25.x]

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5.3.0
with:
go-version: ${{ matrix.go-version }}

- name: Build
run: go build -v ./...

- name: Test
run: go test -v -vet=all ./...

os-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- "ubuntu-latest"
- "windows-latest"
- "macos-latest"
- "ubuntu-24.04-arm"

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5.3.0
with:
go-version: "1.23"

- name: Test
run: go test -v ./...

7 changes: 6 additions & 1 deletion download/download.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
"strings"

"github.com/ansel1/merry/v2"
"golang.org/x/mod/semver"

"github.com/murfffi/getaduck/internal/sclerr"
)
Expand Down Expand Up @@ -127,7 +128,11 @@ func normalizeSpec(spec Spec) (Spec, error) {
spec.Arch = "universal"
}

if spec.Arch == "arm64" {
if !semver.IsValid(spec.Version) && semver.IsValid("v"+spec.Version) {
spec.Version = "v" + spec.Version
}

if spec.Arch == "arm64" && semver.IsValid(spec.Version) && semver.Compare(spec.Version, "v1.3.0") < 0 {
spec.Arch = "aarch64"
}
return spec, err
Expand Down
29 changes: 25 additions & 4 deletions download/download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,34 @@ import (
)

func TestDo(t *testing.T) {
if !testing.Short() {
if testing.Short() {
t.Skip("skipping test that downloads from Github in short mode.")
}
t.Run("default lib", func(t *testing.T) {
res, err := download.Do(download.DefaultSpec())
require.NoError(t, err)
require.FileExists(t, res.OutputFile)
for _, version := range []string{
"1.2.2",
"v1.3.2",
"v1.4.0",
"latest",
} {
t.Run(version, func(t *testing.T) {
for _, arch := range []string{
"amd64",
"arm64",
} {
t.Run(arch, func(t *testing.T) {
spec := download.DefaultSpec()
spec.Version = version
spec.Arch = arch
spec.Overwrite = true
res, err := download.Do(spec)
require.NoError(t, err)
require.FileExists(t, res.OutputFile)
})

}
})
}
})
// cli is tested e2e in shell/run_test.go . Avoid multiple downloads.
}
3 changes: 2 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
module github.com/murfffi/getaduck

go 1.23.6
go 1.24.7

require (
github.com/ansel1/merry/v2 v2.2.1
Expand All @@ -10,5 +10,6 @@ require (
require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/mod v0.28.0 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
github.com/stretchr/testify v1.8.3 h1:RP3t2pwF7cMEbC1dqtB6poj3niw/9gnV4Cjg5oW5gtY=
github.com/stretchr/testify v1.8.3/go.mod h1:sz/lmYIOXD/1dqDmKjjqLyZ2RngseejIcXlSw2iwfAo=
golang.org/x/mod v0.28.0 h1:gQBtGhjxykdjY9YhZpSlZIsbnaE2+PgjfLWUQTnoZ1U=
golang.org/x/mod v0.28.0/go.mod h1:yfB/L0NOf/kmEbXjzCPOx1iK1fRutOydrCMsqRhEBxI=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
Expand Down
2 changes: 1 addition & 1 deletion shell/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

func TestRunArgs(t *testing.T) {
if !testing.Short() {
if testing.Short() {
t.Skip("skipping test that downloads from Github in short mode.")
}
t.Run("cli", func(t *testing.T) {
Expand Down
Loading