Skip to content

refactor(redis): simplify Redis client initialization logic #174

refactor(redis): simplify Redis client initialization logic

refactor(redis): simplify Redis client initialization logic #174

Workflow file for this run

# This workflow will install Python dependencies, run tests and lint with a variety of Python versions
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-python-with-github-actions
name: Python package
on:
push:
branches: [main]
tags: ["*"]
paths:
- .github/**
- src/**
- tests/**
- pyproject.toml
pull_request:
branches: [main]
paths:
- .github/**
- src/**
- tests/**
- pyproject.toml
jobs:
get-version:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Cache pip downloads
uses: actions/cache@v4
with:
path: ~/.cache/pip
key: pip
- name: Install packaging (no deps)
run: python3 -m pip install --disable-pip-version-check packaging
- name: Validate PEP-440 tag (extract & check) and set output
id: get-version
run: |
set -euo pipefail
# The script derives the candidate from GITHUB_REF and writes version=... to GITHUB_OUTPUT
python3 .github/scripts/validate_version.py
unittest-linux:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
services:
redis-standalone:
image: redis:alpine
options: >-
--health-cmd "redis-cli ping | grep PONG"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- uses: actions/checkout@v5
- name: Run shared test steps (Linux matrix)
uses: ./.github/actions/run-tests
with:
python-version: ${{ matrix.python-version }}
upload-codecov: "true"
codecov-token: ${{ secrets.CODECOV_TOKEN }}
unittest-macos:
runs-on: macos-latest
steps:
- uses: actions/checkout@v5
- name: Install & start Redis on macOS (Homebrew)
shell: bash
run: |
# Use the repository script to install and start redis on macOS.
# The script should handle an external REDIS_HOST if set.
bash .github/scripts/install_start_redis-macos.bash
- name: Run shared test steps (macOS)
uses: ./.github/actions/run-tests
with:
upload-codecov: "false"
# Windows CI job removed per repository decision (Windows CI is disabled)
build:
runs-on: ubuntu-latest
needs: [get-version, unittest-linux, unittest-macos]
if: needs.get-version.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v5
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Build
run: uv build
- name: Upload package distributions to artifact
uses: actions/upload-artifact@v4
with:
name: redis_func_cache-dist-${{ needs.get-version.outputs.version }}
path: dist
if-no-files-found: error
retention-days: 1
publish:
runs-on: ubuntu-latest
needs: [get-version, build]
if: needs.get-version.outputs.version != ''
steps:
- name: Download package distributions from artifact
uses: actions/download-artifact@v4
with:
name: redis_func_cache-dist-${{needs.get-version.outputs.version}}
path: dist
- name: Publish package distributions to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
user: __token__
password: ${{ secrets.PYPI_API_TOKEN }}