gradle / gradle-build-action

Execute your Gradle build and trigger dependency submission
https://github.com/marketplace/actions/gradle-build-action
MIT License
673 stars 97 forks source link

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

Closed rnc closed 2 years ago

rnc commented 2 years ago

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 commented 2 years ago

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

tbroyer commented 2 years ago

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 commented 2 years ago

@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 commented 2 years ago

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.