Skip to content

Commit fa886c3

Browse files
committed
Merge branch 'main' into Instant
2 parents bad000d + d568e84 commit fa886c3

File tree

26 files changed

+1256
-252
lines changed

26 files changed

+1256
-252
lines changed
Lines changed: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
name: Data Connect Workflow Notifications
2+
description: Notify a GitHub Issue with the results of a workflow.
3+
4+
inputs:
5+
python-version:
6+
required: true
7+
default: "3.13"
8+
github-issue-for-scheduled-runs:
9+
required: true
10+
job-results-file:
11+
required: true
12+
13+
runs:
14+
using: "composite"
15+
steps:
16+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
17+
with:
18+
python-version: ${{ inputs.python-version }}
19+
20+
- run: pip install -r requirements.txt
21+
shell: bash
22+
working-directory: firebase-dataconnect/ci
23+
24+
- id: issue-id
25+
name: Determine GitHub Issue For Commenting
26+
working-directory: firebase-dataconnect/ci
27+
shell: bash
28+
run: |
29+
args=(
30+
python
31+
calculate_github_issue_for_commenting.py
32+
--issue-output-file=github_issue_number.txt
33+
--github-repository='${{ github.repository }}'
34+
--github-ref='${{ github.ref }}'
35+
--github-event-name='${{ github.event_name }}'
36+
--pr-body-github-issue-key=trksmnkncd_notification_issue
37+
--github-issue-for-scheduled-run='${{ inputs.github-issue-for-scheduled-runs }}'
38+
)
39+
echo "${args[*]}"
40+
"${args[@]}"
41+
42+
set -xv
43+
issue="$(cat github_issue_number.txt)"
44+
echo "issue=$issue" >> "$GITHUB_OUTPUT"
45+
46+
- name: Post Comment on GitHub Issue
47+
if: steps.issue-id.outputs.issue != ''
48+
working-directory: firebase-dataconnect/ci
49+
shell: bash
50+
run: |
51+
args=(
52+
python
53+
post_comment_for_job_results.py
54+
--github-issue='${{ steps.issue-id.outputs.issue }}'
55+
--github-workflow='${{ github.workflow }}'
56+
--github-repository='${{ github.repository }}'
57+
--github-ref='${{ github.ref }}'
58+
--github-event-name='${{ github.event_name }}'
59+
--github-sha='${{ github.sha }}'
60+
--github-repository-html-url='${{ github.event.repository.html_url }}'
61+
--github-run-id='${{ github.run_id }}'
62+
--github-run-number='${{ github.run_number }}'
63+
--github-run-attempt='${{ github.run_attempt }}'
64+
)
65+
66+
while read -r line; do
67+
args=("${args[@]}" "$line")
68+
done <'${{ inputs.job-results-file }}'
69+
70+
echo "${args[*]}"
71+
exec "${args[@]}"

.github/workflows/dataconnect.yml

Lines changed: 121 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ on:
99
firebaseToolsVersion:
1010
gradleInfoLog:
1111
type: boolean
12+
pythonVersion:
1213
pull_request:
1314
paths:
1415
- .github/workflows/dataconnect.yml
@@ -24,9 +25,10 @@ env:
2425
FDC_JAVA_VERSION: ${{ inputs.javaVersion || '17' }}
2526
FDC_ANDROID_EMULATOR_API_LEVEL: ${{ inputs.androidEmulatorApiLevel || '34' }}
2627
FDC_NODEJS_VERSION: ${{ inputs.nodeJsVersion || '20' }}
27-
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '13.29.1' }}
28+
FDC_FIREBASE_TOOLS_VERSION: ${{ inputs.firebaseToolsVersion || '14.2.0' }}
2829
FDC_FIREBASE_TOOLS_DIR: /tmp/firebase-tools
2930
FDC_FIREBASE_COMMAND: /tmp/firebase-tools/node_modules/.bin/firebase
31+
FDC_PYTHON_VERSION: ${{ inputs.pythonVersion || '3.13' }}
3032

3133
concurrency:
3234
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
@@ -74,7 +76,6 @@ jobs:
7476
npm install --fund=false --audit=false --save --save-exact firebase-tools@${{ env.FDC_FIREBASE_TOOLS_VERSION }}
7577
7678
- name: Restore Gradle Cache
77-
id: restore-gradle-cache
7879
uses: actions/cache/restore@d4323d4df104b026a6aa633fdb11d772146be0bf # 4.2.2
7980
if: github.event_name != 'schedule'
8081
with:
@@ -170,43 +171,28 @@ jobs:
170171
~/.android/adb*
171172
key: avd-cache-zhdsn586je-api${{ env.FDC_ANDROID_EMULATOR_API_LEVEL }}-${{ github.run_id }}
172173

