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

Enable Releasing Compiled Test Binaries #3037

Closed
2 tasks done
kalverra opened this issue Apr 13, 2022 · 6 comments · Fixed by #3064
Closed
2 tasks done

Enable Releasing Compiled Test Binaries #3037

kalverra opened this issue Apr 13, 2022 · 6 comments · Fixed by #3064
Assignees
Labels
enhancement New feature or request
Milestone

Comments

@kalverra
Copy link

Is your feature request related to a problem? Please describe.

I'd like to release some binaries of my compiled tests, usually achieved with the following command.

go test -c ./path/to/tests -o binary.name

I'd love to use goreleaser for this, but it seems to lack this option. I tried using

gobinary: "go test -c"

with no luck.

Describe the solution you'd like

Enable an option like

# Have this build compile go tests using `go test -c` instead of using the typical `go build`
# true (default), or false
compile_tests: true

Describe alternatives you've considered

Right now it looks like I'm going to be explicitly compiling these test binaries and using something like this tool to release them.

Search

  • I did search for other open and closed issues before opening this.

Code of Conduct

  • I agree to follow this project's Code of Conduct

Additional context

No response

@kalverra kalverra added enhancement New feature or request triage Issue pending triage by one of the maintainers labels Apr 13, 2022
@caarlos0
Copy link
Member

I think it should work if you add -c to the flags section in the builds config, can you try that?

@kalverra
Copy link
Author

@caarlos0 Looks like the same issue

builds:
  - id: "smoke-tests"
    binary: smoke.test
    dir: ./suite/smoke
    flags: 
      - -c
release failed after 0.74s error=build for smoke.test does not contain a main function

@kalverra
Copy link
Author

kalverra commented Apr 13, 2022

Also, this is a more niche case, but we tend to use Ginkgo to help write and compile our tests. Ginkgo compiles tests using ginkgo build ./path/to/tests so I tried utilizing that as the gobinary value. got the same error.

builds:
  - id: "smoke-tests"
    binary: smoke.test
    dir: ./suite/smoke
    gobinary: "ginkgo"
release failed after 0.77s error=build for smoke.test does not contain a main function

@caarlos0
Copy link
Member

release failed after 0.74s error=build for smoke.test does not contain a main function

ahh, I forgot about this

curious though: what's the use case of releasing test binaries?

@kalverra
Copy link
Author

We're working on a testing framework that includes its own suite of default tests, ones that we'd like other projects to be able to quickly download and utilize without having to clone our repo.

@caarlos0 caarlos0 removed the triage Issue pending triage by one of the maintainers label Apr 22, 2022
@caarlos0 caarlos0 added this to the v1.9.0 milestone Apr 22, 2022
@caarlos0
Copy link
Member

Made a quick prototype here, what do you think about options like this?

CleanShot 2022-04-24 at 22 00 14@2x

caarlos0 added a commit that referenced this issue Apr 25, 2022
Added two more options to the builds section:
- command: allow to override the command being run. E.g. instead of
  `go build`, one could run `go test -c` by setting gobinary, command
  and flags, respectively.
- no_main_check: by default, goreleaser will fail if there's no main
  function. This option allows to disable that check.

This PR effectively make GoReleaser able to release Go test binaries
instead of just "regular" binaries.

closes #3037

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
caarlos0 added a commit that referenced this issue Apr 26, 2022
* feat: add builds.no_main_check and builds.command

Added two more options to the builds section:
- command: allow to override the command being run. E.g. instead of
  `go build`, one could run `go test -c` by setting gobinary, command
  and flags, respectively.
- no_main_check: by default, goreleaser will fail if there's no main
  function. This option allows to disable that check.

This PR effectively make GoReleaser able to release Go test binaries
instead of just "regular" binaries.

closes #3037

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>

* test: fix broken tests

Signed-off-by: Carlos A Becker <caarlos0@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants