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

Gradle version check broken #299

Closed
GFriedrich opened this issue Mar 21, 2019 · 8 comments
Closed

Gradle version check broken #299

GFriedrich opened this issue Mar 21, 2019 · 8 comments

Comments

@GFriedrich
Copy link

GFriedrich commented Mar 21, 2019

To me the following two lines look weird:

releaseCandidate: new GradleUpdateResult(enabled && (gradleReleaseChannel == RELEASE_CANDIDATE.id), gradleUpdateChecker.runningGradleVersion, gradleUpdateChecker.releaseCandidateGradleVersion),
nightly: new GradleUpdateResult(enabled && (gradleReleaseChannel == RELEASE_CANDIDATE.id || gradleReleaseChannel == NIGHTLY.id), gradleUpdateChecker.runningGradleVersion, gradleUpdateChecker.nightlyGradleVersion)

It seems that the releaseCandidate check is being executed when the release channel is set to "RELEASE_CANDIDATE" and the nightly check is executed for "RELEASE_CANDIDATE" OR "NIGHTLY".
I would have expected the check the other way around (or at least no nightly check for "RELEASE_CANDIDATE").
Funny thing is: The nightly result is never printed for "RELEASE_CANDIDATE", as the checks are done correctly within the PlainTextReporter class.

@dje1990
Copy link
Contributor

dje1990 commented Apr 3, 2019

Hi @GFriedrich

Is the check printing the wrong result or is this just a code observation?

Below is the constructor of GradleUpdateResult.
When checking for RC updates (and implicitly current), then the RC channel result is written to the field GradleUpdateResult.version for the field GradleUpdateResults.releaseCandidate
When checking for Nightly updates (and implicitly RC and current), then the Nightly channel result is written to the field GradleUpdateResult.version for the field GradleUpdateResults.nightly

The complete class for GradleUpdateResults is below too.

Hope this helps. Thanks.

  GradleUpdateResult(boolean enabled, GradleUpdateChecker.ReleaseStatus.Available running, GradleUpdateChecker.ReleaseStatus release) {
    if (!enabled) {
      this.version = ""
      this.isUpdateAvailable = false
      this.isFailure = false
      this.reason = "update check disabled"
    } else if (release instanceof GradleUpdateChecker.ReleaseStatus.Available) {
      this.version = release.gradleVersion.version
      this.isUpdateAvailable = release.gradleVersion > running.gradleVersion
      this.isFailure = false
      this.reason = "" // empty string so the field is serialized
    } else if (release instanceof GradleUpdateChecker.ReleaseStatus.Unavailable) {
      this.version = "" // empty string so the field is serialized
      this.isUpdateAvailable = false
      this.isFailure = false
      this.reason = "update check succeeded: no release available"
    } else if (release instanceof GradleUpdateChecker.ReleaseStatus.Failure) {
      this.version = "" // empty string so the field is serialized
      this.isUpdateAvailable = false
      this.isFailure = true
      this.reason = release.reason
    } else {
      throw new IllegalStateException("ReleaseStatus subtype [" + release.class + "] not yet implemented")
    }
  }
@TupleConstructor
class GradleUpdateResults {
  boolean enabled
  GradleUpdateResult running
  GradleUpdateResult current
  GradleUpdateResult releaseCandidate
  GradleUpdateResult nightly
}

@GFriedrich
Copy link
Author

GFriedrich commented Apr 4, 2019

Hi @dje1990,

this was just by reading the code, but nevertheless the checks are not correct in DependencyUpdatesReporter.
Please check again the lines that I've posted:

releaseCandidate: new GradleUpdateResult(enabled && (gradleReleaseChannel == RELEASE_CANDIDATE.id), gradleUpdateChecker.runningGradleVersion, gradleUpdateChecker.releaseCandidateGradleVersion),
nightly: new GradleUpdateResult(enabled && (gradleReleaseChannel == RELEASE_CANDIDATE.id || gradleReleaseChannel == NIGHTLY.id), gradleUpdateChecker.runningGradleVersion, gradleUpdateChecker.nightlyGradleVersion)

You've said:

When checking for RC updates (and implicitly current), then the RC channel result is written to the field GradleUpdateResult.version for the field GradleUpdateResults.releaseCandidate
When checking for Nightly updates (and implicitly RC and current), then the Nightly channel result is written to the field GradleUpdateResult.version for the field GradleUpdateResults.nightly

