Skip to content

Commit 00d8c72

Browse files
authored
Add support of macrobenchmark result analysis in fireci (#4285)
1 parent 31ab674 commit 00d8c72

File tree

23 files changed

+1070
-404
lines changed

23 files changed

+1070
-404
lines changed

.github/workflows/copyright-check.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ jobs:
1111
runs-on: ubuntu-22.04
1212
steps:
1313
- uses: actions/[email protected]
14-
- uses: actions/setup-python@v2
14+
- uses: actions/setup-python@v4
1515
with:
16-
python-version: '3.9'
16+
python-version: '3.10'
1717
- run: |
1818
pip install -e "ci/fireci"
1919
- run: |

.github/workflows/fireci.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,9 +16,9 @@ jobs:
1616
runs-on: ubuntu-22.04
1717
steps:
1818
- uses: actions/[email protected]
19-
- uses: actions/setup-python@v2
19+
- uses: actions/setup-python@v4
2020
with:
21-
python-version: '3.9'
21+
python-version: '3.10'
2222
- run: |
2323
pip install -e "ci/fireci[test]"
2424
- run: |

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,5 @@ firebase-crashlytics-ndk/.externalNativeBuild/
1111
firebase-crashlytics-ndk/.cxx/
1212
smoke-test-logs/
1313
smoke-tests/build-debug-headGit-smoke-test
14-
smoke-tests/firehorn.log
14+
smoke-tests/firehorn.log
15+
macrobenchmark-output.json

ci/fireci/fireci/internal.py

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,14 @@
1313
# limitations under the License.
1414

1515
import click
16-
import contextlib
1716
import functools
1817
import glob
1918
import itertools
2019
import logging
2120
import os
2221
import shutil
2322

23+
from contextlib import contextmanager, nullcontext
2424

2525
_logger = logging.getLogger('fireci')
2626

@@ -30,7 +30,7 @@ def _ensure_dir(directory):
3030
os.makedirs(directory)
3131

3232

33-
@contextlib.contextmanager
33+
@contextmanager
3434
def _artifact_handler(target_directory, artifact_patterns):
3535
_logger.debug(
3636
'Artifacts will be searched for in directories matching {} patterns and placed in {}'
@@ -45,7 +45,7 @@ def _artifact_handler(target_directory, artifact_patterns):
4545
target_name = os.path.join(target_directory, "_".join(path.split('/')))
4646
_logger.debug('Copying artifact {} to {}'.format(path, target_name))
4747
if os.path.isdir(path):
48-
shutil.copytree(path, target_name)
48+
shutil.copytree(path, target_name, dirs_exist_ok=True)
4949
else:
5050
shutil.copyfile(path, target_name)
5151

@@ -68,8 +68,8 @@ class _CommonOptions:
6868
'--artifact-patterns',
6969
default=('**/build/test-results', '**/build/reports'),
7070
help=
71-
'Shell-style artifact patterns that are copied into `artifact-target-dir`.'\
72-
'Can be specified multiple times.',
71+
'Shell-style artifact patterns that are copied into `artifact-target-dir`. '
72+
'Can be specified multiple times.',
7373
multiple=True,
7474
type=str,
7575
)
@@ -83,30 +83,34 @@ def main(options, **kwargs):
8383
setattr(options, k, v)
8484

8585

86-
def ci_command(name=None):
86+
def ci_command(name=None, cls=click.Command, group=main):
8787
"""Decorator to use for CI commands.
8888
8989
The differences from the standard @click.command are:
9090
9191
* Allows configuration of artifacts that are uploaded for later viewing in CI.
92-
* Registers the command automatically
92+
* Registers the command automatically.
9393
94-
:param name: Optional name of the task. Defaults to the function name that is decorated with
95-
this decorator.
94+
:param name: Optional name of the task. Defaults to the function name that is decorated with this decorator.
95+
:param cls: Specifies whether the func is a command or a command group. Defaults to `click.Command`.
96+
:param group: Specifies the group the command belongs to. Defaults to the `main` command group.
9697
"""
9798

9899
def ci_command(f):
99100
actual_name = f.__name__ if name is None else name
100101

101-
@main.command(name=actual_name, help=f.__doc__)
102+
@click.command(name=actual_name, cls=cls, help=f.__doc__)
102103
@_pass_options
103104
@click.pass_context
104105
def new_func(ctx, options, *args, **kwargs):
105106
with _artifact_handler(
106107
options.artifact_target_dir,
107-
options.artifact_patterns):
108+
options.artifact_patterns,
109+
) if cls is click.Command else nullcontext():
108110
return ctx.invoke(f, *args, **kwargs)
109111

112+
group.add_command(new_func)
113+
110114
return functools.update_wrapper(new_func, f)
111115

112116
return ci_command

ci/fireci/fireci/plugins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ def discover():
2727
Note: plugins *must* define the `firebaseplugins` package as a namespace package.
2828
See: https://packaging.python.org/guides/packaging-namespace-packages/
2929
"""
30-
modules = pkgutil.iter_modules(fireciplugins.__path__,
31-
fireciplugins.__name__ + ".")
30+
modules = pkgutil.walk_packages(fireciplugins.__path__,
31+
fireciplugins.__name__ + ".")
3232
for _, name, _ in modules:
3333
importlib.import_module(name)

0 commit comments

Comments
 (0)