Repository navigation
187 lines (161 loc) · 5.47 KB
/
Copy pathpython-package.yml
File metadata and controls
187 lines (161 loc) · 5.47 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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
# 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/**
- docs/**
- pyproject.toml
- .pre-commit-config.yaml
pull_request:
branches: [main]
paths:
- .github/**
- src/**
- tests/**
- docs/**
- pyproject.toml
- .pre-commit-config.yaml
# Minimal GITHUB_TOKEN permissions by default; jobs may widen as needed.
permissions:
contents: read
jobs:
# Decides whether this ref is a release: the tag must be valid PEP-440 (a
# PyPI-publishable version); otherwise the output stays empty and build/publish skip.
check-release-tag:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.check-release-tag.outputs.version }}
steps:
# Shallow checkout suffices: the script only reads GITHUB_REF, it runs no git.
# Full history is only needed where hatch-vcs derives the version (build).
- name: Checkout
uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v10.1.0
with:
enable-cache: true
- name: Validate PEP-440 tag (extract & check) and set output
id: check-release-tag
run: |
set -euo pipefail
# The script derives the candidate from GITHUB_REF and writes version=... to GITHUB_OUTPUT
uv run --no-project .github/scripts/check-release-tag.py
pre-commit:
runs-on: ubuntu-latest
env:
LUALS_VERSION: 3.19.1
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Install uv
uses: astral-sh/setup-uv@v10.1.0
with:
enable-cache: true
- name: Cache lua-language-server
id: luals
uses: actions/cache@v6
with:
path: /opt/luals
key: luals-${{ runner.os }}-${{ env.LUALS_VERSION }}
- name: Download lua-language-server
if: steps.luals.outputs.cache-hit != 'true'
run: |
set -euo pipefail
curl -sSfL -o /tmp/luals.tar.gz \
"https://github.com/LuaLS/lua-language-server/releases/download/${LUALS_VERSION}/lua-language-server-${LUALS_VERSION}-linux-x64.tar.gz"
mkdir -p /opt/luals
tar -xzf /tmp/luals.tar.gz -C /opt/luals
- name: Put lua-language-server on PATH
run: echo /opt/luals/bin >> "${GITHUB_PATH}"
- name: Cache pre-commit environments
uses: actions/cache@v6
with:
path: ~/.cache/pre-commit
key: pre-commit-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Sync project environment (for mypy)
run: uv sync --all-extras --dev
- name: Run pre-commit on all files
run: uvx pre-commit run --all-files
unittest-linux:
runs-on: ubuntu-latest
needs: [pre-commit]
strategy:
matrix:
python-version: ["3.11", "3.12", "3.13", "3.14", "3.15"]
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@v7
- 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
needs: [pre-commit]
steps:
- uses: actions/checkout@v7
- 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: [check-release-tag, pre-commit, unittest-linux, unittest-macos]
if: needs.check-release-tag.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v7
with:
fetch-depth: 0
- name: Install uv
uses: astral-sh/setup-uv@v10.1.0
with:
enable-cache: true
- name: Build
run: uv build
- name: Upload package distributions to artifact
uses: actions/upload-artifact@v7
with:
name: redis_func_cache-dist-${{ needs.check-release-tag.outputs.version }}
path: dist
if-no-files-found: error
retention-days: 1
publish:
runs-on: ubuntu-latest
needs: [check-release-tag, build]
if: needs.check-release-tag.outputs.version != ''
steps:
- name: Download package distributions from artifact
uses: actions/download-artifact@v8
with:
name: redis_func_cache-dist-${{needs.check-release-tag.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 }}