But if you check the lines, this is not what the code is doing: The nightly check is enabled for gradleReleaseChannel == RELEASE_CANDIDATE.id || gradleReleaseChannel == NIGHTLY.id and you said RC should just check for RC (and implicitly current) - but NOT nightly, which is currently happening.

Hope this makes it more clear.

@dje1990
Copy link
Contributor

dje1990 commented Apr 4, 2019

Hi @GFriedrich

I agree I think that the code is incorrect, I have created a fix in #302
Thanks for identifying

@ben-manes
Copy link
Owner

Thanks!

@ben-manes
Copy link
Owner

@dje1990 can you please look into this test failure? I tried to release for Gradle 6, but unfortunately the CI failed (which also pushed the release to jcenter).

com.github.benmanes.gradle.versions.DifferentGradleVersionsSpec > dependencyUpdates task uses specified release channel with Gradle current FAILED
    Condition not satisfied:
    !result.output.contains("UP-TO-DATE")
    ||      |      |
    ||      |      true
    ||      :dependencyUpdates
    ||       
    ||      ------------------------------------------------------------
    ||      : Project Dependency Updates (report to plain text file)
    ||      ------------------------------------------------------------
    ||       
    ||      The following dependencies have later milestone versions:
    ||       - com.google.inject:guice [2.0 -> 3.0]
    ||           http://code.google.com/p/google-guice/
    ||       
    ||      Gradle current updates:
    ||      [ERROR] [release channel: current] Unable to process url: https://services.gradle.org/versions/current
    ||       - Gradle: [3.0: UP-TO-DATE]
    ||       
    ||      Generated report file build/dependencyUpdates/report.txt
    ||       
    ||      BUILD SUCCESSFUL
    ||       
    ||      Total time: 52.87 secs
    |org.gradle.testkit.runner.internal.FeatureCheckBuildResult@506174b6
    false
        at com.github.benmanes.gradle.versions.DifferentGradleVersionsSpec.dependencyUpdates task uses specified release channel with Gradle #gradleReleaseChannel(DifferentGradleVersionsSpec.groovy:139)
com.github.benmanes.gradle.versions.DifferentGradleVersionsSpec > dependencyUpdates task uses specified release channel with Gradle release-candidate FAILED
    org.gradle.testkit.runner.UnexpectedBuildFailure: Unexpected build execution failure in /tmp/junit2930023449630935552 with arguments [dependencyUpdates]
    Output:
    :dependencyUpdates
    ------------------------------------------------------------
    : Project Dependency Updates (report to plain text file)
    ------------------------------------------------------------
    The following dependencies have later milestone versions:
     - com.google.inject:guice [2.0 -> 3.0]
         http://code.google.com/p/google-guice/
    Gradle release-candidate updates:
    [ERROR] [release channel: current] Unable to process url: https://services.gradle.org/versions/current
     - Gradle: [3.0:dependencyUpdates FAILED
    FAILURE: Build failed with an exception.
    * What went wrong:
    Execution failed for task ':dependencyUpdates'.
    > '' is not a valid Gradle version string (examples: '1.0', '1.0-rc-1')
    * Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
    BUILD FAILED
    Total time: 15.883 secs
        at org.gradle.testkit.runner.internal.DefaultGradleRunner$1.execute(DefaultGradleRunner.java:237)
        at org.gradle.testkit.runner.internal.DefaultGradleRunner$1.execute(DefaultGradleRunner.java:234)
        at org.gradle.testkit.runner.internal.DefaultGradleRunner.run(DefaultGradleRunner.java:298)
        at org.gradle.testkit.runner.internal.DefaultGradleRunner.build(DefaultGradleRunner.java:234)
        at com.github.benmanes.gradle.versions.DifferentGradleVersionsSpec.dependencyUpdates task uses specified release channel with Gradle #gradleReleaseChannel(DifferentGradleVersionsSpec.groovy:130)
54 tests completed, 2 failed
> Task :test FAILED

@ben-manes
Copy link
Owner

This might be a different failure.. need to investigate...

@dje1990
Copy link
Contributor

dje1990 commented Aug 10, 2019

Hi @ben-manes
Is this still an issue? I see you pushed version 0.22.0 on the 9th August?

@ben-manes
Copy link
Owner

sorry, it's all perfect. thank you.

It does seem that the tests got flaky somehow, maybe due to TravisCI changing Linux versions. I had to re-run the CI build twice before it released, with different errors each time. So that is concerning, but each looked like they were flaky due to making external calls. Not worth worrying about for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants