Repository: goreleaser/goreleaser
Pull request #2126 (2021-03-19 13:25:45)

fix: properly translate mips arch
closes https://github.com/goreleaser/goreleaser/issues/2125

vercel[bot]: This pull request is being automatically deployed with Vercel ([learn more](https://vercel.link/github-learn-more)).  
To see the status of your deployment, click below or on the icon next to each commit.

🔍 Inspect: [https://vercel.com/goreleaser/goreleaser/Fqov3NgZ7myZQ7BBRSYNYkuSsBRk](https://vercel.com/goreleaser/goreleaser/Fqov3NgZ7myZQ7BBRSYNYkuSsBRk)  
✅ Preview: [https://goreleaser-git-mipsnfpm-goreleaser.vercel.app](https://goreleaser-git-mipsnfpm-goreleaser.vercel.app)


codecov[bot]: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2126?src=pr&el=h1) Report
> Merging [#2126](https://codecov.io/gh/goreleaser/goreleaser/pull/2126?src=pr&el=desc) (987f46c) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/0e689b414a133d9835e2ef9fa9d5b5f34e1105fd?el=desc) (0e689b4) will **increase** coverage by `0.05%`.
> The diff coverage is `100.00%`.

[![Impacted file tree graph](https://codecov.io/gh/goreleaser/goreleaser/pull/2126/graphs/tree.svg?width=650&height=150&src=pr&token=3bJvv6b7hN)](https://codecov.io/gh/goreleaser/goreleaser/pull/2126?src=pr&el=tree)

```diff
@@            Coverage Diff             @@
##           master    #2126      +/-   ##
==========================================
+ Coverage   82.71%   82.77%   +0.05%     
==========================================
  Files          74       74              
  Lines        4010     4012       +2     
==========================================
+ Hits         3317     3321       +4     
+ Misses        565      564       -1     
+ Partials      128      127       -1     
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/2126?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [internal/linux/arch.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2126/diff?src=pr&el=tree#diff-aW50ZXJuYWwvbGludXgvYXJjaC5nbw==) | `100.00% <100.00%> (ø)` | |
| [internal/pipe/docker/docker.go](https://codecov.io/gh/goreleaser/goreleaser/pull/2126/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9kb2NrZXIvZG9ja2VyLmdv) | `94.24% <0.00%> (+1.33%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2126?src=pr&el=continue).
> **Legend** - [Click here to learn more](https://docs.codecov.io/docs/codecov-delta)
> `Δ = absolute <relative> (impact)`, `ø = not affected`, `? = missing data`
> Powered by [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/2126?src=pr&el=footer). Last update [0e689b4...987f46c](https://codecov.io/gh/goreleaser/goreleaser/pull/2126?src=pr&el=lastupdated). Read the [comment docs](https://docs.codecov.io/docs/pull-request-comments).


Patch:
diff --git a/internal/linux/arch.go b/internal/linux/arch.go
index 54302233..b3304aad 100644
--- a/internal/linux/arch.go
+++ b/internal/linux/arch.go
@@ -6,7 +6,10 @@ import "strings"
 // Arch converts a goarch to a linux-compatible arch.
 func Arch(key string) string {
 	// XXX: list of all linux arches: `go tool dist list | grep linux`
-	var arch = strings.TrimPrefix(key, "linux")
+	arch := strings.TrimPrefix(key, "linux")
+	for _, suffix := range []string{"hardfloat", "softfloat"} {
+		arch = strings.TrimSuffix(arch, suffix)
+	}
 	switch arch {
 	case "386":
 		return "i386"
@@ -18,7 +21,10 @@ func Arch(key string) string {
 		return "armhf"
 	case "arm7": // GOARCH + GOARM
 		return "armhf"
-	default:
-		return arch
+	case "mips64le":
+		return "mips64el"
+	case "mipsle":
+		return "mipsel"
 	}
+	return arch
 }


Test patch:
diff --git a/internal/linux/arch_test.go b/internal/linux/arch_test.go
index 86873b81..591ca757 100644
--- a/internal/linux/arch_test.go
+++ b/internal/linux/arch_test.go
@@ -9,15 +9,19 @@ import (
 
 func TestArch(t *testing.T) {
 	for from, to := range map[string]string{
-		"linuxamd64":   "amd64",
-		"linux386":     "i386",
-		"linuxarm64":   "arm64",
-		"linuxarm5":    "armel",
-		"linuxarm6":    "armhf",
-		"linuxarm7":    "armhf",
-		"linuxppc64":   "ppc64",
-		"linuxppc64le": "ppc64le",
-		"linuxwhat":    "what",
+		"linuxamd64":             "amd64",
+		"linux386":               "i386",
+		"linuxarm64":             "arm64",
+		"linuxarm5":              "armel",
+		"linuxarm6":              "armhf",
+		"linuxarm7":              "armhf",
+		"linuxppc64":             "ppc64",
+		"linuxppc64le":           "ppc64le",
+		"linuxwhat":              "what",
+		"linuxmips64lesoftfloat": "mips64el",
+		"linuxmipslehardfloat":   "mipsel",
+		"linuxmipssoftfloat":     "mips",
+		"linuxmips64hardfloat":   "mips64",
 	} {
 		t.Run(fmt.Sprintf("%s to %s", from, to), func(t *testing.T) {
 			require.Equal(t, to, Arch(from))