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
67 changes: 67 additions & 0 deletions .github/workflows/build-shared-spanner-lib.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
name: Build Shared SpannerLib

on:
workflow_call:
workflow_dispatch:

permissions:
contents: read

jobs:
build:
name: Build ${{ matrix.target }}
runs-on: ${{ matrix.os }}
timeout-minutes: 10
strategy:
matrix:
go-version: ['1.25.x']
os: [ubuntu-latest, macos-latest, windows-latest]
include:
- os: ubuntu-latest
target: linux
- os: macos-latest
target: macos
- os: windows-latest
target: windows

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: ${{ matrix.go-version }}
cache: true

- name: Install Dependencies (Linux)
if: matrix.target == 'linux'
run: |
sudo apt-get update
sudo apt-get install -y gcc-aarch64-linux-gnu

- name: Build Binaries
shell: bash
run: |
cd spannerlib/shared
if [ "${{ matrix.target }}" == "linux" ]; then
export SKIP_MACOS=true
export SKIP_WINDOWS=true
# Enable ARM64 build
export BUILD_LINUX_ARM64=true
export CC_LINUX_ARM64=aarch64-linux-gnu-gcc
elif [ "${{ matrix.target }}" == "macos" ]; then
export SKIP_LINUX=true
export SKIP_WINDOWS=true
# Enable AMD64 build (if possible)
export BUILD_MACOS_AMD64=true
elif [ "${{ matrix.target }}" == "windows" ]; then
export SKIP_LINUX=true
export SKIP_MACOS=true
fi
./build-binaries.sh

- name: Upload Artifacts
uses: actions/upload-artifact@v4
with:
name: spannerlib-binaries-${{ matrix.target }}
path: spannerlib/shared/binaries/
37 changes: 37 additions & 0 deletions .github/workflows/python-spanner-lib-wrapper-lint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Python Wrapper Lint

on:
push:
branches: [ "main" ]
paths:
- 'spannerlib/wrappers/spannerlib-python/**'
pull_request:
branches: [ "main" ]
paths:
- 'spannerlib/wrappers/spannerlib-python/**'
workflow_dispatch:

permissions:
contents: read

jobs:
lint:
runs-on: ubuntu-latest
defaults:
run:
working-directory: spannerlib/wrappers/spannerlib-python/spannerlib-python

steps:
- uses: actions/checkout@v4

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install Nox
run: pip install nox

- name: Run Lint
run: nox -s lint
48 changes: 48 additions & 0 deletions .github/workflows/python-spanner-lib-wrapper-system-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
name: Python Wrapper System Tests on Emulator

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
system-tests:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest]
python-version: ['3.10', '3.11', '3.12', '3.13', '3.14']
defaults:
run:
working-directory: spannerlib/wrappers/spannerlib-python/spannerlib-python

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.x'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'

- name: Install Nox
run: pip install nox

- name: Run System Tests
env:
SPANNER_EMULATOR_HOST: localhost:9010
shell: bash
run: |
docker run -d -p 9010:9010 -p 9020:9020 gcr.io/cloud-spanner-emulator/emulator
sleep 10
nox -s system-${{ matrix.python-version }}
38 changes: 38 additions & 0 deletions .github/workflows/python-spanner-lib-wrapper-unit-tests.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: Python Wrapper Unit Tests

on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
workflow_dispatch:

permissions:
contents: read

jobs:
unit-tests:
runs-on: ubuntu-latest
defaults:
run:
working-directory: spannerlib/wrappers/spannerlib-python/spannerlib-python

steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: '1.25.x'

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install Nox
run: pip install nox

- name: Run Unit Tests
run: nox -s unit-3.10
83 changes: 83 additions & 0 deletions .github/workflows/release-python-spanner-lib-wrapper.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Build and Release Python Wrapper

on:
workflow_dispatch:

permissions:
id-token: write
contents: read

jobs:
build-shared-lib:
uses: ./.github/workflows/build-shared-spanner-lib.yml

build-and-publish-wrapper:
needs: build-shared-lib
runs-on: ubuntu-latest
environment:
name: pypi
url: https://pypi.org/p/spannerlib-python
timeout-minutes: 10
permissions:
id-token: write
contents: read

steps:
- uses: actions/checkout@v4

- name: Download Shared Library Artifacts
uses: actions/download-artifact@v4
with:
path: binaries
pattern: spannerlib*
merge-multiple: true

- name: Display Downloaded Files
run: ls -R binaries

- name: Copy Binaries to Lib
run: |
mkdir -p spannerlib/wrappers/spannerlib-python/spannerlib-python/google/cloud/spannerlib/internal/lib
cp -r binaries/* spannerlib/wrappers/spannerlib-python/spannerlib-python/google/cloud/spannerlib/internal/lib/
ls -R spannerlib/wrappers/spannerlib-python/spannerlib-python/google/cloud/spannerlib/internal/lib

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install Build Dependencies
run: pip install build twine

- name: Build Wheel
run: |
cd spannerlib/wrappers/spannerlib-python/spannerlib-python
python -m build

- name: Check Wheels
run: twine check spannerlib/wrappers/spannerlib-python/spannerlib-python/dist/*

- name: Verify Installation
run: |
# Create a fresh virtual environment
python -m venv test-env
source test-env/bin/activate

# Install the built wheel
pip install spannerlib/wrappers/spannerlib-python/spannerlib-python/dist/*.whl

# Verify import
python -c "import google.cloud.spannerlib; print('Successfully imported wrapper from:', google.cloud.spannerlib.__file__)"

- name: Upload Wheel Artifacts
uses: actions/upload-artifact@v4
with:
name: python-wheels
path: spannerlib/wrappers/spannerlib-python/spannerlib-python/dist/*

- name: Publish to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
packages-dir: spannerlib/wrappers/spannerlib-python/spannerlib-python/dist/
verbose: true
Loading
Loading