Skip to content

Commit b5cc0d2

Browse files
committed
Merge branch 'master' into firebase-sessions
2 parents 6eb5bbe + d028b21 commit b5cc0d2

File tree

6 files changed

+89
-52
lines changed

6 files changed

+89
-52
lines changed

.github/workflows/create_releases.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ jobs:
3939
with:
4040
base: 'releases/${{ inputs.name }}'
4141
branch: 'releases/${{ inputs.name }}.release'
42-
add-paths: release.json,release_report.md
42+
add-paths: release.json,release_report.md,release_report.json
4343
title: '${{ inputs.name}} release'
4444
body: 'Auto-generated PR for release ${{ inputs.name}}'
4545
commit-message: 'Create release config for ${{ inputs.name }}'

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

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,10 @@ abstract class PublishingPlugin : Plugin<Project> {
373373
printReleaseConfig.convention(project.provideProperty("printOutput"))
374374

375375
releaseConfigFile.convention(project.layout.projectDirectory.file(RELEASE_CONFIG_FILE))
376-
releaseReportFile.convention(project.layout.projectDirectory.file(RELEASE_REPORT_FILE))
376+
releaseReportMdFile.convention(project.layout.projectDirectory.file(RELEASE_REPORT_MD_FILE))
377+
releaseReportJsonFile.convention(
378+
project.layout.projectDirectory.file(RELEASE_REPORT_JSON_FILE)
379+
)
377380
}
378381

379382
/**
@@ -441,7 +444,8 @@ abstract class PublishingPlugin : Plugin<Project> {
441444

442445
companion object {
443446
const val RELEASE_CONFIG_FILE = "release.json"
444-
const val RELEASE_REPORT_FILE = "release_report.md"
447+
const val RELEASE_REPORT_MD_FILE = "release_report.md"
448+
const val RELEASE_REPORT_JSON_FILE = "release_report.json"
445449

446450
const val GENERATE_BOM_TASK = "generateBom"
447451
const val VALIDATE_PROJECTS_TO_PUBLISH_TASK = "validateProjectsToPublish"

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

Lines changed: 82 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ package com.google.firebase.gradle.plugins
1515

1616
import com.google.common.collect.ImmutableList
1717
import java.io.File
18+
import kotlinx.serialization.Serializable
19+
import kotlinx.serialization.encodeToString
20+
import kotlinx.serialization.json.Json
1821
import org.eclipse.jgit.api.Git
1922
import org.eclipse.jgit.api.ListBranchCommand
2023
import org.eclipse.jgit.api.errors.GitAPIException
@@ -31,25 +34,85 @@ import org.gradle.api.tasks.OutputFile
3134
import org.gradle.api.tasks.TaskAction
3235
import org.gradle.kotlin.dsl.findByType
3336

37+
/**
38+
* Contains output data from the Release Generator, published as release_report.json
39+
*
40+
* @property changesByLibraryName contains libs which have opted into the release, and their changes
41+
* @property changedLibrariesWithNoChangelog contains libs not opted into the release, despite
42+
* having changes
43+
*/
44+
@Serializable
45+
data class ReleaseReport(
46+
val changesByLibraryName: Map<String, List<CommitDiff>>,
47+
val changedLibrariesWithNoChangelog: Set<String>
48+
) {
49+
companion object {
50+
val formatter = Json { prettyPrint = true }
51+
}
52+
53+
fun toFile(file: File) = file.also { it.writeText(formatter.encodeToString(this)) }
54+
55+
override fun toString() =
56+
"""
57+
|# Release Report
58+
|${
59+
changesByLibraryName.entries.joinToString("\n") {
60+
"""
61+
|## ${it.key}
62+
63+
|${it.value.joinToString("\n") { it.toString() }}
64+
""".trimMargin()
65+
}
66+
}
67+
|
68+
|## SDKs with changes, but no changelogs
69+
|${changedLibrariesWithNoChangelog.joinToString(" \n")}
70+
"""
71+
.trimMargin()
72+
}
73+
74+
@Serializable
3475
data class CommitDiff(
3576
val commitId: String,
77+
val prId: String,
3678
val author: String,
3779
val message: String,
80+
val commitLink: String,
81+
val prLink: String,
3882
) {
39-
constructor(
40-
revCommit: RevCommit
41-
) : this(revCommit.id.name, revCommit.authorIdent.name, revCommit.fullMessage) {}
83+
companion object {
84+
// This is a meant to capture the PR number from PR Titles
85+
// ex: "Fix a problem (#1234)" -> "1234"
86+
private val PR_ID_EXTRACTOR = Regex(".*\\(#(\\d+)\\).*")
87+
88+
public fun fromRevCommit(commit: RevCommit): CommitDiff {
89+
val commitId = commit.id.name
90+
val prId =
91+
PR_ID_EXTRACTOR.find(commit.fullMessage.split("\n").first())?.groupValues?.get(1) ?: ""
92+
return CommitDiff(
93+
commitId,
94+
prId,
95+
commit.authorIdent.name,
96+
commit.fullMessage,
97+
"https://github.com/firebase/firebase-android-sdk/commit/$commitId",
98+
"https://github.com/firebase/firebase-android-sdk/pull/$prId"
99+
)
100+
}
101+
}
42102

43103
override fun toString(): String =
44104
"""
45105
|* ${message.split("\n").first()}
46-
| https://github.com/firebase/firebase-android-sdk/commit/${commitId} [${author}]
106+
| [pr]($prLink) [commit]($commitLink) [$author]
47107
48108
"""
49109
.trimMargin()
50110
}
51111

