|
| 1 | +name: Firestore CI Tests |
| 2 | +concurrency: |
| 3 | + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} |
| 4 | + cancel-in-progress: true |
| 5 | +on: |
| 6 | + pull_request: |
| 7 | + push: |
| 8 | + branches: |
| 9 | + - main |
| 10 | + |
| 11 | +jobs: |
| 12 | + determine_changed: |
| 13 | + name: "Determine changed modules" |
| 14 | + runs-on: ubuntu-latest |
| 15 | + if: (github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || github.event_name == 'pull_request' |
| 16 | + outputs: |
| 17 | + modules: ${{ steps.changed-modules.outputs.modules }} |
| 18 | + steps: |
| 19 | + |
| 20 | + with: |
| 21 | + fetch-depth: 2 |
| 22 | + submodules: true |
| 23 | + |
| 24 | + - name: Set up JDK 17 |
| 25 | + |
| 26 | + with: |
| 27 | + java-version: 17 |
| 28 | + distribution: temurin |
| 29 | + cache: gradle |
| 30 | + |
| 31 | + - id: changed-modules |
| 32 | + run: | |
| 33 | + git diff --name-only HEAD~1 | xargs printf -- '--changed-git-paths %s\n' | xargs ./gradlew writeChangedProjects --output-file-path=modules.json |
| 34 | + echo modules=$(cat modules.json) >> $GITHUB_OUTPUT |
| 35 | +
|
| 36 | + integ_tests: |
| 37 | + name: "System Tests" |
| 38 | + # only run on post submit or PRs not originating from forks. |
| 39 | + if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore') |
| 40 | + runs-on: ubuntu-latest |
| 41 | + needs: |
| 42 | + - determine_changed |
| 43 | + strategy: |
| 44 | + fail-fast: false |
| 45 | + |
| 46 | + steps: |
| 47 | + |
| 48 | + with: |
| 49 | + fetch-depth: 2 |
| 50 | + submodules: true |
| 51 | + |
| 52 | + - name: Enable KVM |
| 53 | + run: | |
| 54 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 55 | + sudo udevadm control --reload-rules |
| 56 | + sudo udevadm trigger --name-match=kvm |
| 57 | +
|
| 58 | + - name: Set up JDK 17 |
| 59 | + |
| 60 | + with: |
| 61 | + java-version: 17 |
| 62 | + distribution: temurin |
| 63 | + cache: gradle |
| 64 | + |
| 65 | + - name: Add google-services.json |
| 66 | + env: |
| 67 | + INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }} |
| 68 | + run: | |
| 69 | + echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json |
| 70 | + - uses: google-github-actions/auth@v2 |
| 71 | + with: |
| 72 | + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }} |
| 73 | + - uses: google-github-actions/setup-gcloud@v2 |
| 74 | + - name: firebase-firestore Integ Tests |
| 75 | + uses: reactivecircus/android-emulator-runner@v2 |
| 76 | + env: |
| 77 | + FIREBASE_CI: 1 |
| 78 | + FTL_RESULTS_BUCKET: android-ci |
| 79 | + FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}} |
| 80 | + FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }} |
| 81 | + with: |
| 82 | + api-level: 31 |
| 83 | + arch: x86_64 |
| 84 | + ram-size: 4096M |
| 85 | + heap-size: 4096M |
| 86 | + script: | |
| 87 | + adb logcat -v time > logcat.txt & |
| 88 | + ./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod" |
| 89 | + - name: Upload logs |
| 90 | + if: failure() |
| 91 | + |
| 92 | + with: |
| 93 | + name: logcat.txt |
| 94 | + path: logcat.txt |
| 95 | + retention-days: 7 |
| 96 | + if-no-files-found: ignore |
| 97 | + |
| 98 | + |
| 99 | + named_integ_tests: |
| 100 | + name: "System Tests With Named DB" |
| 101 | + runs-on: ubuntu-latest |
| 102 | + needs: |
| 103 | + - determine_changed |
| 104 | + # only run on post submit or PRs not originating from forks. |
| 105 | + if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore') |
| 106 | + strategy: |
| 107 | + fail-fast: false |
| 108 | + |
| 109 | + steps: |
| 110 | + |
| 111 | + with: |
| 112 | + fetch-depth: 2 |
| 113 | + submodules: true |
| 114 | + |
| 115 | + - name: Enable KVM |
| 116 | + run: | |
| 117 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 118 | + sudo udevadm control --reload-rules |
| 119 | + sudo udevadm trigger --name-match=kvm |
| 120 | +
|
| 121 | + - name: Set up JDK 17 |
| 122 | + |
| 123 | + with: |
| 124 | + java-version: 17 |
| 125 | + distribution: temurin |
| 126 | + cache: gradle |
| 127 | + |
| 128 | + - name: Add google-services.json |
| 129 | + env: |
| 130 | + INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }} |
| 131 | + run: | |
| 132 | + echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json |
| 133 | + - uses: google-github-actions/auth@v2 |
| 134 | + with: |
| 135 | + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }} |
| 136 | + - uses: google-github-actions/setup-gcloud@v2 |
| 137 | + |
| 138 | + # create composite indexes with Terraform |
| 139 | + - name: Setup Terraform |
| 140 | + uses: hashicorp/setup-terraform@v2 |
| 141 | + - name: Terraform Init |
| 142 | + run: | |
| 143 | + cd firebase-firestore |
| 144 | + terraform init |
| 145 | + continue-on-error: true |
| 146 | + - name: Terraform Apply |
| 147 | + if: github.event_name == 'pull_request' |
| 148 | + run: | |
| 149 | + cd firebase-firestore |
| 150 | +
|
| 151 | + # Define a temporary file, redirect both stdout and stderr to the file |
| 152 | + output_file=$(mktemp) |
| 153 | + if ! terraform apply -var-file=../google-services.json -auto-approve > "$output_file" 2>&1 ; then |
| 154 | + cat "$output_file" |
| 155 | + if cat "$output_file" | grep -q "index already exists"; then |
| 156 | + echo "===================================================================================" |
| 157 | + echo -e "\e[93m\e[1mTerraform apply failed due to index already exists; We can safely ignore this error.\e[0m" |
| 158 | + echo "===================================================================================" |
| 159 | + fi |
| 160 | + exit 1 |
| 161 | + fi |
| 162 | + rm -f "$output_file" |
| 163 | + continue-on-error: true |
| 164 | + |
| 165 | + - name: Firestore Named DB Integ Tests |
| 166 | + timeout-minutes: 20 |
| 167 | + uses: reactivecircus/android-emulator-runner@v2 |
| 168 | + env: |
| 169 | + FIREBASE_CI: 1 |
| 170 | + FTL_RESULTS_BUCKET: android-ci |
| 171 | + FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}} |
| 172 | + FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }} |
| 173 | + with: |
| 174 | + api-level: 31 |
| 175 | + arch: x86_64 |
| 176 | + ram-size: 4096M |
| 177 | + heap-size: 4096M |
| 178 | + script: | |
| 179 | + adb logcat -v time > logcat.txt & |
| 180 | + ./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="prod" |
| 181 | + - name: Upload logs |
| 182 | + if: failure() |
| 183 | + |
| 184 | + with: |
| 185 | + name: named-db-logcat.txt |
| 186 | + path: logcat.txt |
| 187 | + retention-days: 7 |
| 188 | + if-no-files-found: ignore |
| 189 | + |
| 190 | + firestore_nightly_integ_tests: |
| 191 | + name: "System Tests Against Nightly" |
| 192 | + runs-on: ubuntu-latest |
| 193 | + needs: |
| 194 | + - determine_changed |
| 195 | + # only run on post submit or PRs not originating from forks. |
| 196 | + if: ((github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)) && contains(fromJSON(needs.determine_changed.outputs.modules), ':firebase-firestore') |
| 197 | + strategy: |
| 198 | + fail-fast: false |
| 199 | + |
| 200 | + steps: |
| 201 | + |
| 202 | + with: |
| 203 | + fetch-depth: 2 |
| 204 | + submodules: true |
| 205 | + |
| 206 | + - name: Enable KVM |
| 207 | + run: | |
| 208 | + echo 'KERNEL=="kvm", GROUP="kvm", MODE="0666", OPTIONS+="static_node=kvm"' | sudo tee /etc/udev/rules.d/99-kvm4all.rules |
| 209 | + sudo udevadm control --reload-rules |
| 210 | + sudo udevadm trigger --name-match=kvm |
| 211 | +
|
| 212 | + - name: Set up JDK 17 |
| 213 | + |
| 214 | + with: |
| 215 | + java-version: 17 |
| 216 | + distribution: temurin |
| 217 | + cache: gradle |
| 218 | + |
| 219 | + - name: Add google-services.json |
| 220 | + env: |
| 221 | + INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.NIGHTLY_INTEG_TESTS_GOOGLE_SERVICES }} |
| 222 | + run: | |
| 223 | + echo $INTEG_TESTS_GOOGLE_SERVICES > google-services.json |
| 224 | + - uses: google-github-actions/auth@v2 |
| 225 | + with: |
| 226 | + credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }} |
| 227 | + - uses: google-github-actions/setup-gcloud@v2 |
| 228 | + |
| 229 | + - name: Firestore Nightly Integ Tests |
| 230 | + uses: reactivecircus/android-emulator-runner@v2 |
| 231 | + env: |
| 232 | + FIREBASE_CI: 1 |
| 233 | + FTL_RESULTS_BUCKET: android-ci |
| 234 | + FTL_RESULTS_DIR: ${{ github.event_name == 'pull_request' && format('pr-logs/pull/{0}/{1}/{2}/{3}_{4}/artifacts/', github.repository, github.event.pull_request.number, github.job, github.run_id, github.run_attempt) || format('logs/{0}/{1}_{2}/artifacts/', github.workflow, github.run_id, github.run_attempt)}} |
| 235 | + FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }} |
| 236 | + with: |
| 237 | + api-level: 31 |
| 238 | + arch: x86_64 |
| 239 | + ram-size: 4096M |
| 240 | + heap-size: 4096M |
| 241 | + script: | |
| 242 | + adb logcat -v time > logcat.txt & |
| 243 | + ./gradlew firebase-firestore:connectedCheck withErrorProne -PtargetBackend="nightly" |
| 244 | + - name: Upload logs |
| 245 | + if: failure() |
| 246 | + |
| 247 | + with: |
| 248 | + name: nightly-logcat.txt |
| 249 | + path: logcat.txt |
| 250 | + retention-days: 7 |
| 251 | + if-no-files-found: ignore |
| 252 | + |
| 253 | + check-required-tests: |
| 254 | + runs-on: ubuntu-latest |
| 255 | + if: always() |
| 256 | + name: Check all required Firestore tests results |
| 257 | + needs: [integ_tests, named_integ_tests] |
| 258 | + steps: |
| 259 | + - name: Check test matrix |
| 260 | + if: needs.integ_tests.result == 'failure' || needs.named_integ_tests.result == 'failure' |
| 261 | + run: exit 1 |
0 commit comments