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

The plugin always detekt all modules as changes #8

Open
kirich1409 opened this issue Oct 23, 2020 · 8 comments
Open

The plugin always detekt all modules as changes #8

kirich1409 opened this issue Oct 23, 2020 · 8 comments

Comments

@kirich1409
Copy link

I've integrated the plugin and has problem in the next condition:

  • all changes are committed
  • current branch is develop
  • Configuration:
changeTracker {
    // List of tasks the plugin will need to create
    tasks = ['lintDebug','testDebugUnitTest', 'detekt']

    // List of modules that should always run
    whitelist = []

    // List of modules that should never run.
    blacklist = []

    // List of modules that will trigger the task for all modules
    reevaluate = []

    // Name of the branch that should compare to the current one to extract the diff
    // Branch can be specified dynamically via Gradle property 'branch'. E.g. -Pbranch=dev
    branch = "develop"
}

Task changedModules always return all modules as changed. What is incorrect?

@ismaeldivita
Copy link
Owner

ismaeldivita commented Oct 24, 2020

Hi 👋

Your setup looks fine

Not sure if this is your case, but, normally when you're doing the plugin setup for the first time, it will trigger the task for all modules since you're modifying the root build.gradle to install the plugin. If that's your problem, the next PRs should be fine, after you actually merge the changes on the develop.

You can have better logs to debug showing which exactly files changes, from which modules, and the impacted modules by adding -i to your command.

If that's not your problem, could you post a quick overview of your how project is setup and what a simple
git diff A...B is returning

@ismaeldivita
Copy link
Owner

Also, I took a look at detekt and it seems they only create the task on the project level, you can't run this task per module.

./gradlew app:detekt

FAILURE: Build failed with an exception.

* What went wrong:
Task 'detekt' not found in project ':app'. 

Trying to run detekt on a module will fail, not sure if they provide a configuration to run per module. Otherwise, this plugin will not work with detekt

@kirich1409
Copy link
Author

I've tried to disable Detekt at all and commit changes. Still all modules are changed (
Does the plugin have possibility to show reason why a module is changed ?

@ismaeldivita
Copy link
Owner

Does the plugin have possibility to show reason why a module is changed ?

Yes, run your command with -i and you should be able to see more logs about the changes

@kirich1409
Copy link
Author

The reason of changes is gradlew.bat, but I didn't change it

> Task :changedModules
Task :changedModules in app Starting
Caching disabled for task ':changedModules' because:
  Caching has not been enabled for the task
Task ':changedModules' is not up-to-date because:
  Task has not declared any outputs despite executing actions.

Changed Files
- gradlew.bat

Changed Projects
- root project 'Replika-android'

@ismaeldivita
Copy link
Owner

ismaeldivita commented Oct 30, 2020

The plugin will use git to extract changes.

Maybe you have a local outdated branch without this change on gradlew.bat. Try to specify the remote on your configuration.

Also, try to run a git diff develop...your_branch

@RBusarow
Copy link

@kirich1409 I just ran into this problem as well.

In my case, the issue was with line endings in gradlew.bat -- LF vs CRLF. A normal git diff ____ does not find changes, but JGit's .diff() does.

I was able to fix it by disabling autocrlf locally and on our CI servers.

You can just add this command to your CI pipelines before executing :changedModules.

$ git config core.autocrlf false

For instance, in a GitHub Actions yaml:

...
      - uses: actions/checkout@v2
        with:
          token: ${{ secrets.SERVICE_TOKEN }}

      # JGit will automatically convert LF files to CRLF before before performing a diff,
      # which makes gradlew.bat appear to be modified when it isn't.
      # This breaks change-tracker-plugin
      - name: disable git auto CRLF
        run: git config core.autocrlf false

      - name: test changed modules
        run: ./gradlew testDebugChangedModules
...

@ismaeldivita
Copy link
Owner

Thanks @RBusarow for find the problem.
I'll try to take a look and see if I can fix this on the plugin side

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