Repository: goreleaser/goreleaser
Pull request #1030 (2019-05-29 02:05:57)

fix: nfpm id
missed it on #1025

caarlos0: also refs https://github.com/goreleaser/goreleaser/issues/1029
codecov-io: # [Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1030?src=pr&el=h1) Report
> Merging [#1030](https://codecov.io/gh/goreleaser/goreleaser/pull/1030?src=pr&el=desc) into [master](https://codecov.io/gh/goreleaser/goreleaser/commit/86c5b93260f751e718f2de987adab244105446b1?src=pr&el=desc) will **increase** coverage by `<.01%`.
> The diff coverage is `100%`.

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

```diff
@@            Coverage Diff             @@
##           master    #1030      +/-   ##
==========================================
+ Coverage   88.57%   88.57%   +<.01%     
==========================================
  Files          53       53              
  Lines        2616     2618       +2     
==========================================
+ Hits         2317     2319       +2     
  Misses        236      236              
  Partials       63       63
```


| [Impacted Files](https://codecov.io/gh/goreleaser/goreleaser/pull/1030?src=pr&el=tree) | Coverage Δ | |
|---|---|---|
| [pkg/config/config.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1030/diff?src=pr&el=tree#diff-cGtnL2NvbmZpZy9jb25maWcuZ28=) | `100% <ø> (ø)` | :arrow_up: |
| [internal/pipe/snapcraft/snapcraft.go](https://codecov.io/gh/goreleaser/goreleaser/pull/1030/diff?src=pr&el=tree#diff-aW50ZXJuYWwvcGlwZS9zbmFwY3JhZnQvc25hcGNyYWZ0Lmdv) | `89.72% <100%> (+0.14%)` | :arrow_up: |

------

[Continue to review full report at Codecov](https://codecov.io/gh/goreleaser/goreleaser/pull/1030?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/1030?src=pr&el=footer). Last update [86c5b93...19f202b](https://codecov.io/gh/goreleaser/goreleaser/pull/1030?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 363f3d10..62ce399e 100644
--- a/internal/linux/arch.go
+++ b/internal/linux/arch.go
@@ -13,8 +13,10 @@ func Arch(key string) string {
 		return "i386"
 	case "amd64":
 		return "amd64"
-	case "arm6": // GOARCH + GOARM
+	case "arm5": // GOARCH + GOARM
 		return "armel"
+	case "arm6": // GOARCH + GOARM
+		return "armhf"
 	case "arm7": // GOARCH + GOARM
 		return "armhf"
 	}
diff --git a/internal/pipe/snapcraft/snapcraft.go b/internal/pipe/snapcraft/snapcraft.go
index b3cebef5..6e63d0ee 100644
--- a/internal/pipe/snapcraft/snapcraft.go
+++ b/internal/pipe/snapcraft/snapcraft.go
@@ -13,6 +13,7 @@ import (
 	"github.com/apex/log"
 	"github.com/goreleaser/goreleaser/internal/artifact"
 	"github.com/goreleaser/goreleaser/internal/deprecate"
+	"github.com/goreleaser/goreleaser/internal/ids"
 	"github.com/goreleaser/goreleaser/internal/linux"
 	"github.com/goreleaser/goreleaser/internal/pipe"
 	"github.com/goreleaser/goreleaser/internal/semerrgroup"
@@ -71,6 +72,7 @@ func (Pipe) Default(ctx *context.Context) error {
 			deprecate.Notice("snapcraft")
 		}
 	}
+	var ids = ids.New()
 	for i := range ctx.Config.Snapcrafts {
 		var snap = &ctx.Config.Snapcrafts[i]
 		if snap.NameTemplate == "" {
@@ -81,8 +83,9 @@ func (Pipe) Default(ctx *context.Context) error {
 				snap.Builds = append(snap.Builds, b.ID)
 			}
 		}
+		ids.Inc(snap.ID)
 	}
-	return nil
+	return ids.Validate()
 }
 
 // Run the pipe
diff --git a/pkg/config/config.go b/pkg/config/config.go
index a97dcb86..fc5b05f5 100644
--- a/pkg/config/config.go
+++ b/pkg/config/config.go
@@ -226,6 +226,7 @@ type Snapcraft struct {
 	Replacements map[string]string `yaml:",omitempty"`
 	Publish      bool              `yaml:",omitempty"`
 
+	ID          string                          `yaml:",omitempty"`
 	Builds      []string                        `yaml:",omitempty"`
 	Name        string                          `yaml:",omitempty"`
 	Summary     string                          `yaml:",omitempty"`
diff --git a/www/content/snapcraft.md b/www/content/snapcraft.md
index fd2fdf4a..f2d6fab7 100644
--- a/www/content/snapcraft.md
+++ b/www/content/snapcraft.md
@@ -20,6 +20,10 @@ Available options:
 # .goreleaser.yml
 snapcrafts:
   -
+    # ID of the nfpm config, must be unique.
+    # Defaults to "default".
+    id: foo
+
     # Build IDs for the builds you want to create snapcraft packages for.
     # Defaults to all builds.
     builds:


Test patch:
diff --git a/internal/linux/arch_test.go b/internal/linux/arch_test.go
index a8d9901a..8b689c04 100644
--- a/internal/linux/arch_test.go
+++ b/internal/linux/arch_test.go
@@ -9,14 +9,15 @@ import (
 
 func TestArch(t *testing.T) {
 	for from, to := range map[string]string{
-		"linuxamd64": "amd64",
-		"linux386":   "i386",
-		"linuxarm64": "arm64",
-		"linuxarm6":  "armel",
-		"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",
 	} {
 		t.Run(fmt.Sprintf("%s to %s", from, to), func(t *testing.T) {
 			assert.Equal(t, to, Arch(from))
diff --git a/internal/pipe/snapcraft/snapcraft_test.go b/internal/pipe/snapcraft/snapcraft_test.go
index 4a2fc5ea..b582378d 100644
--- a/internal/pipe/snapcraft/snapcraft_test.go
+++ b/internal/pipe/snapcraft/snapcraft_test.go
@@ -12,6 +12,7 @@ import (
 	"github.com/goreleaser/goreleaser/pkg/config"
 	"github.com/goreleaser/goreleaser/pkg/context"
 	"github.com/stretchr/testify/assert"
+	"github.com/stretchr/testify/require"
 	yaml "gopkg.in/yaml.v2"
 )
 
@@ -80,7 +81,7 @@ func TestRunPipe(t *testing.T) {
 	addBinaries(t, ctx, "foo", filepath.Join(dist, "foo"), "foo")
 	addBinaries(t, ctx, "bar", filepath.Join(dist, "bar"), "bar")
 	assert.NoError(t, Pipe{}.Run(ctx))
-	assert.Len(t, ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List(), 6)
+	assert.Len(t, ctx.Artifacts.Filter(artifact.ByType(artifact.PublishableSnapcraft)).List(), 9)
 }
 
 func TestRunPipeInvalidNameTemplate(t *testing.T) {
@@ -313,3 +314,19 @@ func addBinaries(t *testing.T, ctx *context.Context, name, dist, dest string) {
 		}
 	}
 }
+
+func TestSeveralSnapssWithTheSameID(t *testing.T) {
+	var ctx = &context.Context{
+		Config: config.Project{
+			Snapcrafts: []config.Snapcraft{
+				{
+					ID: "a",
+				},
+				{
+					ID: "a",
+				},
+			},
+		},
+	}
+	require.EqualError(t, Pipe{}.Default(ctx), "found 2 items with the ID 'a', please fix your config")
+}