-
Notifications
You must be signed in to change notification settings - Fork 0
137 lines (119 loc) · 3.75 KB
/
python-package.yml
File metadata and controls
137 lines (119 loc) · 3.75 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# 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
env:
REDIS_HOST: "${{ secrets.REDIS_HOST }}"
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 }}