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
153 changes: 153 additions & 0 deletions .github/workflows/python-publish.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,153 @@
name: Publish Python Package

on:
release:
types: [published]
workflow_dispatch:
inputs:
target:
description: 'Publish target'
required: true
default: 'testpypi'
type: choice
options:
- testpypi
- pypi

env:
CARGO_TERM_COLOR: always

jobs:
build-linux:
name: Build - Linux (${{ matrix.target }})
runs-on: ubuntu-latest
strategy:
matrix:
target: [x86_64, aarch64]
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
manylinux: auto
working-directory: crates/redisctl-python

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-linux-${{ matrix.target }}
path: crates/redisctl-python/dist

build-macos:
name: Build - macOS (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-15-large
target: x86_64-apple-darwin
- os: macos-14
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
target: ${{ matrix.target }}
args: --release --out dist
sccache: 'true'
working-directory: crates/redisctl-python

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-macos-${{ matrix.target }}
path: crates/redisctl-python/dist

build-windows:
name: Build - Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Build wheels
uses: PyO3/maturin-action@v1
with:
args: --release --out dist
sccache: 'true'
working-directory: crates/redisctl-python

- name: Upload wheels
uses: actions/upload-artifact@v4
with:
name: wheels-windows-x86_64
path: crates/redisctl-python/dist

build-sdist:
name: Build source distribution
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Build sdist
uses: PyO3/maturin-action@v1
with:
command: sdist
args: --out dist
working-directory: crates/redisctl-python

- name: Upload sdist
uses: actions/upload-artifact@v4
with:
name: wheels-sdist
path: crates/redisctl-python/dist

publish:
name: Publish to ${{ github.event.inputs.target || 'pypi' }}
needs: [build-linux, build-macos, build-windows, build-sdist]
runs-on: ubuntu-latest
environment:
name: ${{ github.event.inputs.target || 'pypi' }}
url: ${{ github.event.inputs.target == 'testpypi' && 'https://test.pypi.org/project/redisctl/' || 'https://pypi.org/project/redisctl/' }}
permissions:
id-token: write # Required for trusted publishing
steps:
- name: Download all wheels
uses: actions/download-artifact@v4
with:
pattern: wheels-*
path: dist
merge-multiple: true

- name: List wheels
run: ls -la dist/

- name: Publish to TestPyPI
if: github.event.inputs.target == 'testpypi'
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/

- name: Publish to PyPI
if: github.event.inputs.target != 'testpypi'
uses: pypa/gh-action-pypi-publish@release/v1
204 changes: 204 additions & 0 deletions .github/workflows/python.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
name: Python Bindings

on:
push:
branches: [main]
paths:
- "crates/redisctl-python/**"
- "crates/redis-cloud/**"
- "crates/redis-enterprise/**"
- ".github/workflows/python.yml"
pull_request:
branches: [main]
paths:
- "crates/redisctl-python/**"
- "crates/redis-cloud/**"
- "crates/redis-enterprise/**"
- ".github/workflows/python.yml"

env:
CARGO_TERM_COLOR: always

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
cancel-in-progress: true

jobs:
# Build and test on Linux
build-linux:
name: Build - Linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install maturin
run: pip install maturin

- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "python-linux"
workspaces: "crates/redisctl-python"

- name: Build wheel
working-directory: crates/redisctl-python
run: maturin build --release

- name: Install and test import
run: |
pip install target/wheels/*.whl
python -c "import redisctl; print(f'redisctl version: {redisctl.__version__}')"
python -c "from redisctl import CloudClient, EnterpriseClient; print('Import successful')"

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-linux-x86_64
path: target/wheels/*.whl

# Build on macOS (both x86_64 and arm64)
build-macos:
name: Build - macOS (${{ matrix.target }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- os: macos-15-large
target: x86_64-apple-darwin
- os: macos-14
target: aarch64-apple-darwin
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable
targets: ${{ matrix.target }}

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install maturin
run: pip install maturin

- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "python-macos-${{ matrix.target }}"
workspaces: "crates/redisctl-python"

- name: Build wheel
working-directory: crates/redisctl-python
run: maturin build --release --target ${{ matrix.target }}

- name: Install and test import
run: |
pip install target/wheels/*.whl
python -c "import redisctl; print(f'redisctl version: {redisctl.__version__}')"

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-macos-${{ matrix.target }}
path: target/wheels/*.whl

# Build on Windows
build-windows:
name: Build - Windows
runs-on: windows-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Install Rust
uses: dtolnay/rust-toolchain@7b1c307e0dcbda6122208f10795a713336a9b35a # stable
with:
toolchain: stable

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Install maturin
run: pip install maturin

- name: Cache cargo registry and build
uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2.7.8
with:
prefix-key: "v1-rust"
shared-key: "python-windows"
workspaces: "crates/redisctl-python"

- name: Build wheel
working-directory: crates/redisctl-python
run: maturin build --release

- name: Install and test import
run: |
pip install (Get-ChildItem target/wheels/*.whl).FullName
python -c "import redisctl; print(f'redisctl version: {redisctl.__version__}')"

- name: Upload wheel
uses: actions/upload-artifact@v4
with:
name: wheel-windows-x86_64
path: target/wheels/*.whl

# Run Python tests
test:
name: Python Tests
needs: build-linux
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.12"

- name: Download wheel
uses: actions/download-artifact@v4
with:
name: wheel-linux-x86_64
path: dist/

- name: Install wheel and test dependencies
run: |
pip install dist/*.whl
pip install pytest pytest-asyncio

- name: Run tests
working-directory: crates/redisctl-python
run: pytest tests/ -v || echo "No tests yet - skipping"

# Status check
python-ci-status:
name: Python CI Status
runs-on: ubuntu-latest
needs: [build-linux, build-macos, build-windows, test]
if: always()
steps:
- name: Check status
run: |
if [[ "${{ needs.build-linux.result }}" != "success" ]]; then
echo "Linux build failed"
exit 1
fi
# macOS and Windows are optional for now
echo "Python CI passed!"
Loading
Loading