Skip to content

Commit 18adefe

Browse files
authored
Merge 1e4a34c into f133454
2 parents f133454 + 1e4a34c commit 18adefe

File tree

2 files changed

+87
-3
lines changed

2 files changed

+87
-3
lines changed

.github/workflows/diff-javadoc.yml

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
name: Diff Javadoc
2+
3+
on:
4+
pull_request:
5+
6+
jobs:
7+
build:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
pull-requests: write
11+
steps:
12+
- name: Make Dir
13+
run: mkdir ~/diff
14+
15+
- uses: actions/checkout@v3
16+
with:
17+
fetch-depth: 2
18+
submodules: true
19+
20+
- name: Set up JDK 11
21+
uses: actions/setup-java@v2
22+
with:
23+
java-version: 11
24+
distribution: temurin
25+
cache: gradle
26+
27+
- name: Changed Modules
28+
id: changed-modules
29+
run: |
30+
git diff --name-only HEAD~1 | xargs printf -- '--changed-git-paths %s\n' | xargs ./gradlew writeChangedProjects --output-file-path=modules.json --only-firebase-sdks
31+
echo "run=$(cat modules.json | sed "s/[]\"[]//g" | sed "s/,/\n/g" | xargs printf -- "%s:kotlinDoc ")" >> $GITHUB_OUTPUT
32+
33+
- name: Build
34+
run: ./gradlew ${{ steps.changed-modules.outputs.run }}
35+
36+
- name: Move original docs
37+
run: mv build ~/diff/modified
38+
39+
- uses: actions/checkout@v3
40+
with:
41+
ref: ${{ github.base_ref }}
42+
43+
- name: Build
44+
run: ./gradlew ${{ steps.changed-modules.outputs.run }}
45+
46+
- name: Move modified docs
47+
run: mv build ~/diff/original
48+
49+
- name: Diff docs
50+
run: >
51+
`# Recursively diff directories, including new files, git style, with 3 lines of context`
52+
diff -wEburN ~/diff/original ~/diff/modified
53+
`# Remove the first line and new file signifier of the output`
54+
| tail -n +2
55+
`# Replace the diff new file signifier with the end and start of a new codeblock`
56+
| sed "s/^diff.*$/\`\`\`\\n\`\`\`diff/g"
57+
`# Add a collapsable block, summary, and start the first code block on the first line`
58+
| sed "1s/^/<details>\\n<summary>Javadoc Changes:<\/summary>\\n\\n\`\`\`diff\\n/"
59+
`# Close the final code block and close the collapsable on the final line`
60+
| sed "$ s/$/\\n\`\`\`\\n<\/details>/"
61+
`# Write to diff.md for later`
62+
> diff.md
63+
64+
- name: Add comment
65+
uses: mshick/add-pr-comment@v2
66+
with:
67+
message-path: diff.md

buildSrc/src/main/java/com/google/firebase/gradle/plugins/ci/ChangedModulesTask.kt

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414

1515
package com.google.firebase.gradle.plugins.ci
1616

17+
import com.google.firebase.gradle.plugins.FirebaseLibraryExtension
1718
import com.google.gson.Gson
1819
import java.io.File
1920
import org.gradle.api.DefaultTask
@@ -22,16 +23,21 @@ import org.gradle.api.tasks.Input
2223
import org.gradle.api.tasks.OutputFile
2324
import org.gradle.api.tasks.TaskAction
2425
import org.gradle.api.tasks.options.Option
26+
import org.gradle.kotlin.dsl.findByType
2527

2628
abstract class ChangedModulesTask : DefaultTask() {
2729
@get:Input
28-
@set:Option(option = "changed-git-paths", description = "Hellos")
30+
@set:Option(option = "changed-git-paths", description = "The list of changed paths")
2931
abstract var changedGitPaths: List<String>
3032

3133
@get:Input
32-
@set:Option(option = "output-file-path", description = "Hello")
34+
@set:Option(option = "output-file-path", description = "The file to output json to")
3335
abstract var outputFilePath: String
3436

37+
@get:Input
38+
@set:Option(option = "only-firebase-sdks", description = "Only list Firebase SDKs")
39+
abstract var onlyFirebaseSDKs: Boolean
40+
3541
@get:OutputFile val outputFile by lazy { File(outputFilePath) }
3642

3743
init {
@@ -43,14 +49,25 @@ abstract class ChangedModulesTask : DefaultTask() {
4349
val projects =
4450
AffectedProjectFinder(project, changedGitPaths.toSet(), listOf())
4551
.find()
52+
.filter {
53+
val ext = it.extensions.findByType(FirebaseLibraryExtension::class.java)
54+
!onlyFirebaseSDKs || it.extensions.findByType<FirebaseLibraryExtension>() != null
55+
}
4656
.map { it.path }
4757
.toSet()
4858

4959
val result = project.rootProject.subprojects.associate { it.path to mutableSetOf<String>() }
5060
project.rootProject.subprojects.forEach { p ->
5161
p.configurations.forEach { c ->
5262
c.dependencies.filterIsInstance<ProjectDependency>().forEach {
53-
result[it.dependencyProject.path]?.add(p.path)
63+
if (
64+
!onlyFirebaseSDKs ||
65+
it.dependencyProject.extensions.findByType<FirebaseLibraryExtension>() != null
66+
) {
67+
if (!onlyFirebaseSDKs || p.extensions.findByType<FirebaseLibraryExtension>() != null) {
68+
result[it.dependencyProject.path]?.add(p.path)
69+
}
70+
}
5471
}
5572
}
5673
}

0 commit comments

Comments
 (0)