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

Remove dependency on mavenLocal() for functionalTests #6060

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

cortinico
Copy link
Member

Our tests should not depend on mavenLocal() at all.
The problem is that detekt-gradle-plugin is applying a dependency on detekt-cli using the version defined here:

const val DETEKT: String = "1.23.0-RC3"

So whenever that version gets bumped, test starts to fail unless you publishToMavenLocal as they'll try to find the next version on Maven Central, which won't be there.

That's also the reason why sometimes those PRs:

fail on CI as they can't find the newer artifact for detekt-cli on Maven Central yet.

This is blocking any automation of the release process essentially, and we should move away from it. See:

In this PR I'm moving away from using the project version to apply the detekt-cli to use the latest published stable. This allows those tests to rely just on mavenCentral().
The dependency will be updated by Renovate bot as we release stable versions (we're doing the same thing for the formatting of the detekt-gradle-plugin itself).

@detekt-ci
Copy link
Collaborator

detekt-ci commented Apr 30, 2023

Warnings
⚠️ It looks like this PR contains functional changes without a corresponding test.
⚠️ This PR is approved with no milestone set. If merged, it won't appear in the detekt release notes.

Generated by 🚫 dangerJS against 6943eba

@detekt-ci detekt-ci added build dependencies Pull requests that update a dependency file gradle-plugin labels Apr 30, 2023
@codecov
Copy link

codecov bot commented Apr 30, 2023

Codecov Report

Merging #6060 (6943eba) into main (1191dbf) will not change coverage.
The diff coverage is n/a.

@@            Coverage Diff            @@
##               main    #6060   +/-   ##
=========================================
  Coverage     84.86%   84.86%           
  Complexity     3975     3975           
=========================================
  Files           564      564           
  Lines         13300    13300           
  Branches       2325     2325           
=========================================
  Hits          11287    11287           
  Misses          870      870           
  Partials       1143     1143           

Copy link
Member

@schalkms schalkms left a comment

Choose a reason for hiding this comment

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

Glad that this pain point gets removed! 👍

@3flex
Copy link
Member

3flex commented May 1, 2023

Completely agree with the goal of removing mavenLocal usage, however this seems to make it more difficult to iterate on changes to CLI and the plugin and run functional tests.

When doing something like adding a new CLI flag and a complementary property in the Gradle plugin it seems like there's no way to run the functional tests with the updated CLI dependency?

Related (unmerged) PRs:

gradle/libs.versions.toml Outdated Show resolved Hide resolved
Co-authored-by: Matthew Haughton <3flex@users.noreply.github.com>
@cortinico
Copy link
Member Author

When doing something like adding a new CLI flag and a complementary property in the Gradle plugin it seems like there's no way to run the functional tests with the updated CLI dependency?

Yeah I agree, but I believe this is an improvement from the current status.
Even today, it's not possible to test the Gradle Plugin with the latest version of the CLI, unless you bump version and publishToMavenLocal.

If it helps, I can setup a separate CI job that bumps the version to 0.0.0 a local maven repo (I won't use mavenLocal() though) and runs functionalTest against it.
Still I would keep the current logic (i.e. relying on the latest release by default) as I want to be able to automate the release process, without having to publishToMavenLocal to merge the version bump.

@3flex
Copy link
Member

3flex commented May 1, 2023

That would help on CI but not local builds - unless that new task is attached to the functionalTest task as a dependency?

Maybe add that and then outline how one would update CLI & Gradle plugin together and run functional tests using that new task. As long as it's not necessary to update test code to get those tests working together when needed.

@cortinico
Copy link
Member Author

That would help on CI but not local builds - unless that new task is attached to the functionalTest task as a dependency?

I don't think we test this flow today with local build, though. As of today, local builds fetch detekt-cli from mavenCentral().

They will end up using mavenLocal() ONLY if you bump the version number here:

const val DETEKT: String = "1.23.0-RC3"

@3flex
Copy link
Member

3flex commented May 1, 2023

I recently found a Gradle feature that would fix that: https://docs.gradle.org/current/userguide/declaring_repositories.html#declaring_content_exclusively_found_in_one_repository

Using this means only Maven Local would be searched for the dependency. If the detekt CLI version is declared as a dynamic version then this would avoid the need to do any version bump as well. The only requirement then is pushing the required dependencies to Maven Local which can be easily setup with task dependencies.

Would this resolve your release issues as well?

@cortinico
Copy link
Member Author

I recently found a Gradle feature that would fix that: docs.gradle.org/current/userguide/declaring_repositories.html#declaring_content_exclusively_found_in_one_repository

Yup we could use this, yet still we will be forcing to depend on publishToMavenLocal() before we can run tests. Publishing to another maven local repo (being not ~/.m2) would probably be better but still suboptimal.

@cortinico cortinico marked this pull request as draft May 9, 2023 10:33
@cortinico
Copy link
Member Author

(holding this till after 1.23.0 stable)

@cortinico
Copy link
Member Author

@3flex what's the best course of action for this? I'd really love to get rid of this setup as it's making the release process extremely complicated

@detekt-ci
Copy link
Collaborator

This PR is stale because it has been open 90 days with no activity. Please comment or this will be closed in 7 days.

@3flex 3flex added never gets stale Mark Issues/PRs that should not be closed as they won't get stale and removed stale labels Oct 29, 2023
@BraisGabin
Copy link
Member

I vote to merge. If in the future we find better options we can revert this one and implement the better option but we have an issue with our release and this will improve that process.

@3flex 3flex marked this pull request as ready for review October 29, 2023 11:33
@3flex
Copy link
Member

3flex commented Oct 29, 2023

I'd like to take another look at this - I'm not a fan of adding code to the plugin that's only there to support functional tests.

Also, the issue raised in the PR description:

whenever that version gets bumped, test starts to fail unless you publishToMavenLocal as they'll try to find the next version on Maven Central, which won't be there.

Should have been solved by #6424.

Agree with the goal of not using Maven local repo at all, but I don't think this should be merged.

@cortinico
Copy link
Member Author

Should have been solved by #6424.

@3flex I'm unsure this solved it. It's easy to verify by just bumping the Versions.kt file and attempting to ./gradlew build without having run publishToMavenLocal before.

I'm up for any alternative that makes use not fallback to Maven Central or Maven Local for running our tests as this overcomplicates the release process

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build dependencies Pull requests that update a dependency file gradle-plugin never gets stale Mark Issues/PRs that should not be closed as they won't get stale
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants