Skip to content

Commit

Permalink
Merge branch 'master' into sessions-nine
Browse files Browse the repository at this point in the history
  • Loading branch information
mrober committed Oct 23, 2023
2 parents ec89794 + 1ec75d4 commit 2ac4229
Show file tree
Hide file tree
Showing 28 changed files with 106 additions and 54 deletions.
44 changes: 28 additions & 16 deletions .github/workflows/ci_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -121,22 +121,6 @@ jobs:
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@v0
# create composite indexes with Terraform
- name: Setup Terraform
if: contains(matrix.module, ':firebase-firestore')
uses: hashicorp/setup-terraform@v2
- name: Terraform Init
if: contains(matrix.module, ':firebase-firestore')
run: |
cd firebase-firestore
terraform init
continue-on-error: true
- name: Terraform Apply
if: github.event_name == 'pull_request' && contains(matrix.module, ':firebase-firestore')
run: |
cd firebase-firestore
terraform apply -var-file=../google-services.json -auto-approve
continue-on-error: true
- name: ${{ matrix.module }} Integ Tests
env:
FIREBASE_CI: 1
Expand Down Expand Up @@ -178,6 +162,34 @@ jobs:
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@v0

# create composite indexes with Terraform
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
- name: Terraform Init
run: |
cd firebase-firestore
terraform init
continue-on-error: true
- name: Terraform Apply
if: github.event_name == 'pull_request'
run: |
cd firebase-firestore
# Define a temporary file, redirect both stdout and stderr to the file
output_file=$(mktemp)
if ! terraform apply -var-file=../google-services.json -auto-approve > "$output_file" 2>&1 ; then
cat "$output_file"
if cat "$output_file" | grep -q "index already exists"; then
echo "==================================================================================="
echo -e "\e[93m\e[1mTerraform apply failed due to index already exists; We can safely ignore this error.\e[0m"
echo "==================================================================================="
fi
exit 1
fi
rm -f "$output_file"
continue-on-error: true

