Skip to content

Commit 66ea30e

Browse files
feat: Skip tests for doc-only changes
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.
1 parent 87148c9 commit 66ea30e

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public AffectedProjectFinder(Project project, List<Pattern> ignorePaths) {
3939
this(project, changedPaths(project.getRootDir()), ignorePaths);
4040
}
4141

42+
private static final Set<String> DOC_EXTENSIONS = ImmutableSet.of("md", "txt", "html");
43+
4244
public AffectedProjectFinder(
4345
Project project, Set<String> changedPaths, List<Pattern> ignorePaths) {
4446
this.project = project;
@@ -53,9 +55,17 @@ public AffectedProjectFinder(
5355
}
5456
return true;
5557
})
58+
.filter(p -> !isDocFile(p))
5659
.collect(Collectors.toSet());
5760
}
5861

62+
private static boolean isDocFile(String path) {
63+
if (path.startsWith("docs/")) {
64+
return true;
65+
}
66+
return DOC_EXTENSIONS.stream().anyMatch(ext -> path.endsWith("." + ext));
67+
}
68+
5969
Set<Project> find() {
6070
Set<String> paths = new HashSet<>(changedPaths);
6171
Set<Project> projects = changedSubProjects(project, paths);

0 commit comments

Comments
 (0)