Skip to content

Commit a2bd6ec

Browse files
committed
refactor: simplify CI without gapic-generator template changes and fix syntax errors
1 parent 885de7f commit a2bd6ec

14 files changed

Lines changed: 47 additions & 360 deletions

File tree

ci/run_single_test.sh

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -106,31 +106,44 @@ case ${TEST_TYPE} in
106106
esac
107107
;;
108108
import_profile)
109-
if nox --list-sessions | grep -q "import_profile"; then
109+
if [ -f setup.py ]; then
110+
echo "Creating temporary virtualenv for import profile..."
111+
python3 -m venv .venv-profiler
112+
source .venv-profiler/bin/activate
113+
pip install -e .
114+
115+
PACKAGE_NAME=$(basename $(pwd))
116+
PROFILER_SCRIPT="../../scripts/import_profiler/profiler.py"
117+
110118
rm -f /tmp/baseline.csv
111119
if [ -n "${TARGET_BRANCH}" ]; then
112120
if git rev-parse HEAD^1 >/dev/null 2>&1; then
113121
echo "Checking out HEAD^1 for baseline..."
114122
git checkout HEAD^1
115-
if nox --list-sessions | grep -q "import_profile"; then
116-
nox -s import_profile -- --csv /tmp/baseline.csv
123+
if [ -f setup.py ]; then
124+
pip install -e .
125+
python ${PROFILER_SCRIPT} --package ${PACKAGE_NAME} --iterations 10 --csv /tmp/baseline.csv
117126
else
118-
echo "No import_profile session on baseline."
127+
echo "setup.py not found on baseline. Skipping baseline generation."
119128
fi
120129
git checkout -
130+
# Re-install the current branch to ensure we profile the latest code
131+
pip install -e .
121132
else
122133
echo "Could not find HEAD^1. Skipping baseline generation."
123134
fi
124135
fi
125136

126137
if [ -f /tmp/baseline.csv ]; then
127-
nox -s import_profile -- --diff-baseline /tmp/baseline.csv --diff-threshold 100
138+
python ${PROFILER_SCRIPT} --package ${PACKAGE_NAME} --iterations 10 --fail-threshold 5000 --diff-baseline /tmp/baseline.csv --diff-threshold 100
128139
else
129-
nox -s import_profile
140+
python ${PROFILER_SCRIPT} --package ${PACKAGE_NAME} --iterations 10 --fail-threshold 5000
130141
fi
131142
retval=$?
143+
deactivate
144+
rm -rf .venv-profiler
132145
else
133-
echo "Skipping import_profile as it is not supported by this package yet."
146+
echo "Skipping import_profile as this does not appear to be a Python package (no setup.py)."
134147
retval=0
135148
fi
136149
;;

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

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

9291
# Error if a python version is missing
@@ -642,31 +641,4 @@ def core_deps_from_source(session, protobuf_implementation):
642641
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
643642
},
644643
)
645-
646-
647-
@nox.session(python=DEFAULT_PYTHON_VERSION)
648-
def import_profile(session):
649-
"""Ensure import times remain below defined thresholds."""
650-
profiler_script = (
651-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
652-
)
653-
if not profiler_script.exists():
654-
session.skip("The import profiler script was not found.")
655-
656-
session.install(".")
657-
session.run(
658-
"python",
659-
str(profiler_script),
660-
"--module",
661-
{% if api.naming.module_namespace %}
662-
"{{ api.naming.module_namespace[0] }}",
663-
{% else %}
664-
"{{ api.naming.versioned_module_name }}",
665-
{% endif %}
666-
"--iterations",
667-
"10",
668-
"--fail-threshold",
669-
"5000",
670-
*session.posargs,
671-
)
672644
{% endblock %}

packages/gapic-generator/tests/integration/goldens/asset/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.cloud.asset",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

packages/gapic-generator/tests/integration/goldens/credentials/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.iam.credentials",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

packages/gapic-generator/tests/integration/goldens/eventarc/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.cloud.eventarc_v1",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

packages/gapic-generator/tests/integration/goldens/logging/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.cloud.logging",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

packages/gapic-generator/tests/integration/goldens/logging_internal/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.cloud.logging",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

packages/gapic-generator/tests/integration/goldens/redis/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.cloud.redis",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

packages/gapic-generator/tests/integration/goldens/redis_selective/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.cloud.redis",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

packages/gapic-generator/tests/integration/goldens/storagebatchoperations/noxfile.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,6 @@
9393
"lint_setup_py",
9494
"blacken",
9595
"docs",
96-
"import_profile",
9796
]
9897

9998
# Error if a python version is missing
@@ -634,25 +633,3 @@ def core_deps_from_source(session, protobuf_implementation):
634633
"PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION": protobuf_implementation,
635634
},
636635
)
637-
638-
639-
@nox.session(python="3.15")
640-
def import_profile(session):
641-
"""Ensure import times remain below defined thresholds."""
642-
profiler_script = (
643-
CURRENT_DIRECTORY.parent.parent / "scripts" / "import_profiler" / "profiler.py"
644-
)
645-
if not profiler_script.exists():
646-
session.skip("The import profiler script was not found.")
647-
648-
session.install(".")
649-
session.run(
650-
"python",
651-
str(profiler_script),
652-
"--package",
653-
"google.cloud.storagebatchoperations",
654-
"--fail-threshold",
655-
"5000",
656-
"--iterations",
657-
"10",
658-
)

0 commit comments

Comments
 (0)