diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index bcc5eae5505..fb249b7a187 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -64,7 +64,7 @@ jobs: mkdir -p $HOME/.cache/snapcraft/stage-packages - uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v3 with: - go-version: '1.18' + go-version: '1.19' - uses: actions/cache@661fd3eb7f2f20d8c7c84bc2b0509efd7a826628 # v2 with: path: | diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index b2625949ac5..594bdc17e93 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -23,7 +23,7 @@ jobs: repo-token: ${{ secrets.GITHUB_TOKEN }} - uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v3 with: - go-version: 1.18 + go-version: 1.19 - run: task docs:build - uses: wjdp/htmltest-action@09118714cd26bef56bd3d0819e4f9b1dce6f60a9 # master with: diff --git a/.github/workflows/generate.yml b/.github/workflows/generate.yml index e83f40815dc..694b737ff06 100644 --- a/.github/workflows/generate.yml +++ b/.github/workflows/generate.yml @@ -24,7 +24,7 @@ jobs: token: ${{ secrets.GH_PAT }} - uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v3 with: - go-version: 1.18 + go-version: 1.19 - uses: arduino/setup-task@ca745e18916de727f841ec824ac20a615f1cddea # v1 - run: task docs:generate - run: task schema:generate diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index a782f00da09..dd3ce21ff9c 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -19,7 +19,7 @@ jobs: steps: - uses: actions/setup-go@84cbf8094393cdc5fe1fe1671ff2647332956b1a # v3 with: - go-version: ~1.18 + go-version: ~1.19 - uses: actions/checkout@b0e28b5ac45a892f91e7d036f8200cf5ed489415 # v3 - name: golangci-lint uses: golangci/golangci-lint-action@537aa1903e5d359d0b27dbc19ddd22c5087f3fbc # v3 diff --git a/.golangci.yaml b/.golangci.yaml index dda47b7b9dc..627661571de 100644 --- a/.golangci.yaml +++ b/.golangci.yaml @@ -1,5 +1,5 @@ run: - go: 1.18 + go: 1.19 linters: enable: - thelper diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 3ebab66f507..a27e5c962a6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -9,7 +9,7 @@ By participating to this project, you agree to abide our [code of conduct](https Prerequisites: - [Task](https://taskfile.dev/#/installation) -- [Go 1.18+](https://golang.org/doc/install) +- [Go 1.19+](https://golang.org/doc/install) Other things you might need to run the tests: diff --git a/cmd/util_test.go b/cmd/util_test.go index 3d9b4c0597d..083f63860fd 100644 --- a/cmd/util_test.go +++ b/cmd/util_test.go @@ -62,7 +62,7 @@ func goModInit(tb testing.TB) { tb.Helper() createFile(tb, "go.mod", `module foo -go 1.18 +go 1.19 `) } diff --git a/go.mod b/go.mod index f19bb5a8b67..337c864a983 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/goreleaser/goreleaser -go 1.18 +go 1.19 require ( code.gitea.io/sdk/gitea v0.15.1 diff --git a/internal/artifact/artifact_test.go b/internal/artifact/artifact_test.go index c3e3452cad8..e1dfd62650e 100644 --- a/internal/artifact/artifact_test.go +++ b/internal/artifact/artifact_test.go @@ -405,7 +405,7 @@ func TestExtra(t *testing.T) { t.Run("unmarshal error", func(t *testing.T) { _, err := Extra[config.Docker](a, "fail-plz") - require.EqualError(t, err, "json: unknown field \"Name\"") + require.EqualError(t, err, "json: unknown field \"tap\"") }) t.Run("marshal error", func(t *testing.T) { diff --git a/internal/builders/golang/build_test.go b/internal/builders/golang/build_test.go index ef9fbfb47f6..c10550e3aa6 100644 --- a/internal/builders/golang/build_test.go +++ b/internal/builders/golang/build_test.go @@ -258,8 +258,9 @@ func TestDefaults(t *testing.T) { // createFakeGoBinaryWithVersion creates a temporary executable with the // given name, which will output a go version string with the given version. -// The temporary directory created by this function will be placed in the PATH -// variable for the duration of (and cleaned up at the end of) the +// +// The temporary directory created by this function will be placed in the +// PATH variable for the duration of (and cleaned up at the end of) the // current test run. func createFakeGoBinaryWithVersion(tb testing.TB, name, version string) { tb.Helper() @@ -626,7 +627,7 @@ func TestRunInvalidAsmflags(t *testing.T) { err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{ Target: runtimeTarget, }) - require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, err) } func TestRunInvalidGcflags(t *testing.T) { @@ -650,7 +651,7 @@ func TestRunInvalidGcflags(t *testing.T) { err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{ Target: runtimeTarget, }) - require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, err) } func TestRunInvalidLdflags(t *testing.T) { @@ -675,7 +676,7 @@ func TestRunInvalidLdflags(t *testing.T) { err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{ Target: runtimeTarget, }) - require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, err) } func TestRunInvalidFlags(t *testing.T) { @@ -698,7 +699,7 @@ func TestRunInvalidFlags(t *testing.T) { err := Default.Build(ctx, ctx.Config.Builds[0], api.Options{ Target: runtimeTarget, }) - require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, err) } func TestRunPipeWithoutMainFunc(t *testing.T) { @@ -903,15 +904,15 @@ func TestLdFlagsFullTemplate(t *testing.T) { } func TestInvalidTemplate(t *testing.T) { - for template, eerr := range map[string]string{ - "{{ .Nope }": `template: tmpl:1: unexpected "}" in operand`, - "{{.Env.NOPE}}": `template: tmpl:1:6: executing "tmpl" at <.Env.NOPE>: map has no entry for key "NOPE"`, + for _, template := range []string{ + "{{ .Nope }", + "{{.Env.NOPE}}", } { t.Run(template, func(t *testing.T) { ctx := context.New(config.Project{}) ctx.Git.CurrentTag = "3.4.1" flags, err := tmpl.New(ctx).Apply(template) - require.EqualError(t, err, eerr) + testlib.RequireTemplateError(t, err) require.Empty(t, flags) }) } @@ -966,10 +967,8 @@ func TestProcessFlagsInvalid(t *testing.T) { "{{.Version}", } - expected := `template: tmpl:1: unexpected "}" in operand` - flags, err := processFlags(ctx, &artifact.Artifact{}, []string{}, source, "-testflag=") - require.EqualError(t, err, expected) + testlib.RequireTemplateError(t, err) require.Nil(t, flags) } @@ -1291,7 +1290,7 @@ func TestOverrides(t *testing.T) { Goarch: runtime.GOARCH, }, ) - require.EqualError(t, err, `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, err) }) t.Run("with goarm", func(t *testing.T) { diff --git a/internal/pipe/archive/archive_test.go b/internal/pipe/archive/archive_test.go index 373d3e958c0..4fba3b4196f 100644 --- a/internal/pipe/archive/archive_test.go +++ b/internal/pipe/archive/archive_test.go @@ -536,7 +536,7 @@ func TestRunPipeInvalidNameTemplate(t *testing.T) { artifact.ExtraID: "default", }, }) - require.EqualError(t, Pipe{}.Run(ctx), `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) } func TestRunPipeInvalidFilesNameTemplate(t *testing.T) { @@ -574,7 +574,7 @@ func TestRunPipeInvalidFilesNameTemplate(t *testing.T) { artifact.ExtraID: "default", }, }) - require.EqualError(t, Pipe{}.Run(ctx), `failed to find files to archive: failed to apply template {{.asdsd}: template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) } func TestRunPipeInvalidWrapInDirectoryTemplate(t *testing.T) { diff --git a/internal/pipe/artifactory/artifactory_test.go b/internal/pipe/artifactory/artifactory_test.go index 8d7e9d5dcda..d8e9ce0cd8b 100644 --- a/internal/pipe/artifactory/artifactory_test.go +++ b/internal/pipe/artifactory/artifactory_test.go @@ -358,7 +358,7 @@ func TestRunPipe_TargetTemplateError(t *testing.T) { Name: "production", Mode: "binary", // This template is not correct and should fail - Target: "http://storage.company.com/example-repo-local/{{ .ProjectName /{{ .Version }}/", + Target: "http://storage.company.com/example-repo-local/{{.Name}", Username: "deployuser", }, }, @@ -378,7 +378,7 @@ func TestRunPipe_TargetTemplateError(t *testing.T) { }) require.NoError(t, Pipe{}.Default(ctx)) - require.EqualError(t, Pipe{}.Publish(ctx), `artifactory: error while building the target url: template: tmpl:1: unexpected "/" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Publish(ctx)) } func TestRunPipe_BadCredentials(t *testing.T) { diff --git a/internal/pipe/docker/docker_test.go b/internal/pipe/docker/docker_test.go index 0eeee1de213..3858c74a692 100644 --- a/internal/pipe/docker/docker_test.go +++ b/internal/pipe/docker/docker_test.go @@ -81,13 +81,17 @@ func TestRunPipe(t *testing.T) { t.Helper() require.NoError(t, err) } + shouldTemplateErr := func(t *testing.T, err error) { + t.Helper() + testlib.RequireTemplateError(t, err) + } type imageLabelFinder func(*testing.T, string) shouldFindImagesWithLabels := func(image string, filters ...string) func(*testing.T, string) { return func(t *testing.T, use string) { t.Helper() for _, filter := range filters { cmd := exec.Command("docker", "images", "-q", "--filter", "reference=*/"+image, "--filter", filter) - t.Log("running", cmd) + // t.Log("running", cmd) output, err := cmd.CombinedOutput() require.NoError(t, err, string(output)) uniqueIDs := map[string]string{} @@ -272,7 +276,7 @@ func TestRunPipe(t *testing.T) { fmt.Sprintf("docker push %sgoreleaser/dummy:v1", registry), fmt.Sprintf("docker manifest create %sgoreleaser/test_multiarch:2test --amend %sgoreleaser/dummy:v1 --insecure", registry, registry), } { - t.Log("running", cmd) + // t.Log("running", cmd) parts := strings.Fields(cmd) out, err := exec.CommandContext(ctx, parts[0], parts[1:]...).CombinedOutput() require.NoError(t, err, cmd+": "+string(out)) @@ -319,7 +323,7 @@ func TestRunPipe(t *testing.T) { expect: []string{registry + "goreleaser/test_multiarch_manifest_tmpl_error"}, assertError: shouldNotErr, pubAssertError: shouldNotErr, - manifestAssertError: shouldErr(`template: tmpl:1: unexpected "}" in operand`), + manifestAssertError: shouldTemplateErr, assertImageLabels: noLabels, }, "multiarch image template error": { @@ -340,7 +344,7 @@ func TestRunPipe(t *testing.T) { expect: []string{registry + "goreleaser/test_multiarch_img_tmpl_error"}, assertError: shouldNotErr, pubAssertError: shouldNotErr, - manifestAssertError: shouldErr(`template: tmpl:1: unexpected "}" in operand`), + manifestAssertError: shouldTemplateErr, assertImageLabels: noLabels, }, "multiarch missing manifest name": { @@ -478,7 +482,7 @@ func TestRunPipe(t *testing.T) { }, }, expect: []string{}, - assertError: shouldErr(`template: tmpl:1:7: executing "tmpl" at <.Env.Dockerfile>: map has no entry for key "Dockerfile"`), + assertError: shouldTemplateErr, assertImageLabels: noLabels, pubAssertError: shouldNotErr, manifestAssertError: shouldNotErr, @@ -771,7 +775,7 @@ func TestRunPipe(t *testing.T) { }, }, assertImageLabels: noLabels, - assertError: shouldErr(`template: tmpl:1: unexpected "}" in operand`), + assertError: shouldTemplateErr, }, "build_flag_template_error": { dockers: []config.Docker{ @@ -788,7 +792,7 @@ func TestRunPipe(t *testing.T) { }, }, assertImageLabels: noLabels, - assertError: shouldErr(`template: tmpl:1: unexpected "}" in operand`), + assertError: shouldTemplateErr, }, "missing_env_on_tag_template": { dockers: []config.Docker{ @@ -802,7 +806,7 @@ func TestRunPipe(t *testing.T) { }, }, assertImageLabels: noLabels, - assertError: shouldErr(`template: tmpl:1:46: executing "tmpl" at <.Env.NOPE>: map has no entry for key "NOPE"`), + assertError: shouldTemplateErr, }, "missing_env_on_build_flag_template": { dockers: []config.Docker{ @@ -819,7 +823,7 @@ func TestRunPipe(t *testing.T) { }, }, assertImageLabels: noLabels, - assertError: shouldErr(`template: tmpl:1:19: executing "tmpl" at <.Env.NOPE>: map has no entry for key "NOPE"`), + assertError: shouldTemplateErr, }, "image_has_projectname_template_variable": { dockers: []config.Docker{ @@ -1087,7 +1091,7 @@ func TestRunPipe(t *testing.T) { // this might should not fail as the image should have been created when // the step ran for _, img := range docker.expect { - t.Log("removing docker image", img) + // t.Log("removing docker image", img) require.NoError(t, rmi(img), "could not delete image %s", img) } }) diff --git a/internal/pipe/gomod/gomod_proxy_test.go b/internal/pipe/gomod/gomod_proxy_test.go index e49fed48da0..b6b057bedf9 100644 --- a/internal/pipe/gomod/gomod_proxy_test.go +++ b/internal/pipe/gomod/gomod_proxy_test.go @@ -227,7 +227,7 @@ func requireGoMod(tb testing.TB, module, version string) { require.NoError(tb, err) require.Contains(tb, string(mod), fmt.Sprintf(`module foo -go 1.18 +go 1.19 require %s %s `, module, version)) diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go index 26c8b62fbcb..922ac10eeb8 100644 --- a/internal/pipe/nfpm/nfpm_test.go +++ b/internal/pipe/nfpm/nfpm_test.go @@ -429,7 +429,7 @@ func TestInvalidTemplate(t *testing.T) { FileNameTemplate: "{{.Foo}", } require.NoError(t, Pipe{}.Default(ctx)) - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("source", func(t *testing.T) { @@ -442,7 +442,7 @@ func TestInvalidTemplate(t *testing.T) { }, }, } - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_SOURCE>: map has no entry for key "NOPE_SOURCE"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("target", func(t *testing.T) { @@ -455,49 +455,49 @@ func TestInvalidTemplate(t *testing.T) { }, }, } - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_TARGET>: map has no entry for key "NOPE_TARGET"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("description", func(t *testing.T) { ctx := makeCtx() ctx.Config.NFPMs[0].Description = "{{ .NOPE_DESC }}" - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_DESC>: map has no entry for key "NOPE_DESC"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("maintainer", func(t *testing.T) { ctx := makeCtx() ctx.Config.NFPMs[0].Maintainer = "{{ .NOPE_DESC }}" - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_DESC>: map has no entry for key "NOPE_DESC"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("homepage", func(t *testing.T) { ctx := makeCtx() ctx.Config.NFPMs[0].Homepage = "{{ .NOPE_HOMEPAGE }}" - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_HOMEPAGE>: map has no entry for key "NOPE_HOMEPAGE"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("deb key file", func(t *testing.T) { ctx := makeCtx() ctx.Config.NFPMs[0].Deb.Signature.KeyFile = "{{ .NOPE_KEY_FILE }}" - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_KEY_FILE>: map has no entry for key "NOPE_KEY_FILE"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("rpm key file", func(t *testing.T) { ctx := makeCtx() ctx.Config.NFPMs[0].RPM.Signature.KeyFile = "{{ .NOPE_KEY_FILE }}" - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_KEY_FILE>: map has no entry for key "NOPE_KEY_FILE"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("apk key file", func(t *testing.T) { ctx := makeCtx() ctx.Config.NFPMs[0].APK.Signature.KeyFile = "{{ .NOPE_KEY_FILE }}" - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:3: executing "tmpl" at <.NOPE_KEY_FILE>: map has no entry for key "NOPE_KEY_FILE"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("bindir", func(t *testing.T) { ctx := makeCtx() ctx.Config.NFPMs[0].Bindir = "/usr/{{ .NOPE }}" - require.Contains(t, Pipe{}.Run(ctx).Error(), `template: tmpl:1:8: executing "tmpl" at <.NOPE>: map has no entry for key "NOPE"`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) } @@ -532,7 +532,7 @@ func TestRunPipeInvalidContentsSourceTemplate(t *testing.T) { artifact.ExtraID: "default", }, }) - require.EqualError(t, Pipe{}.Run(ctx), `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) } func TestNoBuildsFound(t *testing.T) { diff --git a/internal/pipe/snapcraft/snapcraft_test.go b/internal/pipe/snapcraft/snapcraft_test.go index e008390d901..2014727c463 100644 --- a/internal/pipe/snapcraft/snapcraft_test.go +++ b/internal/pipe/snapcraft/snapcraft_test.go @@ -142,7 +142,7 @@ func TestRunPipeInvalidNameTemplate(t *testing.T) { ctx.Git.CurrentTag = "v1.2.3" ctx.Version = "1.2.3" addBinaries(t, ctx, "foo", dist) - require.EqualError(t, Pipe{}.Run(ctx), `template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) } func TestRunPipeWithName(t *testing.T) { diff --git a/internal/pipe/snapshot/snapshot_test.go b/internal/pipe/snapshot/snapshot_test.go index ac5c6f07b56..fa430c7d1fb 100644 --- a/internal/pipe/snapshot/snapshot_test.go +++ b/internal/pipe/snapshot/snapshot_test.go @@ -3,6 +3,7 @@ package snapshot import ( "testing" + "github.com/goreleaser/goreleaser/internal/testlib" "github.com/goreleaser/goreleaser/pkg/config" "github.com/goreleaser/goreleaser/pkg/context" "github.com/stretchr/testify/require" @@ -40,7 +41,7 @@ func TestSnapshotInvalidNametemplate(t *testing.T) { NameTemplate: "{{.ShortCommit}{{{sss}}}", }, }) - require.EqualError(t, Pipe{}.Run(ctx), `failed to generate snapshot name: template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) } func TestSnapshotEmptyFinalName(t *testing.T) { diff --git a/internal/pipe/universalbinary/universalbinary_test.go b/internal/pipe/universalbinary/universalbinary_test.go index b5dd59f21a6..b018ad5f387 100644 --- a/internal/pipe/universalbinary/universalbinary_test.go +++ b/internal/pipe/universalbinary/universalbinary_test.go @@ -10,6 +10,7 @@ import ( "time" "github.com/goreleaser/goreleaser/internal/artifact" + "github.com/goreleaser/goreleaser/internal/testlib" "github.com/goreleaser/goreleaser/pkg/config" "github.com/goreleaser/goreleaser/pkg/context" "github.com/stretchr/testify/require" @@ -267,13 +268,13 @@ func TestRun(t *testing.T) { }) t.Run("bad template", func(t *testing.T) { - require.EqualError(t, Pipe{}.Run(context.New(config.Project{ + testlib.RequireTemplateError(t, Pipe{}.Run(context.New(config.Project{ UniversalBinaries: []config.UniversalBinary{ { NameTemplate: "{{.Name}", }, }, - })), `template: tmpl:1: unexpected "}" in operand`) + }))) }) t.Run("no darwin builds", func(t *testing.T) { @@ -326,7 +327,7 @@ func TestRun(t *testing.T) { Env: []string{"FOO=foo-{{.Tag}"}, }} ctx.Config.UniversalBinaries[0].Hooks.Post = []config.Hook{} - require.EqualError(t, Pipe{}.Run(ctx), `pre hook failed: template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("hook with bad dir tmpl", func(t *testing.T) { @@ -336,7 +337,7 @@ func TestRun(t *testing.T) { Dir: "{{.Tag}", }} ctx.Config.UniversalBinaries[0].Hooks.Post = []config.Hook{} - require.EqualError(t, Pipe{}.Run(ctx), `pre hook failed: template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) t.Run("hook with bad cmd tmpl", func(t *testing.T) { @@ -345,7 +346,7 @@ func TestRun(t *testing.T) { Cmd: "echo blah-{{.Tag }", }} ctx.Config.UniversalBinaries[0].Hooks.Post = []config.Hook{} - require.EqualError(t, Pipe{}.Run(ctx), `pre hook failed: template: tmpl:1: unexpected "}" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Run(ctx)) }) } diff --git a/internal/pipe/upload/upload_test.go b/internal/pipe/upload/upload_test.go index 9d46cf9ee89..2149cb5631d 100644 --- a/internal/pipe/upload/upload_test.go +++ b/internal/pipe/upload/upload_test.go @@ -12,6 +12,7 @@ import ( "github.com/goreleaser/goreleaser/internal/artifact" "github.com/goreleaser/goreleaser/internal/pipe" + "github.com/goreleaser/goreleaser/internal/testlib" "github.com/goreleaser/goreleaser/pkg/config" "github.com/goreleaser/goreleaser/pkg/context" "github.com/stretchr/testify/require" @@ -396,7 +397,7 @@ func TestRunPipe_TargetTemplateError(t *testing.T) { Name: "production", Mode: "binary", // This template is not correct and should fail - Target: "http://storage.company.com/example-repo-local/{{ .ProjectName /{{ .Version }}/", + Target: "http://storage.company.com/example-repo-local/{{ .ProjectName}", Username: "deployuser", }, }, @@ -414,9 +415,7 @@ func TestRunPipe_TargetTemplateError(t *testing.T) { Goos: "darwin", Type: artifact.UploadableBinary, }) - err := Pipe{}.Publish(ctx) - require.Error(t, err) - require.Contains(t, err.Error(), `upload: error while building the target url: template: tmpl:1: unexpected "/" in operand`) + testlib.RequireTemplateError(t, Pipe{}.Publish(ctx)) } func TestRunPipe_BadCredentials(t *testing.T) { diff --git a/internal/testlib/tmpl.go b/internal/testlib/tmpl.go new file mode 100644 index 00000000000..77a932fd9e9 --- /dev/null +++ b/internal/testlib/tmpl.go @@ -0,0 +1,16 @@ +package testlib + +import ( + "testing" + + "github.com/stretchr/testify/require" +) + +// RequireTemplateError requires thqt an error happens and that it is an template error. +func RequireTemplateError(tb testing.TB, err error) { + tb.Helper() + + require.Error(tb, err) + require.Contains(tb, err.Error(), "template:") + require.Regexp(tb, "bad character|map has no entry|unexpected \"}\" in operand", err.Error()) +} diff --git a/www/docs/ci/actions.md b/www/docs/ci/actions.md index 2b50350a1e0..b07a55cc8ce 100644 --- a/www/docs/ci/actions.md +++ b/www/docs/ci/actions.md @@ -42,7 +42,7 @@ jobs: name: Set up Go uses: actions/setup-go@v2 with: - go-version: 1.18 + go-version: 1.19 - name: Run GoReleaser uses: goreleaser/goreleaser-action@v2 diff --git a/www/docs/ci/azurepipelines.md b/www/docs/ci/azurepipelines.md index 0cdfafae8d2..84f4a42e05f 100644 --- a/www/docs/ci/azurepipelines.md +++ b/www/docs/ci/azurepipelines.md @@ -69,7 +69,7 @@ trigger: - refs/tags/* variables: - GO_VERSION: "1.18" + GO_VERSION: "1.19" pool: vmImage: ubuntu-latest diff --git a/www/docs/ci/circle.md b/www/docs/ci/circle.md index 12d6306c0b8..c62ac61bea6 100644 --- a/www/docs/ci/circle.md +++ b/www/docs/ci/circle.md @@ -18,7 +18,7 @@ workflows: jobs: release: docker: - - image: cimg/go:1.18 + - image: cimg/go:1.19 steps: - checkout - run: curl -sfL https://goreleaser.com/static/run | bash diff --git a/www/docs/ci/codefresh.md b/www/docs/ci/codefresh.md index 973f2b0edd6..af5f89ea6dc 100644 --- a/www/docs/ci/codefresh.md +++ b/www/docs/ci/codefresh.md @@ -23,7 +23,7 @@ steps: BuildMyApp: title: Compiling go code stage: build - image: 'golang:1.18' + image: 'golang:1.19' commands: - go build ReleaseMyApp: