Skip to content

Commit d26034c

Browse files
authored
Merge 6cf560d into e461cb7
2 parents e461cb7 + 6cf560d commit d26034c

File tree

4 files changed

+107
-6
lines changed

4 files changed

+107
-6
lines changed

.github/workflows/health-metrics.yml

Lines changed: 60 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,27 @@
11
name: Health Metrics
22

3-
on: [ pull_request, push ]
3+
concurrency:
4+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
5+
cancel-in-progress: true
6+
7+
on:
8+
pull_request:
9+
push:
10+
branches:
11+
- master
12+
# add other feature branches here
13+
# TODO(yifany): support workflow_dispatch for metric tests (or only for startup time test)
414

515
env:
616
GITHUB_PULL_REQUEST_NUMBER: ${{ github.event.pull_request.number }}
717

818
jobs:
919
coverage:
1020
name: Coverage
11-
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)
21+
if: |
22+
(github.event_name == 'push' && github.repository == 'firebase/firebase-android-sdk')
23+
|| (github.event_name == 'pull_request'
24+
&& github.event.pull_request.head.repo.full_name == github.repository)
1225
runs-on: ubuntu-latest
1326
steps:
1427
- uses: actions/checkout@v3
@@ -40,7 +53,10 @@ jobs:
4053

4154
size:
4255
name: Size
43-
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)
56+
if: |
57+
(github.event_name == 'push' && github.repository == 'firebase/firebase-android-sdk')
58+
|| (github.event_name == 'pull_request'
59+
&& github.event.pull_request.head.repo.full_name == github.repository)
4460
runs-on: ubuntu-latest
4561
steps:
4662
- uses: actions/checkout@v3
@@ -69,3 +85,44 @@ jobs:
6985
- name: Run size tests (post-submit)
7086
if: ${{ github.event_name == 'push' }}
7187
run: fireci binary_size
88+
89+
startup_time:
90+
name: Startup Time
91+
if: |
92+
(github.event_name == 'push' && github.repository == 'firebase/firebase-android-sdk')
93+
|| (github.event_name == 'pull_request'
94+
&& github.event.pull_request.head.repo.full_name == github.repository)
95+
runs-on: ubuntu-latest
96+
steps:
97+
- uses: actions/checkout@v3
98+
with:
99+
fetch-depth: 2
100+
submodules: true
101+
- name: Set up JDK 11
102+
uses: actions/setup-java@v2
103+
with:
104+
java-version: 11
105+
distribution: temurin
106+
cache: gradle
107+
- name: Set up Python 3.10
108+
uses: actions/setup-python@v4
109+
with:
110+
python-version: '3.10'
111+
- uses: google-github-actions/auth@v0
112+
with:
113+
credentials_json: '${{ secrets.GCP_SERVICE_ACCOUNT }}'
114+
- uses: google-github-actions/setup-gcloud@v0
115+
- name: Set up fireci
116+
run: pip3 install -e ci/fireci
117+
- name: Add google-services.json
118+
env:
119+
INTEG_TESTS_GOOGLE_SERVICES: ${{ secrets.INTEG_TESTS_GOOGLE_SERVICES }}
120+
BENCHMARK_APP_LOCATION: health-metrics/benchmark/template/app/google-services.json
121+
run: |
122+
echo $INTEG_TESTS_GOOGLE_SERVICES | base64 -d > $BENCHMARK_APP_LOCATION
123+
- name: Run startup-time tests (presubmit)
124+
if: ${{ github.event_name == 'pull_request' }}
125+
run: fireci macrobenchmark ci --pull-request
126+
- name: Run startup-time tests (post-submit)
127+
if: ${{ github.event_name == 'push' }}
128+
run: fireci macrobenchmark ci --push

ci/fireci/fireci/uploader.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@
1717
import os
1818
import requests
1919
import subprocess
20-
import urllib.parse
2120

2221

2322
_logger = logging.getLogger('fireci.uploader')
@@ -62,6 +61,7 @@ def _construct_request_endpoint_for_github_actions(metric_type):
6261

6362
return endpoint
6463

64+
6565
def _construct_request_endpoint_for_prow(metric_type):
6666
repo_owner = os.getenv('REPO_OWNER')
6767
repo_name = os.getenv('REPO_NAME')

ci/fireci/fireciplugins/macrobenchmark/commands.py

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,11 @@
1414

1515
import asyncio
1616
import click
17+
import json
1718

1819
from .analyze import analyzer
1920
from .run import runner
20-
from fireci import ci_command
21+
from fireci import ci_command, ci_utils, uploader
2122
from pathlib import Path
2223
from typing import List
2324

@@ -125,4 +126,46 @@ def analyze(
125126
output_dir,
126127
)
127128

129+
130+
@click.option(
131+
'--pull-request/--push',
132+
required=True,
133+
help='Whether the test is running for a pull request or a push event.'
134+
)
135+
@click.option(
136+
'--repeat',
137+
default=10,
138+
show_default=True,
139+
help='Number of times to repeat the test (for obtaining more data points).'
140+
)
141+
@ci_command(group=macrobenchmark)
142+
def ci(pull_request, repeat):
143+
"""Run tests in CI and upload results to the metric service."""
144+
145+
# TODO(yifany): run tests only for affected product in pull requests
146+
147+
output_path = Path("macrobenchmark-test-output.json")
148+
exception = None
149+
try:
150+
asyncio.run(runner.start(build_only=False, local=False, repeat=repeat, output=output_path))
151+
except Exception as e:
152+
exception = e
153+
154+
with open(output_path) as output_file:
155+
output = json.load(output_file)
156+
ftl_dirs = list(filter(lambda x: x['project'] == 'all-included', output))[0]['successful_runs']
157+
ftl_bucket_name = 'fireescape-benchmark-results'
158+
159+
log = ci_utils.ci_log_link()
160+
ftl_results = list(map(lambda x: {'bucket': ftl_bucket_name, 'dir': x}, ftl_dirs))
161+
startup_time_data = {'log': log, 'ftlResults': ftl_results}
162+
163+
if ftl_results:
164+
metric_service_url = 'https://api.firebase-sdk-health-metrics.com'
165+
access_token = ci_utils.gcloud_identity_token()
166+
uploader.post_report(startup_time_data, metric_service_url, access_token, 'startup-time')
167+
168+
if exception:
169+
raise exception
170+
128171
# TODO(yifany): support of command chaining

ci/fireci/fireciplugins/macrobenchmark/run/test_project.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,13 @@ async def run(index: int, run_id: str) -> str:
8383
args += ['--type', 'instrumentation']
8484
args += ['--app', app_apk_path]
8585
args += ['--test', test_apk_path]
86+
args += ['--device', 'model=oriole,version=32,locale=en,orientation=portrait']
8687
args += ['--device', 'model=redfin,version=30,locale=en,orientation=portrait']
8788
args += ['--directories-to-pull', '/sdcard/Download']
8889
args += ['--results-bucket', 'fireescape-benchmark-results']
8990
args += ['--results-dir', run_id]
9091
args += ['--environment-variables', ','.join(ftl_environment_variables)]
91-
args += ['--timeout', '30m']
92+
args += ['--timeout', '45m']
9293
args += ['--project', 'fireescape-c4819']
9394
await execute_async(executable, *args, logger=run_logger)
9495
return run_id

0 commit comments

Comments
 (0)