diff --git a/.github/workflows/firestore-nightly.yml b/.github/workflows/firestore-nightly.yml new file mode 100644 index 00000000000..e4261462f2f --- /dev/null +++ b/.github/workflows/firestore-nightly.yml @@ -0,0 +1,93 @@ +# Copyright 2023 Google LLC +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: firestore_nightly + +on: + pull_request: + workflow_dispatch: + schedule: + # Run every day at 2am (PST) - cron uses UTC times + - cron: '0 10 * * *' + +concurrency: + group: ${{ github.workflow }}-${{ github.head_ref || github.ref }} + cancel-in-progress: true + +jobs: + check: + runs-on: macos-12 + steps: + - uses: actions/checkout@v3 + + - uses: actions/setup-python@v4 + with: + python-version: 3.11 + + - name: Setup check + run: scripts/setup_check.sh + + - name: Run check + run: scripts/check.sh --test-only + + cmake-prod-db: + needs: check + + strategy: + matrix: + os: [macos-12] + databaseId: [(default)] + + env: + plist_secret: ${{ secrets.GHASecretsGPGPassphrase1 }} + MINT_PATH: ${{ github.workspace }}/mint + TARGET_DATABASE_ID: ${{ matrix.databaseId }} + + runs-on: ${{ matrix.os }} + steps: + - uses: actions/checkout@v3 + + - name: Prepare ccache + uses: actions/cache@v3 + with: + path: ${{ runner.temp }}/ccache + key: firestore-ccache-${{ matrix.databaseId }}-${{ runner.os }}-${{ github.sha }} + restore-keys: | + firestore-ccache-${{ matrix.databaseId }}-${{ runner.os }}- + + - name: Cache Mint packages + uses: actions/cache@v3 + with: + path: ${{ env.MINT_PATH }} + key: ${{ runner.os }}-mint-${{ hashFiles('**/Mintfile') }} + restore-keys: ${{ runner.os }}-mint- + + - uses: actions/setup-python@v4 + with: + python-version: '3.7' + + - name: Install Secret GoogleService-Info.plist + run: scripts/decrypt_gha_secret.sh scripts/gha-encrypted/firestore-nightly.plist.gpg \ + Firestore/Example/App/GoogleService-Info.plist "$plist_secret" + + # Skipping terraform index creation because we are not allowed to download SA key json. + + - name: Setup build + run: scripts/install_prereqs.sh Firestore ${{ runner.os }} cmake + + - name: Build and test + run: | + export CCACHE_DIR=${{ runner.temp }}/ccache + export TARGET_BACKEND=nightly + scripts/third_party/travis/retry.sh scripts/build.sh Firestore ${{ runner.os }} cmake diff --git a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm index 13fc8e960fb..1f8f28473fc 100644 --- a/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm +++ b/Firestore/Example/Tests/Integration/API/FIRServerTimestampTests.mm @@ -123,11 +123,18 @@ - (void)verifyTimestampsInSnapshot:(FIRDocumentSnapshot *)snapshot /** Verifies a snapshot containing _setData but with resolved server timestamps. */ - (void)verifySnapshotWithResolvedTimestamps:(FIRDocumentSnapshot *)snapshot { + // Tolerate up to 10 seconds of clock skew between client and server. + NSInteger tolerance = 10; + + // Somehow the skew is much worse in nightly + if ([self.db.settings.host isEqualToString:@"test-firestore.sandbox.googleapis.com"]) { + tolerance = 200; + } + XCTAssertTrue(snapshot.exists); FIRTimestamp *when = snapshot[@"when"]; XCTAssertTrue([when isKindOfClass:[FIRTimestamp class]]); - // Tolerate up to 10 seconds of clock skew between client and server. - XCTAssertEqualWithAccuracy(when.seconds, [FIRTimestamp timestamp].seconds, 10); + XCTAssertEqualWithAccuracy(when.seconds, [FIRTimestamp timestamp].seconds, tolerance); // Validate the rest of the document. XCTAssertEqualObjects(snapshot.data, [self expectedDataWithTimestamp:when]); diff --git a/scripts/gha-encrypted/firestore-nightly.plist.gpg b/scripts/gha-encrypted/firestore-nightly.plist.gpg new file mode 100644 index 00000000000..7c8645634c1 Binary files /dev/null and b/scripts/gha-encrypted/firestore-nightly.plist.gpg differ