- name: Firestore Named DB Integ Tests
env:
FIREBASE_CI: 1
Expand Down
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-debug-testing/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-debug/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-interop/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck-playintegrity/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
2 changes: 1 addition & 1 deletion appcheck/firebase-appcheck/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.1
latestReleasedVersion=17.0.1
latestReleasedVersion=17.1.0
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,10 @@ class PostReleasePlugin : Plugin<Project> {
* is set to the current version of said module. After a release, this `version` should be bumped
* up to differentiate between code at HEAD, and the latest released version.
*
* Furthermore, this file may optionally contain a `latestReleasedVersion` variable (if the SDK
* has released). If this property is present, it should be updated to the related version that
* went out during the release.
*
* @see VersionBumpTask
*
* @param project the [Project] to register this task to
Expand All @@ -72,7 +76,9 @@ class PostReleasePlugin : Plugin<Project> {
* @param project the [Project] to register this task to
*/
fun registerMoveUnreleasedChangesTask(project: Project) =
project.tasks.register<MoveUnreleasedChangesTask>("moveUnreleasedChanges")
project.tasks.register<MoveUnreleasedChangesTask>("moveUnreleasedChanges") {
onlyIf("CHANGELOG.md file must be present") { project.file("CHANGELOG.md").exists() }
}

/**
* Registers the `updatePinnedDependencies` for the provided [Project]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,22 +24,29 @@ import org.gradle.api.tasks.TaskAction
import org.gradle.kotlin.dsl.provideDelegate

/**
* Bumps the `version` property of the specified [versionFile].
* Bumps the `version` property of the specified [versionFile], and sets the
* `latestReleasedVersion`.
*
* Primarily utilized as a post-release clean up task in which we bump the versions of released
* modules to be one patch higher than their currently released counterparts.
* modules to be one patch higher than their currently released counterparts, and update their
* latest released version.
*
* @see PostReleasePlugin
*
* @property versionFile A [File] that contains the `version` property. Defaults to the
* `gradle.properties` file at the project's root.
* @property releasedVersion A [ModuleVersion] of what to bump from. Defaults to the project
* version.
* @property newVersion A [ModuleVersion] of what to set the version to. Defaults to one patch
* higher than the existing version.
* higher than [releasedVersion]
*/
abstract class VersionBumpTask : DefaultTask() {
@get:[Optional InputFile]
abstract val versionFile: Property<File>

@get:[Optional Input]
abstract val releasedVersion: Property<ModuleVersion>

@get:[Optional Input]
abstract val newVersion: Property<ModuleVersion>

Expand All @@ -50,18 +57,23 @@ abstract class VersionBumpTask : DefaultTask() {
@TaskAction
fun build() {
versionFile.get().rewriteLines {
if (it.startsWith("version=")) "version=${newVersion.get()}" else it
when {
it.startsWith("version=") -> "version=${newVersion.get()}"
it.startsWith("latestReleasedVersion") -> "latestReleasedVersion=${releasedVersion.get()}"
else -> it
}
}
}

fun configure() {
versionFile.convention(project.file("gradle.properties"))
newVersion.convention(computeNewVersion())
releasedVersion.convention(computeReleasedVersion())
newVersion.convention(releasedVersion.map { it.bump() })
}

fun computeNewVersion(): ModuleVersion? {
fun computeReleasedVersion(): ModuleVersion? {
val version: String? by project

return version?.let { ModuleVersion.fromStringOrNull(it)?.bump() }
return version?.let { ModuleVersion.fromStringOrNull(it) }
}
}
2 changes: 1 addition & 1 deletion firebase-config/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,6 @@
#

version=21.5.1
latestReleasedVersion=21.4.1
latestReleasedVersion=21.5.0
android.enableUnitTestBinaryResources=true

2 changes: 1 addition & 1 deletion firebase-crashlytics-ndk/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=18.5.1
latestReleasedVersion=18.4.3
latestReleasedVersion=18.5.0
2 changes: 1 addition & 1 deletion firebase-crashlytics/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=18.5.1
latestReleasedVersion=18.4.3
latestReleasedVersion=18.5.0
2 changes: 1 addition & 1 deletion firebase-database/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

version=20.3.1
latestReleasedVersion=20.2.2
latestReleasedVersion=20.3.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-dynamic-links/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

version=21.2.1
latestReleasedVersion=21.1.0
latestReleasedVersion=21.2.0
android.enableUnitTestBinaryResources=true
22 changes: 22 additions & 0 deletions firebase-firestore/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,28 @@ Run:
./gradlew :firebase-firestore:deviceCheck
```

### Testing composite index query against production
#### Setting Up the Environment:
1. Create a `google-services.json` file in the root directory. This file should contain your target Firebase project's configuration.
2. If not already logged in, authenticate with your Google Cloud Platform (GCP) account using
`gcloud auth application-default login`. You can check your logged-in accounts by running
`gcloud auth list`.
3. Navigate to the `firebase-firestore` directory, create composite indexes by running:
```
terraform init
terraform apply -var-file=../google-services.json -auto-approve
```
Note: If the index creation encounters issues, such as concurrent operations, consider running the
index creation process again. Error messages indicating that indexes have already been created can
be safely disregarded.

#### Adding new composite index query tests
1. To create a new composite index for local development, click on the provided link in the test
error message, which will direct you to the Firebase Console.
2. Add the newly created composite index to the `firestore_index_config.tf` file. The "__name__"
field is not required to be explicitly added to the file, as the index creation will auto complete
it on behalf.

## Code Formatting

Run below to format Java code:
Expand Down
2 changes: 1 addition & 1 deletion firebase-firestore/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=24.9.1
latestReleasedVersion=24.8.1
latestReleasedVersion=24.9.0
Original file line number Diff line number Diff line change
Expand Up @@ -30,14 +30,13 @@
* Guidance for Creating Tests:
* ----------------------------
* When creating tests that require composite indexes, it is recommended to utilize the
* "CompositeIndexTestHelper" class. This utility class provides methods for creating
* and setting test documents and running queries with ease, ensuring proper data
* isolation and query construction.
* "CompositeIndexTestHelper" class. This utility class provides methods for creating and setting
* test documents and running queries with ease, ensuring proper data isolation and query
* construction.
*
* Please remember to update the main index configuration file (firestore_index_config.tf)
* with any new composite indexes needed for the tests. This ensures synchronization with
* other testing environments, including CI. You can generate the required index link by
* clicking on the Firebase console link in the error message while running tests locally.
* To get started, please refer to the instructions provided in the README file. This will guide
* you through setting up your local testing environment and updating the Terraform configuration
* with any new composite indexes required for your testing scenarios.
*/
@RunWith(AndroidJUnit4.class)
public class CompositeIndexQueryTest {
Expand Down
2 changes: 1 addition & 1 deletion firebase-functions/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=20.4.1
latestReleasedVersion=20.3.1
latestReleasedVersion=20.4.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-inappmessaging-display/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=20.4.1
latestReleasedVersion=20.3.5
latestReleasedVersion=20.4.0
2 changes: 1 addition & 1 deletion firebase-inappmessaging/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=20.4.1
latestReleasedVersion=20.3.5
latestReleasedVersion=20.4.0
1 change: 1 addition & 0 deletions firebase-installations-interop/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# Unreleased
* [changed] Release to align with ktx changes


4 changes: 2 additions & 2 deletions firebase-installations-interop/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.1.2
latestReleasedVersion=17.1.0
version=17.2.0
latestReleasedVersion=17.1.1
2 changes: 1 addition & 1 deletion firebase-installations/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=17.2.1
latestReleasedVersion=17.1.4
latestReleasedVersion=17.2.0
2 changes: 1 addition & 1 deletion firebase-messaging-directboot/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=23.3.1
latestReleasedVersion=23.2.1
latestReleasedVersion=23.3.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-messaging/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
version=23.3.1
latestReleasedVersion=23.2.1
latestReleasedVersion=23.3.0
android.enableUnitTestBinaryResources=true
2 changes: 1 addition & 1 deletion firebase-ml-modeldownloader/gradle.properties
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version=24.2.1
latestReleasedVersion=24.1.3
latestReleasedVersion=24.2.0
2 changes: 1 addition & 1 deletion firebase-perf/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@
#

version=20.5.1
latestReleasedVersion=20.4.1
latestReleasedVersion=20.5.0
android.enableUnitTestBinaryResources=true

2 changes: 1 addition & 1 deletion firebase-sessions/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,4 @@
# limitations under the License.

version=1.1.1
latestReleasedVersion=1.0.2
latestReleasedVersion=1.1.0
2 changes: 1 addition & 1 deletion firebase-storage/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -13,5 +13,5 @@
# limitations under the License.

version=20.3.1
latestReleasedVersion=20.2.1
latestReleasedVersion=20.3.0
android.enableUnitTestBinaryResources=true

0 comments on commit 2ac4229

Please sign in to comment.