Skip to content

Commit 6d60f59

Browse files
committed
ci: add import profiler check across monorepo
1 parent b2ec761 commit 6d60f59

2 files changed

Lines changed: 51 additions & 0 deletions

File tree

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: import-profiler
2+
3+
on:
4+
pull_request:
5+
branches:
6+
- main
7+
- preview
8+
# Trigger workflow on GitHub merge queue events
9+
merge_group:
10+
types: [checks_requested]
11+
12+
permissions:
13+
contents: read
14+
15+
jobs:
16+
import-profile:
17+
runs-on: ubuntu-latest
18+
steps:
19+
- name: Checkout
20+
uses: actions/checkout@v6
21+
with:
22+
fetch-depth: 2
23+
- name: Setup Python
24+
uses: actions/setup-python@v6
25+
with:
26+
python-version: "3.15"
27+
- name: Install nox
28+
run: |
29+
python -m pip install --upgrade setuptools pip wheel
30+
python -m pip install nox
31+
- name: Run import profiler
32+
env:
33+
BUILD_TYPE: presubmit
34+
TARGET_BRANCH: ${{ github.base_ref || github.event.merge_group.base_ref }}
35+
TEST_TYPE: import_profile
36+
PY_VERSION: "3.15"
37+
run: |
38+
ci/run_conditional_tests.sh

packages/gapic-generator/gapic/templates/noxfile.py.j2

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -86,6 +86,7 @@ nox.options.sessions = [
8686
"lint_setup_py",
8787
"blacken",
8888
"docs",
89+
"import_profile",
8990
]
9091

9192
# Error if a python version is missing
@@ -641,4 +642,16 @@ def core_deps_from_source(session, protobuf_implementation):
641642
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
642643
},
643644
)
645+
646+
647+
@nox.session(python="3.15")
648+
def import_profile(session):
649+
"""Ensure import times remain below defined thresholds."""
650+
session.install(".")
651+
profiler_script = os.path.join(CURRENT_DIRECTORY.parent.parent, "scripts", "import_profiler", "profiler.py")
652+
{% if api.naming.module_namespace %}
653+
session.run("python", profiler_script, "--module", "{{ api.naming.module_namespace[0] }}", "--iterations", "10")
654+
{% else %}
655+
session.run("python", profiler_script, "--module", "{{ api.naming.versioned_module_name }}", "--iterations", "10")
656+
{% endif %}
644657
{% endblock %}

0 commit comments

Comments
 (0)