52112
abstract class ReleaseGenerator : DefaultTask() {
113+
companion object {
114+
private val RELEASE_CHANGE_FILTER = "NO_RELEASE_CHANGE"
115+
}
53116

54117
@get:Input abstract val currentRelease: Property<String>
55118

@@ -59,7 +122,9 @@ abstract class ReleaseGenerator : DefaultTask() {
59122

60123
@get:OutputFile abstract val releaseConfigFile: RegularFileProperty
61124

62-
@get:OutputFile abstract val releaseReportFile: RegularFileProperty
125+
@get:OutputFile abstract val releaseReportMdFile: RegularFileProperty
126+
127+
@get:OutputFile abstract val releaseReportJsonFile: RegularFileProperty
63128

64129
@TaskAction
65130
@Throws(Exception::class)
@@ -81,34 +146,14 @@ abstract class ReleaseGenerator : DefaultTask() {
81146
val releaseConfig = ReleaseConfig(currentRelease.get(), libsToRelease.map { it.path })
82147
releaseConfig.toFile(releaseConfigFile.get().asFile)
83148

84-
val releaseReport = generateReleaseReport(changes, changedLibsWithNoChangelog)
149+
val releaseReport = ReleaseReport(changes, changedLibsWithNoChangelog)
85150
if (printReleaseConfig.orNull.toBoolean()) {
86-
project.logger.info(releaseReport)
151+
project.logger.info(releaseReport.toString())
87152
}
88-
writeReleaseReport(releaseReportFile.get().asFile, releaseReport)
153+
releaseReportMdFile.get().asFile.writeText(releaseReport.toString())
154+
releaseReportJsonFile.get().asFile.let { releaseReport.toFile(it) }
89155
}
90156

91-
private fun generateReleaseReport(
92-
changes: Map<String, List<CommitDiff>>,
93-
changedLibrariesWithNoChangelog: Set<String>
94-
) =
95-
"""
96-
|# Release Report
97-
|${
98-
changes.entries.joinToString("\n") {
99-
"""
100-
|## ${it.key}
101-
102-
|${it.value.joinToString("\n") { it.toString() }}
103-
""".trimMargin()
104-
}
105-
}
106-
|
107-
|## SDKs with changes, but no changelogs
108-
|${changedLibrariesWithNoChangelog.joinToString(" \n")}
109-
"""
110-
.trimMargin()
111-
112157
private fun getChangesForLibraries(
113158
repo: Git,
114159
branchRef: ObjectId,
@@ -179,7 +224,7 @@ abstract class ReleaseGenerator : DefaultTask() {
179224
.addRange(previousReleaseRef, currentReleaseRef)
180225
.setMaxCount(10)
181226
.call()
182-
.filter { !it.fullMessage.contains("NO_RELEASE_CHANGE") }
227+
.filter { !it.fullMessage.contains(RELEASE_CHANGE_FILTER) }
183228
.isNotEmpty()
184229

185230
private fun getDirChanges(
@@ -188,11 +233,13 @@ abstract class ReleaseGenerator : DefaultTask() {
188233
currentReleaseRef: ObjectId,
189234
directory: String
190235
) =
191-
repo.log().addPath(directory).addRange(previousReleaseRef, currentReleaseRef).call().map {
192-
CommitDiff(it)
193-
}
194-
195-
private fun writeReleaseReport(file: File, report: String) = file.writeText(report)
236+
repo
237+
.log()
238+
.addPath(directory)
239+
.addRange(previousReleaseRef, currentReleaseRef)
240+
.call()
241+
.filter { !it.fullMessage.contains(RELEASE_CHANGE_FILTER) }
242+
.map { CommitDiff.fromRevCommit(it) }
196243

197244
private fun getRelativeDir(project: Project) = project.path.substring(1).replace(':', '/')
198245
}

firebase-firestore/src/test/resources/json/existence_filter_spec_test.json

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
"describeName": "Existence Filters:",
44
"itName": "Bloom filter can process special characters in document name",
55
"tags": [
6-
"no-ios"
76
],
87
"config": {
98
"numClients": 1,
@@ -207,7 +206,6 @@
207206
"describeName": "Existence Filters:",
208207
"itName": "Bloom filter fills in default values for undefined padding and hashCount",
209208
"tags": [
210-
"no-ios"
211209
],
212210
"config": {
213211
"numClients": 1,
@@ -394,7 +392,6 @@
394392
"describeName": "Existence Filters:",
395393
"itName": "Bloom filter is handled at global snapshot",
396394
"tags": [
397-
"no-ios"
398395
],
399396
"config": {
400397
"numClients": 1,
@@ -633,7 +630,6 @@
633630
"describeName": "Existence Filters:",
634631
"itName": "Bloom filter limbo resolution is denied",
635632
"tags": [
636-
"no-ios"
637633
],
638634
"config": {
639635
"numClients": 1,
@@ -893,7 +889,6 @@
893889
"describeName": "Existence Filters:",
894890
"itName": "Bloom filter with large size works as expected",
895891
"tags": [
896-
"no-ios"
897892
],
898893
"config": {
899894
"numClients": 1,
@@ -6517,7 +6512,6 @@
65176512
"describeName": "Existence Filters:",
65186513
"itName": "Full re-query is skipped when bloom filter can identify documents deleted",
65196514
"tags": [
6520-
"no-ios"
65216515
],
65226516
"config": {
65236517
"numClients": 1,
@@ -6977,7 +6971,6 @@
69776971
"describeName": "Existence Filters:",
69786972
"itName": "Full re-query is triggered when bloom filter can not identify documents deleted",
69796973
"tags": [
6980-
"no-ios"
69816974
],
69826975
"config": {
69836976
"numClients": 1,
@@ -7190,7 +7183,6 @@
71907183
"describeName": "Existence Filters:",
71917184
"itName": "Full re-query is triggered when bloom filter hashCount is invalid",
71927185
"tags": [
7193-
"no-ios"
71947186
],
71957187
"config": {
71967188
"numClients": 1,
@@ -7379,7 +7371,6 @@
73797371
"describeName": "Existence Filters:",
73807372
"itName": "Full re-query is triggered when bloom filter is empty",
73817373
"tags": [
7382-
"no-ios"
73837374
],
73847375
"config": {
73857376
"numClients": 1,
@@ -7568,7 +7559,6 @@
75687559
"describeName": "Existence Filters:",
75697560
"itName": "Same documents can have different bloom filters",
75707561
"tags": [
7571-
"no-ios"
75727562
],
75737563
"config": {
75747564
"numClients": 1,

firebase-firestore/src/test/resources/json/limbo_spec_test.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7956,7 +7956,6 @@
79567956
"describeName": "Limbo Documents:",
79577957
"itName": "Limbo resolution throttling with bloom filter application",
79587958
"tags": [
7959-
"no-ios"
79607959
],
79617960
"config": {
79627961
"maxConcurrentLimboResolutions": 2,

firebase-firestore/src/test/resources/json/listen_spec_test.json

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3385,7 +3385,6 @@
33853385
"describeName": "Listens:",
33863386
"itName": "ExpectedCount in listen request should work after coming back online",
33873387
"tags": [
3388-
"no-ios"
33893388
],
33903389
"config": {
33913390
"numClients": 1,
@@ -12745,7 +12744,6 @@
1274512744
"describeName": "Listens:",
1274612745
"itName": "Resuming a query should specify expectedCount that does not include pending mutations",
1274712746
"tags": [
12748-
"no-ios"
1274912747
],
1275012748
"config": {
1275112749
"numClients": 1,
@@ -12947,7 +12945,6 @@
1294712945
"describeName": "Listens:",
1294812946
"itName": "Resuming a query should specify expectedCount when adding the target",
1294912947
"tags": [
12950-
"no-ios"
1295112948
],
1295212949
"config": {
1295312950
"numClients": 1,

0 commit comments

Comments
 (0)