Skip to content

Never cache integration and prod tests; always run them so that we do… #12008

Never cache integration and prod tests; always run them so that we do…

Never cache integration and prod tests; always run them so that we do… #12008

Workflow file for this run

name: CI Tests
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
on:
pull_request:
push:
branches:
- main
jobs:
determine_changed:
name: "Determine changed modules"
runs-on: ubuntu-22.04
if: (github.repository == 'Firebase/firebase-android-sdk' && github.event_name == 'push') || github.event_name == 'pull_request'
outputs:
modules: ${{ steps.changed-modules.outputs.modules }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 2
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: 17
distribution: temurin
# Do not update to version 6, context: https://blog.gradle.org/github-actions-for-gradle-v6
- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- id: changed-modules
run: |
git diff --name-only HEAD~1 | xargs printf -- '--changed-git-paths %s\n' | xargs ./gradlew writeChangedProjects --output-file-path=modules.json
echo modules=$(cat modules.json) >> $GITHUB_OUTPUT
unit_tests:
name: "Unit Tests"
runs-on: ubuntu-22.04
needs:
- determine_changed
if: ${{ needs.determine_changed.outputs.modules != '[]' }}
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 2
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: 17
distribution: temurin
# Do not update to version 6, context: https://blog.gradle.org/github-actions-for-gradle-v6
- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- name: Clone ai mock responses
if: matrix.module == ':ai-logic:firebase-ai'
run: ai-logic/firebase-ai/update_responses.sh
- name: Add local.properties (for FAD gradle tests)
env:
INTEG_TESTS_FAD_LOCAL_PROPERTIES: ${{ secrets.INTEG_TESTS_FAD_LOCAL_PROPERTIES }}
if: env.INTEG_TESTS_FAD_LOCAL_PROPERTIES != '' && env.INTEG_TESTS_FAD_LOCAL_PROPERTIES != 'null'
run: |
echo $INTEG_TESTS_FAD_LOCAL_PROPERTIES | base64 -d > local.properties
- name: Add FAD service-credentials.json
env:
INTEG_TESTS_FAD_SERVICE_CREDENTIALS: ${{ secrets.INTEG_TESTS_FAD_SERVICE_CREDENTIALS }}
if: env.INTEG_TESTS_FAD_SERVICE_CREDENTIALS != '' && env.INTEG_TESTS_FAD_SERVICE_CREDENTIALS != 'null'
run: |
echo $INTEG_TESTS_FAD_SERVICE_CREDENTIALS | base64 -d > firebase-appdistribution-gradle/service-credentials.json
- name: Add google-services.json
env:
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
if: env.INTEG_TESTS_GOOGLE_SERVICES != '' && env.INTEG_TESTS_GOOGLE_SERVICES != 'null'
run: |
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
- name: ${{ matrix.module }} Unit Tests
env:
FIREBASE_CI: 1
MATRIX_MODULE: ${{matrix.module}}
run: |
./gradlew ${MATRIX_MODULE}:check withErrorProne
- name: Compute upload file name
if: always()
run: |
MODULE=${MATRIX_MODULE}
echo "ARTIFACT_NAME=${MODULE//:/_}" >> $GITHUB_ENV
env:
MATRIX_MODULE: ${{matrix.module}}
- name: Upload Test Results
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
if: always()
with:
name: unit-test-result-${{env.ARTIFACT_NAME}}
path: "**/build/test-results/**/*.xml"
retention-days: 7
if-no-files-found: ignore
# A job that fails if any job in the unit_tests matrix fails,
# to be used as a required check for merging.
check_all:
runs-on: ubuntu-22.04
name: Unit Tests (matrix)
needs: unit_tests
if: ${{ failure() }}
steps:
- name: Check test matrix results
run: exit 1
integ_tests:
name: "Instrumentation Tests"
# only run on post submit or PRs not originating from forks.
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)
runs-on: ubuntu-22.04
needs:
- determine_changed
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}
exclude:
- module: :firebase-firestore
- module: :firebase-functions:ktx
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
fetch-depth: 2
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@be666c2fcd27ec809703dec50e508c2fdc7f6654 # v5.2.0
with:
java-version: 17
distribution: temurin
# Do not update to version 6, context: https://blog.gradle.org/github-actions-for-gradle-v6
- name: Setup Gradle
uses: gradle/actions/setup-gradle@0723195856401067f7a2779048b490ace7a47d7c # v5.0.2
- name: Add google-services.json
env:
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
if: env.INTEG_TESTS_GOOGLE_SERVICES != '' && env.INTEG_TESTS_GOOGLE_SERVICES != 'null'
run: |
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
- uses: google-github-actions/auth@7c6bc770dae815cd3e89ee6cdf493a5fab2cc093 # v3.0.0
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@aa5489c8933f4cc7a4f7d45035b3b1440c9c10db # v3.0.1
- name: ${{ matrix.module }} Integ Tests
env:
FIREBASE_CI: 1
FTL_RESULTS_BUCKET: android-ci
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)}}
FIREBASE_APP_CHECK_DEBUG_SECRET: ${{ secrets.FIREBASE_APP_CHECK_DEBUG_SECRET }}
MATRIX_MODULE: ${{matrix.module}}
run: |
./gradlew ${MATRIX_MODULE}:deviceCheck withErrorProne -PtargetBackend="prod"
publish-test-results:
name: "Publish Tests Results"
needs:
- unit_tests
runs-on: ubuntu-22.04
permissions:
checks: write
# only needed unless run with comment_mode: off
pull-requests: write
if: always()
steps:
- name: Download Artifacts
uses: actions/download-artifact@95815c38cf2ff2164869cbab79da8d1f422bc89e # v4.2.1
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@170bf24d20d201b842d7a52403b73ed297e6645b # v2.18.0
if: always()
with:
files: "artifacts/**/*.xml"
comment_mode: off
compare_to_earlier_commit: false