-
Notifications
You must be signed in to change notification settings - Fork 436
[K2] Run unit tests against the latest Analysis API #3552
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
Merged
vmishenev
merged 2 commits into
master
from
vmishenev/3540-Run_unit_tests_against_the_latest_analysis_api
Apr 5, 2024
Merged
Changes from 1 commit
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think, that it will better to override version directly in the version catalog instead of via configurations as it will be more idiomatic.
F.e like described in this issue: gradle/gradle#20070
So in
root
settings.gradle.kts we should have something like:(property name is TBD, just an example)
And then, no additional configuration is needed in a project.
It's possible to just have a
boolean
flag, but I believe that it will be better if we provide this version on CI (as you suggested in the comment above) as it will allow us easier to update to newer version, by just changing property on TeamCity instead of changing it in the repository.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought about this for some time.
I personally like both approaches (the current one and what Oleg proposed), both have advantages and disadvantages. Oleg's proposal seems to cover some additional use cases though: it will be possible to run the tests with any custom version of
kotlin-compiler-k2
, not just the hardcoded and latest-dev
one. This might come in useful when debugging or trying to narrow down the version in which a bug appeared (i.e test2.0.20-dev-10
, then2.0.20-dev-1
, then2.0.20-dev-5
, etc) without having to change the project's code - all done in CIThe proposed approach does have one disadvantage in my opinion: it's less obvious what is happening, we're overriding but a single specific version in the very common and unexpected place. In Vadim's approach the resolution logic is mostly isolated in
analysis-kotlin-symbols
, which is nice and easy to understand. But hopefully Gradle will provide some sort of a solution in gradle/gradle#20070, like-Pgradle.libs.kotlin-compiler-k2="2.0.20-dev-+"
, and this disadvantage won't be relevant anymore, and the resolution code will actually be easy to get rid of.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh, sorry, missed @vmishenev's comment above
I guess I would mostly vote for passing the version as a property (instead of the boolean flag), not necessarily as Oleg proposed :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TBH, for me, the variant with
configurations
in this PR is less obvious, because configurations are like for advanced usage and most of the time there is a solution which doesn't involve them and it's easier and more straightforward.F.e with logic implemented in current PR we override all dependencies (not only which use
kotlin-compiler-k2
version) to newer version. F.e in case we will havekotlin-compiler-k2=2.1.0
andkotlin-compiler-k2-override-version=2.2.0-dev-*
and some dependency with version2.1.0
we will update this dependency version and so receive a build failure. May be it will not happen, but when something like this happens, the issue is not obvious. It could be prevented of course, by checking group/module names of dependency.Instead when we dynamically modify version inside
Version Catalog
we are explicitly changing only one version and so only those dependencies which use it via Gradle-native way.Additionally, what if we would like to add one more property to configure testing with newer version of
kotlin-compiler
for descriptors (to check, that there is no regressions in analysis) or any other thing - I would expect to see all such version overrides in one place, not in separate projects.While for current use-case both variants are fine, IMO we should use version catalogs native solution instead of configuration based.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I agree. It can theoretically lead to false-positive builds.
By the way, I see the request on some local DSL to override a version
https://github.com/gradle/gradle/issues/26029
since e.g., another implementation is to override a version only for the test configuration. (but does not work for our integration tests)
I think we can try https://docs.gradle.org/current/userguide/platforms.html#sec:overwriting-catalog-versions
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree that it would be nicer to have the version defined in one place, and to allow it to be overridden with a specific version. Using the version catalog has some benefits (it's nice to have a version defined in one place, and it should be possible to override a version via a runtime property).
However, Gradle dependency management is tricky...
A version catalog doesn't always control the version. Example: if a project has a direct dependency on
x.y.z:foo:1.0.0
, and some other dependency has a transient dependency onx.y.z:foo:2.0.0
, then Gradle will select the highest version.So, while version catalogs are convenient, to control the version of dependencies we'd need to use constraints.
This is what I'd propose:
In DokkaBuild, add a
val kotlinAnalysisVersionOverride: Provider<String>
.And then, in the project, define constraints to control the versions. This can either use the overridden version (if present), or the default value in the version catalog.
For Dokka currently, the analysis dependencies are shadowed into the project's artifact, so I don't think that aligning the versions across multiple projects is required. If it is, and the constraints should be shared across subprojects, then the solution is to use the Java Platform Plugin to share the constraints.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That is interesting. Thank you for participating.
It seems overly strict.
I thought we should have an existing case to introduce a version constraint.
Currently, I can not imagine any case with Analysis API surface that breaks using the API.
@whyoleg Do you have an opinion on what approach we should implement?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
hm, I think that constraints is the direct replacement for what is proposed in current PR (using configurations), but with nicer API and more strict behaviour.
But, I'm not sure, that we will fall in the situation when for some reason, we would have transitive dependency on Analysis API of higher version :)
So we have 2 options:
I would say, that the main difference for our use case is locality of the change:
Both variants are fine for me. Still I'm more in favour of changing the version via version catalog. No specific arguments for this, mostly it just fills more clear and natural for me: if we want to override version, we override it in version catalog.
BTW, @atyrin setup to test Dokka over newer Kotlin versions also overrides version via version catalog, so setup will be similar and so more understandable (IMO).
On additional note: I think we agreed that we will provide newer
dev
version via property (not just boolean flag) and so it would be good to add to the Version Catalog nearkotlin-compiler-k2
that this version could be overridden by Gradle property.