173-
- name: Data Connect Emulator Start
174-
id: data-connect-emulator
174+
- name: Start Firebase Emulators
175175
run: |
176-
set -euo pipefail
177-
set -xv
178-
179-
echo 'emulator.postgresConnectionUrl=postgresql://postgres:[email protected]:5432?sslmode=disable' > firebase-dataconnect/dataconnect.local.properties
176+
set -xveuo pipefail
180177
181-
./gradlew \
182-
${{ (inputs.gradleInfoLog && '--info') || '' }} \
183-
:firebase-dataconnect:connectors:runDebugDataConnectEmulator \
184-
>firebase.emulator.dataconnect.log 2>&1 &
185-
186-
echo "FIREBASE_DATA_CONNECT_EMULATOR_PID=$!" >> "$GITHUB_ENV"
187-
188-
- name: Firebase Auth Emulator Start
189-
id: firebase-auth-emulator
190-
run: |
191-
set -euo pipefail
192-
set -xv
178+
# Use the same dataconnect binary as was used for code generation in gradle assemble
179+
DATACONNECT_EMULATOR_BINARY_PATH="$(find "$PWD"/firebase-dataconnect/connectors/build/intermediates/dataconnect/debug/executable -type f)"
180+
if [[ -z $DATACONNECT_EMULATOR_BINARY_PATH ]] ; then
181+
echo "INTERNAL ERROR v7kg2dfhbc: unable to find data connect binary" >&2
182+
exit 1
183+
fi
184+
export DATACONNECT_EMULATOR_BINARY_PATH
193185
186+
export FIREBASE_DATACONNECT_POSTGRESQL_STRING='postgresql://postgres:[email protected]:5432?sslmode=disable'
194187
cd firebase-dataconnect/emulator
195-
${{ env.FDC_FIREBASE_COMMAND }} emulators:start --only=auth >firebase.emulator.auth.log 2>&1 &
196-
197-
echo "FIREBASE_AUTH_EMULATOR_PID=$!" >> "$GITHUB_ENV"
188+
${{ env.FDC_FIREBASE_COMMAND }} emulators:start --only=auth,dataconnect >firebase.emulators.log 2>&1 &
198189
199-
- name: Logcat Log Capture Start
200-
id: logcat-capture
190+
- name: Start Logcat Capture
201191
continue-on-error: true
202192
run: |
203-
set -euo pipefail
204-
set -xv
205-
193+
set -xveuo pipefail
206194
"$ANDROID_HOME/platform-tools/adb" logcat >logcat.log 2>&1 &
207195
208-
echo "LOGCAT_PID=$!" >> "$GITHUB_ENV"
209-
210196
- name: Gradle connectedCheck
211197
id: connectedCheck
212198
uses: reactivecircus/android-emulator-runner@62dbb605bba737720e10b196cb4220d374026a6d #v2.33.0
@@ -256,30 +242,121 @@ jobs:
256242
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
257243
with:
258244
show-progress: false
245+
sparse-checkout: '.github/'
259246
- uses: docker://rhysd/actionlint:1.7.7
260247
with:
261248
args: -color /github/workspace/.github/workflows/dataconnect.yml
262249

