Skip to content
Closed
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
65 changes: 65 additions & 0 deletions .github/workflows/test_cross_package_compatibility.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
# Copyright 2025 Google LLC

# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at

# https://www.apache.org/licenses/LICENSE-2.0

# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

name: A workflow for testing cross package compatibility using pex

# Controls when the action will run.

# Run this action anytime `gapic_version.py` is updated in main
on:
push:
paths:
- '**/gapic_version.py'
branches:
- main
# TODO: Remove this before merging
pull_request:
branches:
- main


permissions:
contents: read

jobs:
build:
permissions:
issues: write # to open issues when compatibility issues are found
name: Cross Package Compatibility using Pex
runs-on: ubuntu-latest
# don't run the workflow on forks of googleapis/google-cloud-python
if: ${{github.repository == 'googleapis/google-cloud-python'}}
steps:
- uses: actions/checkout@v4
- name: Set up Python 3.13
uses: actions/setup-python@v5
with:
python-version: 3.13
- name: Install build dependencies
run: pip install build wheel
- name: Build wheels for all packages
run: ./build_wheels.sh
working-directory: ./scripts/test_cross_package_compatibility
- name: Create requirements.txt file to install all packages from source
run: ./create_requirements_file.sh
working-directory: ./scripts/test_cross_package_compatibility
- name: Create python file to be used during the compatibility check
run: ./generate_test_code.sh
working-directory: ./scripts/test_cross_package_compatibility
- name: Install pex
run: pip install pex
- name: Install all packages and run compatibility check
run: pex -r requirements.txt -- test_imports.py
working-directory: ./scripts/test_cross_package_compatibility
# TODO : open github issue if there are failures
25 changes: 25 additions & 0 deletions scripts/test_cross_package_compatibility/build_wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}"))
REPO_ROOT=${SCRIPT_ROOT/%'/scripts/test_cross_package_compatibility'}

# Build wheels for all packages
for package in $REPO_ROOT/packages/*/ ; do
pushd ${package}
distribution_name=$(basename $package)
python3 -m build --wheel
popd
done
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}"))
REPO_ROOT=${SCRIPT_ROOT/%'/scripts/test_cross_package_compatibility'}

output=''
# Create a requirements.txt file with all packages in this repo
for package in $REPO_ROOT/packages/*/ ; do
distribution_name=$(basename $package)
# Replace `-` with `_`
distribution_name_wheel=$(echo ${distribution_name} | sed -E 's/\-/_/g')
output+="${distribution_name} @ file://localhost${REPO_ROOT}/packages/${distribution_name}/dist/${distribution_name_wheel}-0.0.0-py3-none-any.whl\n"
done
output+="# Remove pin below once https://github.com/googleapis/google-cloud-python/issues/13874 is fixed\n"
output+="protobuf<6"

# Save the output to a requirements.txt
echo -e $output > requirements.txt
32 changes: 32 additions & 0 deletions scripts/test_cross_package_compatibility/generate_test_code.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# Copyright 2025 Google LLC
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR from google.cloud.billing import CloudBillingClientDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#

SCRIPT_ROOT=$(realpath $(dirname "${BASH_SOURCE[0]}"))
REPO_ROOT=${SCRIPT_ROOT/%'/scripts/test_cross_package_compatibility'}

output=''
# Create a requirements.txt file with all packages in this repo
for package in $REPO_ROOT/packages/*/ ; do
package_dir=$(basename $package)
top_namespace="${package_dir%%-*}"
for d in `find $package$top_namespace -name '__init__.py'`; do
init_relative_path=${d#$package}
module_path=$(echo $init_relative_path | sed -e "s/\/__init__.py//")
import_path="$(echo $module_path | sed -E 's/\//./g')"
output+="from $import_path import *\n"
done
done
# Save the output to a python file
echo -e $output > test_imports.py
Loading