Repository navigation
90 lines (85 loc) · 2.61 KB
/
Copy pathpython-package.yml
File metadata and controls
90 lines (85 loc) · 2.61 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
# 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-pep440:
runs-on: ubuntu-latest
outputs:
version: ${{ steps.get-version.outputs.version }}
steps:
- name: Get PEP-440 style version
id: get-version
run: |
PEP440_VERSION=""
VERSION_PREFIX="v"
BRANCH_OR_TAG="$(echo ${{ github.event.ref }} | cut -d / -f 3)"
if [[ "${BRANCH_OR_TAG}" =~ ^v?(([1-9][0-9]*!)?(0|[1-9][0-9]*)(\.(0|[1-9][0-9]*))*(\.?(a|b|rc)(0|[1-9][0-9]*))?(\.post(0|[1-9][0-9]*))?(\.dev(0|[1-9][0-9]*))?)$ ]]
then
PEP440_VERSION="${BRANCH_OR_TAG#$VERSION_PREFIX}"
fi
echo "version=${PEP440_VERSION}" | tee -a $GITHUB_OUTPUT
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.9", "3.10", "3.11", "3.12", "3.13", "3.14"]
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
python-version: ${{ matrix.python-version }}
- name: Install project
run: uv sync --no-dev --group test --group typed
- name: Cache of Ruff and MyPY
uses: actions/cache@v4
with:
path: |
.ruff_cache
.mypy_cache
key: cache-mypy-ruff
- name: Lint check with ruff
uses: astral-sh/ruff-action@v3
- name: Static type check with mypy
run: uv run --no-dev mypy
- name: Unit test
run: |
uv run --no-dev pytest
uv run --no-dev coverage report -m
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
publish:
runs-on: ubuntu-latest
needs: [get-version-pep440, test]
if: needs.get-version-pep440.outputs.version != ''
steps:
- name: Checkout
uses: actions/checkout@v5
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Build
run: uv build
- name: Publish
run: uv publish --token ${{ secrets.PYPI_API_TOKEN }}