250+
python-ci-unit-tests:
251+
continue-on-error: false
252+
runs-on: ubuntu-latest
253+
steps:
254+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
255+
with:
256+
show-progress: false
257+
sparse-checkout: 'firebase-dataconnect/ci/'
258+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
259+
with:
260+
python-version: ${{ env.FDC_PYTHON_VERSION }}
261+
- run: pip install -r firebase-dataconnect/ci/requirements.txt
262+
- name: pytest
263+
working-directory: firebase-dataconnect/ci
264+
run: pytest --verbose --full-trace --color=no --strict-config
265+
266+
python-ci-lint:
267+
continue-on-error: false
268+
runs-on: ubuntu-latest
269+
steps:
270+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
271+
with:
272+
show-progress: false
273+
sparse-checkout: 'firebase-dataconnect/ci/'
274+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
275+
with:
276+
python-version: ${{ env.FDC_PYTHON_VERSION }}
277+
- run: pip install -r firebase-dataconnect/ci/requirements.txt
278+
- name: ruff check
279+
working-directory: firebase-dataconnect/ci
280+
run: ruff check --diff --verbose --no-cache --output-format=github --exit-non-zero-on-fix
281+
282+
python-ci-format:
283+
continue-on-error: false
284+
runs-on: ubuntu-latest
285+
steps:
286+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
287+
with:
288+
show-progress: false
289+
sparse-checkout: 'firebase-dataconnect/ci/'
290+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
291+
with:
292+
python-version: ${{ env.FDC_PYTHON_VERSION }}
293+
- run: pip install -r firebase-dataconnect/ci/requirements.txt
294+
- name: ruff format
295+
working-directory: firebase-dataconnect/ci
296+
run: ruff format --diff --verbose --no-cache
297+
298+
python-ci-type-check:
299+
continue-on-error: false
300+
runs-on: ubuntu-latest
301+
steps:
302+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
303+
with:
304+
show-progress: false
305+
sparse-checkout: 'firebase-dataconnect/ci/'
306+
- uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0
307+
with:
308+
python-version: ${{ env.FDC_PYTHON_VERSION }}
309+
- run: pip install -r firebase-dataconnect/ci/requirements.txt
310+
- name: pyright
311+
working-directory: firebase-dataconnect/ci
312+
run: pyright --warnings --stats
313+
314+
# The "send-notifications" job adds a comment to GitHub Issue
315+
# https://github.com/firebase/firebase-android-sdk/issues/6857 with the results of the scheduled
316+
# nightly runs. Interested parties can then subscribe to that issue to be aprised of the outcome
317+
# of the nightly runs.
318+
#
319+
# When testing the comment-adding logic itself, you can add the line
320+
# trksmnkncd_notification_issue=6863
321+
# into the PR's description to instead post a comment to issue #6863, an issue specifically
322+
# created for testing, avoiding spamming the main issue to which others are subscribed.
263323
send-notifications:
264-
needs: [integration-test, actionlint-dataconnect-yml]
324+
needs:
325+
- 'integration-test'
326+
- 'actionlint-dataconnect-yml'
327+
- 'python-ci-unit-tests'
328+
- 'python-ci-lint'
329+
- 'python-ci-format'
330+
- 'python-ci-type-check'
265331
if: always()
266332
permissions:
267333
issues: write
268334
runs-on: ubuntu-latest
269335
steps:
270-
- name: Post Comment on Issue #6857
271-
if: github.event_name == 'schedule'
272-
env:
273-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
274-
run: |
275-
set -euo pipefail
336+
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
337+
with:
338+
show-progress: false
339+
sparse-checkout: |
340+
firebase-dataconnect/ci/
341+
.github/
276342
277-
cat >message.txt <<EOF
278-
Result of workflow ${{ github.workflow }} at ${{ github.ref }}: ${{ job.status }}
279-
${{ github.event.repository.html_url }}/actions/runs/${{ github.run_id }}
280-
job=${{ github.job }} run_id=${{ github.run_id }} run_number=${{ github.run_number }} run_attempt=${{ github.run_attempt }}
343+
- name: gh auth login
344+
run: echo '${{ secrets.GITHUB_TOKEN }}' | gh auth login --with-token
345+
346+
- name: Create Job Results File
347+
run: |
348+
set -xveuo pipefail
349+
cat >'${{ runner.temp }}/job_results.txt' <<EOF
350+
integration-test:${{ needs.integration-test.result }}
351+
actionlint-dataconnect-yml:${{ needs.actionlint-dataconnect-yml.result }}
352+
python-ci-unit-tests:${{ needs.python-ci-unit-tests.result }}
353+
python-ci-lint:${{ needs.python-ci-lint.result }}
354+
python-ci-format:${{ needs.python-ci-format.result }}
355+
python-ci-type-check:${{ needs.python-ci-type-check.result }}
281356
EOF
282357
283-
echo "Posting comment on GitHub Issue: https://github.com/firebase/firebase-android-sdk/issues/6857:"
284-
cat message.txt
285-
gh issue comment 6857 --body-file message.txt -R ${{ github.repository }}
358+
- uses: ./.github/actions/dataconnect-send-notifications
359+
with:
360+
python-version: ${{ env.FDC_PYTHON_VERSION }}
361+
github-issue-for-scheduled-runs: "6857"
362+
job-results-file: ${{ runner.temp }}/job_results.txt

0 commit comments

Comments
 (0)