Skip to content

Commit bbfcc2f

Browse files
feat: Skip tests for doc-only changes (#7306)
This change improves the CI process by skipping test runs for pull requests that only contain changes to documentation files. The logic is implemented in `AffectedProjectFinder.java`. It filters out files with common documentation extensions (`.md`, `.txt`, `.html`) and files in the `docs/` directory from the set of changed files. If all changed files in a pull request are documentation files, the set of affected projects will be empty, and no tests will be run. This avoids unnecessary test runs and saves CI resources. --------- Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>
1 parent f6feb92 commit bbfcc2f

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

plugins/src/main/java/com/google/firebase/gradle/plugins/ci/AffectedProjectFinder.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
import com.google.common.collect.ImmutableSet;
1818
import com.google.common.io.CharStreams;
19+
import com.google.common.io.Files;
1920
import java.io.File;
2021
import java.io.IOException;
2122
import java.io.InputStreamReader;
@@ -39,6 +40,8 @@ public AffectedProjectFinder(Project project, List<Pattern> ignorePaths) {
3940
this(project, changedPaths(project.getRootDir()), ignorePaths);
4041
}
4142

43+
private static final Set<String> DOC_EXTENSIONS = ImmutableSet.of("md", "txt", "html");
44+
4245
public AffectedProjectFinder(
4346
Project project, Set<String> changedPaths, List<Pattern> ignorePaths) {
4447
this.project = project;
@@ -53,9 +56,17 @@ public AffectedProjectFinder(
5356
}
5457
return true;
5558
})
59+
.filter(p -> !isDocFile(p))
5660
.collect(Collectors.toSet());
5761
}
5862

63+
private static boolean isDocFile(String path) {
64+
if (path.startsWith("docs/")) {
65+
return true;
66+
}
67+
return DOC_EXTENSIONS.contains(Files.getFileExtension(path));
68+
}
69+
5970
Set<Project> find() {
6071
Set<String> paths = new HashSet<>(changedPaths);
6172
Set<Project> projects = changedSubProjects(project, paths);

0 commit comments

Comments
 (0)