Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 7 additions & 5 deletions .github/workflows/unittest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -117,21 +117,23 @@ jobs:
echo "============================================================"

set +e
if [ -f "${pkg}/.coveragerc" ]; then
pushd "${pkg}" > /dev/null
if [ -f ".coveragerc" ]; then
echo "Using package-specific configuration: ${pkg}/.coveragerc"
# If fail_under is specified in the package-specific .coveragerc, coverage report
# will automatically enforce it. Otherwise, we enforce the default.
if grep -q "fail_under" "${pkg}/.coveragerc"; then
coverage report --rcfile="${pkg}/.coveragerc" --include="${pkg}/**"
if grep -q "fail_under" ".coveragerc"; then
COVERAGE_FILE=../../.coverage coverage report --include="$PWD/**"
else
echo "No fail_under specified in ${pkg}/.coveragerc, enforcing default"
coverage report --rcfile="${pkg}/.coveragerc" --include="${pkg}/**" --fail-under="${DEFAULT_FAIL_UNDER}"
COVERAGE_FILE=../../.coverage coverage report --include="$PWD/**" --fail-under="${DEFAULT_FAIL_UNDER}"
fi
else
echo "No .coveragerc found for ${pkg}, enforcing default"
coverage report --include="${pkg}/**" --fail-under="${DEFAULT_FAIL_UNDER}"
COVERAGE_FILE=../../.coverage coverage report --include="$PWD/**" --fail-under="${DEFAULT_FAIL_UNDER}"
fi
status=$?
popd > /dev/null
set -e

if [ ${status} -ne 0 ]; then
Expand Down
4 changes: 4 additions & 0 deletions packages/google-cloud-spanner-dbapi-driver/.coveragerc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,10 @@ branch = True

[report]
show_missing = True
# The spanner library has not had 100% coverage in the past and until such a time
# as the unittest coverage is fixed, we need to set it at an appropriate level
# to detect regressions in coverage but not fail due to known lack of coverage.
fail_under = 89
omit =
google/cloud/spanner_driver/__init__.py
exclude_lines =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,31 @@
"""Helper functions for system tests."""

import os
import pytest

SPANNER_EMULATOR_HOST = os.environ.get("SPANNER_EMULATOR_HOST")
TEST_ON_PROD = not bool(SPANNER_EMULATOR_HOST)

# As of June 2026, this package is in 'Planning' status.
# The CI/CD system does not yet have a SPANNER_EMULATOR_HOST active for this package,
# so running tests on production is the default. This fallback and skip logic acts
# as a safety measure until an emulator is available or production credentials are fully configured.
if TEST_ON_PROD:
PROJECT_ID = os.environ.get("SPANNER_PROJECT_ID")
INSTANCE_ID = os.environ.get("SPANNER_INSTANCE_ID")
PROJECT_ID = (
os.environ.get("SPANNER_PROJECT_ID")
or os.environ.get("GOOGLE_CLOUD_PROJECT")
or os.environ.get("PROJECT_ID")
)
INSTANCE_ID = os.environ.get("SPANNER_INSTANCE_ID") or os.environ.get(
"GOOGLE_CLOUD_TESTS_SPANNER_INSTANCE"
)
DATABASE_ID = os.environ.get("SPANNER_DATABASE_ID")

if not PROJECT_ID or not INSTANCE_ID or not DATABASE_ID:
raise ValueError(
"SPANNER_PROJECT_ID, SPANNER_INSTANCE_ID, and SPANNER_DATABASE_ID "
"must be set when running tests on production."
pytest.skip(
"SPANNER_PROJECT_ID, SPANNER_INSTANCE_ID, and SPANNER_DATABASE_ID (or standard fallbacks) "
"must be set when running tests on production.",
allow_module_level=True,
)
else:
PROJECT_ID = "test-project"
Expand Down
Loading