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

build-result-capture.init.gradle is giving errors in action run #350

Closed
rnc opened this issue Jun 29, 2022 · 4 comments
Closed

build-result-capture.init.gradle is giving errors in action run #350

rnc opened this issue Jun 29, 2022 · 4 comments
Assignees
Labels
bug Something isn't working
Milestone

Comments

@rnc
Copy link

rnc commented Jun 29, 2022

In my action run I can see

       Caused by: groovy.lang.GroovyRuntimeException: Ambiguous method overloading for method java.io.File#<init>.
      Cannot resolve which method to invoke for [null, class java.lang.String] due to overlapping prototypes between:
      	[class java.lang.String, class java.lang.String]
      	[class java.io.File, class java.lang.String]

I think this is coming from https://github.com/gradle/gradle-build-action/blob/main/src/resources/init-scripts/build-result-capture.init.gradle#L109 as its possible getenv returns null. It may be better to use getProperty with a default value?

An example of this happening is https://github.com/project-ncl/gradle-manipulator/runs/7109028866?check_suite_focus=true

@tbroyer
Copy link

tbroyer commented Jun 29, 2022

Apparently, it should be possible to use System.getenv("RUNNER_TEMP") as String to disambiguate: https://stackoverflow.com/a/12535814/116472

@tbroyer
Copy link

tbroyer commented Jun 29, 2022

Fwiw, I find it a bit strange to build the project with many different Gradle versions, rather than using, say, TestKit, to use a fixed version to build the project and then run tests using many different Gradle versions.

Using TestKit for instance would mean using a separate Gradle User Home dir (even if you use the same Gradle version as the one used to build the project), so your tests won't be polluted by things setup in the Gradle User Home, like the init script used by the gradle-build-action.

@rnc
Copy link
Author

rnc commented Jun 29, 2022

@tbroyer We do use TestKit as well, but due to the differing API between Gradle versions and the necessity to able to work against various Gradle versions (as when we internally rebuild all projects they may use different versions of Gradle) it meant the test suite had to be more comprehensive.

@bigdaz
Copy link
Member

bigdaz commented Jul 11, 2022

Thanks for the report @rnc, and for the diagnosis. Indeed I can see how the init-script will fail when a Gradle build is run without the GitHub Actions env vars set.

I plan on fixing this so that builds run outside of the GitHub Actions context will not have any results file written, and thus will not show up in the GitHub Actions Job Summary.

@bigdaz bigdaz self-assigned this Jul 11, 2022
@bigdaz bigdaz added the bug Something isn't working label Jul 11, 2022
@bigdaz bigdaz added this to the v2.2.2 milestone Jul 11, 2022
@bigdaz bigdaz closed this as completed in 792a93a Jul 11, 2022
dwalluck added a commit to dwalluck/gradle-manipulator that referenced this issue Aug 3, 2022
dwalluck added a commit to dwalluck/gradle-manipulator that referenced this issue Aug 4, 2022
rnc pushed a commit to project-ncl/gradle-manipulator that referenced this issue Aug 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants