Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(nfpm): Add extension to produced artifacts #3940

Merged
merged 1 commit into from Apr 13, 2023

Conversation

mbamber
Copy link
Contributor

@mbamber mbamber commented Apr 13, 2023

Add extension to produced artifacts so that they can be filtered in later steps

Fixes #3933


I tried running the tests before raising this, but I get an unrelated error with docker (I get the same error on main). I'm not sure about if you value a test specifically around this? If so, lmk and I'll try to add one

@pull-request-size pull-request-size bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Apr 13, 2023
@mbamber mbamber mentioned this pull request Apr 13, 2023
3 tasks
Copy link
Member

@caarlos0 caarlos0 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good, should probably add a test too.

This should suffice:

diff --git a/internal/pipe/nfpm/nfpm_test.go b/internal/pipe/nfpm/nfpm_test.go
index 21e23af1..57809ae8 100644
--- a/internal/pipe/nfpm/nfpm_test.go
+++ b/internal/pipe/nfpm/nfpm_test.go
@@ -281,6 +281,7 @@ func TestRunPipe(t *testing.T) {
 	for _, pkg := range packages {
 		format := pkg.Format()
 		require.NotEmpty(t, format)
+		require.Equal(t, pkg.Format(), artifact.ExtraOr(*pkg, artifact.ExtraExt, ""))
 		arch := pkg.Goarch
 		if pkg.Goarm != "" {
 			arch += "v" + pkg.Goarm

Add extension to produced artifacts so that they can be filtered in
later steps

Fixes goreleaser#3933

Co-authored-by: Carlos A Becker <caarlos0@users.noreply.github.com>
@caarlos0
Copy link
Member

awesome, thank you!

@caarlos0 caarlos0 added the bug Something isn't working label Apr 13, 2023
@caarlos0 caarlos0 merged commit ac19f90 into goreleaser:main Apr 13, 2023
9 checks passed
@github-actions github-actions bot added this to the v1.18.0 milestone Apr 13, 2023
@caarlos0
Copy link
Member

I tried running the tests before raising this, but I get an unrelated error with docker (I get the same error on main). I'm not sure about if you value a test specifically around this? If so, lmk and I'll try to add one

hmmm which error you got? may be worth investigating...

@mbamber
Copy link
Contributor Author

mbamber commented Apr 13, 2023

TestRunPipe/multiarch_image_template_error_on_docker

Output:

--- FAIL: TestRunPipe (7.34s)
    docker_test.go:959: starting registries
    --- FAIL: TestRunPipe/multiarch_image_template_error_on_docker (3.74s)
        docker_test.go:1051:
            	Error Trace:	/Users/mbamber/workspace/goreleaser/internal/pipe/docker/docker_test.go:47
            	            				/Users/mbamber/workspace/goreleaser/internal/pipe/docker/docker_test.go:1051
            	Error:      	Received unexpected error:
            	            	docker build failed: seems like you tried to copy a file that is not available in the build context.

            	            	Here's more information about the build context:

            	            	dir: "/var/folders/z6/04q0xsdn4zl1kzsxg0tsv7c00000gn/T/goreleaserdocker3348068017"
            	            	files in that dir:
            	            	 Dockerfile
            	            	 anotherbin
            	            	 mybin
            	            	 mybin_arm64.apk

            	            	Previous error:
            	            	failed to build localhost:5050/goreleaser/test_multiarch_img_tmpl_error: exit status 1: #1 [internal] load build definition from Dockerfile
            	            	#1 sha256:197467af2f316b7d03019b38c72600fb2c0dc25b796613e94ef25062c2d96fce
            	            	#1 transferring dockerfile: 66B 0.0s done
            	            	#1 DONE 0.1s

            	            	#2 [internal] load .dockerignore
            	            	#2 sha256:66f38a7631a43183fcc0a8f02571c83154a9049da86edeeddf37de0fb3f74bae
            	            	#2 transferring context: 2B done
            	            	#2 DONE 0.1s

            	            	#3 [internal] load metadata for docker.io/library/alpine:latest
            	            	#3 sha256:d4fb25f5b5c00defc20ce26f2efc4e288de8834ed5aa59dff877b495ba88fda6
            	            	#3 ERROR: rpc error: code = Unknown desc = error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``
            	            	------
            	            	 > [internal] load metadata for docker.io/library/alpine:latest:
            	            	------
            	            	failed to solve with frontend dockerfile.v0: failed to create LLB definition: rpc error: code = Unknown desc = error getting credentials - err: exec: "docker-credential-desktop": executable file not found in $PATH, out: ``

            	            	Learn more at https://goreleaser.com/errors/docker-build
            	Test:       	TestRunPipe/multiarch_image_template_error_on_docker
FAIL

Having spent more than 5s actually reading this error, it's probably because I don't have docker-credential-desktop installed/setup correctly, so I reckon this is a non-issue

@mbamber mbamber deleted the fix-nfpm-extensions branch April 13, 2023 15:30
@caarlos0
Copy link
Member

err: exec: "docker-credential-desktop": executable file not found in $PATH, out:

this seems to be the root cause...

@caarlos0
Copy link
Member

this should improve it: #3942

caarlos0 added a commit that referenced this pull request Apr 13, 2023
@mbamber
Copy link
Contributor Author

mbamber commented Apr 13, 2023

Awesome! Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working size/XS Denotes a PR that changes 0-9 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nfpm extensions not being set
2 participants