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

Adjust Tooling API cross-version test ranges #29160

Merged
merged 1 commit into from
May 16, 2024

Conversation

donat
Copy link
Member

@donat donat commented May 15, 2024

The Gradle documentation defines concrete rules on the supported Tooling API version ranges. To summarize

  • A TAPI 8.9 client is compatible with Gradle versions [3.0, 10.0)
  • The oldest TAPI client guaranteed to work with Gradle 8.9 is version 7.0.

These rules are captured by the @ToolingApiVersion and @TargetGradleVersion annotations on the ToolingApiSpecification class.

At the same time, many cross-version tests overwrite the test coverage version ranges with a more permissive rule. This leads to confusion and unexpected test failures as we can observe here.

This change resolves the inconsistent version range declarations using the following rules:

  • If a test has a more permissive version range than the default then the annotation is removed
    • example: @ToolingApiVersion(">=5.4") is remove
  • If the lower bound of the version range is lower then the default minimum then the lower bound is bumped to the minimum
    • example: @TargetGradleVersion(">=2.6 <5.0") should be changed to @TargetGradleVersion(">=3.0 <5.0")
  • If the version range is completely outside of the supported range then the entire test is removed
    • example: @ToolingApiVersion(">=3.0 <4.0") or @TargetGradleVersion("=2.6")

@donat donat force-pushed the donat/fixit/tapi-test-ranges branch 2 times, most recently from 7cd8b9f to ed3501f Compare May 15, 2024 14:58
@donat donat marked this pull request as ready for review May 15, 2024 14:59
@donat donat requested review from a team as code owners May 15, 2024 14:59
@donat donat requested review from octylFractal and a team and removed request for a team and octylFractal May 15, 2024 14:59
@donat donat added the a:chore Minor issue without significant impact label May 15, 2024
Copy link
Member

@hegyibalint hegyibalint left a comment

Choose a reason for hiding this comment

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

This is really nice cleanup work!
If you want, I would value if you could make an attempt at maybe rephrasing the ToolingApiSpecification JavaDoc, so it has the:

  • supported version ranges
  • expresses when you need to use the annotations
    so we would have less misuse of the annotations.This is really nice cleanup work!
    If you want, I would value if you could make an attempt at maybe rephrasing the ToolingApiSpecification JavaDoc, so it has the:
  • supported version ranges
  • expresses when you need to use the annotations
    so we would have less misuse of the annotations.

Comment on lines -76 to -77
@ToolingApiVersion('<3.3 >=3.0')
@TargetGradleVersion('>=3.5')
Copy link
Member

Choose a reason for hiding this comment

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

❓Shouldn't this be in the accepted range?

Copy link
Member

Choose a reason for hiding this comment

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

Especially @TargetGradleVersion('>=3.5'), as it's higher than 3.0

Copy link
Member Author

@donat donat May 15, 2024

Choose a reason for hiding this comment

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

We should only test TAPI 7+ versions. This test covers tapi versions [3.0, 3.3). So it should be safe to delete.

Copy link
Member Author

Choose a reason for hiding this comment

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

Regarding your main comments, I don't want to duplicate information, but mentioning the rules in the docs would not hurt. I'll add something.

Copy link
Member

Choose a reason for hiding this comment

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

At least point to the document

Copy link
Member

Choose a reason for hiding this comment

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

We should only test TAPI 7+ versions.

But my main concern is about the Gradle version. Isn't the by-default @TargetGradleVersion('>=3.0')? Wouldn't that mean that we push the lower boundary of the Gradle version lower?

Copy link
Member Author

Choose a reason for hiding this comment

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

If I understand your question correctly, you are asking whether the annotations combine or overwrite each other. It's the latter. If the base class has @TargetGradleVersion('>=4.0 <=6.0') and a test method has @TargetGradleVersion('>=5.0 <=7.0'), the method will be execute with Gradle versions 5.0, 6.0, 7.0 (and with the minor releases in between, of course).

Copy link
Member Author

Choose a reason for hiding this comment

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

Added some documentation, ptal.

Copy link
Member

Choose a reason for hiding this comment

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

you are asking whether the annotations combine or overwrite each other

here we go, probably this is why I didn't understand the situation!

// versions of Gradle.
@Ignore
@TargetGradleVersion("=2.10")
def "can use plugin built with current Gradle with old version"() {
Copy link
Contributor

Choose a reason for hiding this comment

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

🎉

Copy link
Contributor

@reinsch82 reinsch82 left a comment

Choose a reason for hiding this comment

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

I think some of the annotation removals will lead to unintended executions

Copy link
Contributor

@reinsch82 reinsch82 left a comment

Choose a reason for hiding this comment

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

LGTM now.
Wasn't aware of the base class providing a different version for the TAPI

The Gradle documentation defines concrete rules on the supported Tooling API version ranges. To summarize

- A TAPI 8.9 client is compatible with Gradle versions [3.0, 10.0)
- The oldest TAPI client guaranteed to work with Gradle 8.9 is version 7.0.

These rules are captured by the @ToolingApiVersion and @TargetGradleVersion annotations on the ToolingApiSpecification class.

At the same time, many cross-version tests overwrite the test coverage version ranges with a more permissive rule. This leads to confusion and even flaky tests.

This change resolves the inconsistent version range declarations using the following rules:

- If a test has a more permissive version range than the default then the annotation is removed
  - example: @ToolingApiVersion(">=5.4") is remove
- If the lower bound of the version range is lower then the default minimum then the lower bound is bumped to the minimum
  - example: @TargetGradleVersion(">=2.6 <5.0") should be changed to @TargetGradleVersion(">=3.0 <5.0")
- If the version range is completely outside of the supported range then the entire test is removed
  - example: @ToolingApiVersion(">=3.0 <4.0") or @TargetGradleVersion("=2.6")
@donat donat force-pushed the donat/fixit/tapi-test-ranges branch from 8c8520e to d50ba8d Compare May 16, 2024 10:10
@donat
Copy link
Member Author

donat commented May 16, 2024

@bot-gradle test RFN

@gradle gradle deleted a comment from donat May 16, 2024
@bot-gradle
Copy link
Collaborator

I've triggered the following builds for you. Click here to see all build failures.

@gitstream-cm gitstream-cm bot removed the a:chore Minor issue without significant impact label May 16, 2024
@donat
Copy link
Member Author

donat commented May 16, 2024

@bot-gradle merge

@gradle gradle deleted a comment from donat May 16, 2024
@bot-gradle bot-gradle added this pull request to the merge queue May 16, 2024
@bot-gradle bot-gradle added this to the 8.9 RC1 milestone May 16, 2024
Merged via the queue into master with commit 3e893ac May 16, 2024
65 checks passed
@bot-gradle bot-gradle deleted the donat/fixit/tapi-test-ranges branch May 16, 2024 14:01
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

Successfully merging this pull request may close these issues.

None yet

5 participants