-
Notifications
You must be signed in to change notification settings - Fork 582
177 lines (155 loc) · 5.47 KB
/
ci_tests.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
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@v4.1.1
with:
fetch-depth: 2
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4.1.0
with:
java-version: 17
distribution: temurin
cache: gradle
- 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
strategy:
fail-fast: false
matrix:
module: ${{ fromJSON(needs.determine_changed.outputs.modules) }}
steps:
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 2
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4.1.0
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Pull genai-common
if: matrix.module == ':firebase-vertexai'
run: |
git clone https://github.com/google-gemini/generative-ai-android.git
cd generative-ai-android
./gradlew :common:updateVersion common:publishToMavenLocal
cd ..
- name: Clone mock responses
if: matrix.module == ':firebase-vertexai'
run: |
firebase-vertexai/update_responses.sh
- name: Add google-services.json
env:
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
run: |
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
- name: ${{ matrix.module }} Unit Tests
env:
FIREBASE_CI: 1
run: |
./gradlew ${{matrix.module}}:check withErrorProne
- name: Compute upload file name
run: |
MODULE=${{matrix.module}}
echo "ARTIFACT_NAME=${MODULE//:/_}" >> $GITHUB_ENV
- name: Upload Test Results
uses: actions/upload-artifact@v4.3.3
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
if: always()
name: Unit Tests (matrix)
needs: unit_tests
steps:
- name: Check test matrix
if: needs.unit_tests.result != 'success'
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
steps:
- uses: actions/checkout@v4.1.1
with:
fetch-depth: 2
submodules: true
- name: Set up JDK 17
uses: actions/setup-java@v4.1.0
with:
java-version: 17
distribution: temurin
cache: gradle
- name: Add google-services.json
env:
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
run: |
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > google-services.json
- uses: google-github-actions/auth@v2
with:
credentials_json: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@v2
- 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 }}
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@v4.1.7
with:
path: artifacts
- name: Publish Test Results
uses: EnricoMi/publish-unit-test-result-action@82082dac68ad6a19d980f8ce817e108b9f496c2a
with:
files: "artifacts/**/*.xml"