Skip to content

Ability to configure skipping build all #255

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
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ affectedModuleDetector {
ignoredFiles = [
".*\\.md", ".*\\.txt", ".*README"
]
buildAllWhenNoProjectsChanged = true // default is true
includeUncommitted = true
top = "HEAD"
customTasks = [
Expand All @@ -113,6 +114,7 @@ affectedModuleDetector {
- `logFolder`: A folder to output the log file in
- `specifiedBranch`: A branch to specify changes against. Must be used in combination with configuration `compareFrom = "SpecifiedBranchCommit"`
- `ignoredFiles`: A set of files that will be filtered out of the list of changed files retrieved by git.
- `buildAllWhenNoProjectsChanged`: If true, the plugin will build all projects when no projects are considered affected.
- `compareFrom`: A commit to compare the branch changes against. Can be either:
- PreviousCommit: compare against the previous commit
- ForkCommit: compare against the commit the branch was forked from
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,11 @@ class AffectedModuleConfiguration {
*/
var includeUncommitted: Boolean = true

/**
* If we should build all projects when no projects have changed
*/
var buildAllWhenNoProjectsChanged: Boolean = true

/**
* The top of the git log to use, only used when [includeUncommitted] is false
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -476,7 +476,7 @@ class AffectedModuleDetectorImpl constructor(
var buildAll = false

// Should only trigger if there are no changedFiles
if (changedProjects.isEmpty() && unknownFiles.isEmpty()) {
if (config.buildAllWhenNoProjectsChanged && changedProjects.isEmpty() && unknownFiles.isEmpty()) {
buildAll = true
}
logger?.info(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.dropbox.affectedmoduledetector

import com.google.common.truth.Truth.assertThat
import org.junit.Assert.assertFalse
import org.junit.Assert.assertTrue
import org.junit.Assert.fail
import org.junit.Before
import org.junit.Rule
Expand Down Expand Up @@ -324,4 +326,29 @@ class AffectedModuleConfigurationTest {

assert(actual.first().taskDescription == "Description of fake task")
}

@Test
fun `GIVEN AffectedModuleConfiguration WHEN buildAllWhenNoProjectsChanged THEN then default value is true`() {
// GIVEN
// config

// WHEN
val buildAllWhenNoProjectsChanged = config.buildAllWhenNoProjectsChanged

// THEN
assertTrue(buildAllWhenNoProjectsChanged)
}

@Test
fun `GIVEN AffectedModuleConfiguration WHEN buildAllWhenNoProjectsChanged is set to false THEN then value is false`() {
// GIVEN
val buildAll = false
config.buildAllWhenNoProjectsChanged = buildAll

// WHEN
val actual = config.buildAllWhenNoProjectsChanged

// THEN
assertFalse(actual)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,29 @@ class AffectedModuleDetectorImplTest {
)
}

@Test
fun noChangeSkipAll() {
val detector = AffectedModuleDetectorImpl(
rootProject = root,
logger = logger,
ignoreUnknownProjects = false,
projectSubset = ProjectSubset.ALL_AFFECTED_PROJECTS,
injectedGitClient = MockGitClient(
changedFiles = emptyList(),
tmpFolder = tmpFolder.root
),
config = affectedModuleConfiguration.also {
it.buildAllWhenNoProjectsChanged = false
}
)
MatcherAssert.assertThat(
detector.affectedProjects,
CoreMatchers.`is`(
emptySet()
)
)
}

@Test
fun changeInOneOnlyDependent() {
val detector = AffectedModuleDetectorImpl(
Expand Down