-
Notifications
You must be signed in to change notification settings - Fork 183
149 lines (148 loc) · 4.45 KB
/
python-package.yml
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
---
name: CI/CD
on:
push:
branches: [master]
pull_request:
branches: [master]
release:
types: [created]
branches: [master]
env:
FORCE_COLOR: '1' # Make tools pretty.
PIP_DISABLE_PIP_VERSION_CHECK: '1'
PIP_NO_PYTHON_VERSION_WARNING: '1'
PYTHON_LATEST: '3.12'
# For re-actors/checkout-python-sdist
sdist-artifact: python-package-distributions
jobs:
lint:
name: Check linting
runs-on: ubuntu-latest
steps:
- name: Checkout project
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: ${{ env.PYTHON_LATEST }}
cache: pip
- run: |
python -m pip install build
python -m pip install -r requirements/test.txt
name: Install core libraries for build and install
- name: Run linting checks
run: scripts/check
test-pytest:
name: 'Python ${{ matrix.python-version }}/Cython: ${{ matrix.use-cython }}'
runs-on: ubuntu-latest
timeout-minutes: 10 # Maybe we should remove this someday but the PyPy tests are acting strange
strategy:
# Complete all jobs even if one fails, allows us to see
# for example if a test fails only when Cython is enabled
fail-fast: false
matrix:
python-version: ['3.8', '3.9', '3.10', '3.11']
use-cython: ['true', 'false']
experimental: [false]
include:
- python-version: 'pypy3.9'
use-cython: false
experimental: true
- python-version: ~3.13.0-0
experimental: true
use-cython: false
- python-version: 3.12
experimental: true
use-cython: false
- python-version: 3.12
experimental: true
use-cython: true
env:
USE_CYTHON: ${{ matrix.use-cython }}
continue-on-error: ${{ matrix.experimental }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: requirements/test.txt
- name: Install dependencies
run: |
pip install -r requirements/test.txt
pip install .
- name: Run tests
run: scripts/tests
- name: Enforce coverage
uses: codecov/codecov-action@v3
with:
token: ${{ secrets.CODECOV_TOKEN }}
check: # This job does nothing and is only used for the branch protection
name: ✅ Ensure the required checks passing
if: always()
needs: [lint, test-pytest]
runs-on: ubuntu-latest
steps:
- name: Decide whether the needed jobs succeeded or failed
uses: re-actors/alls-green@release/v1
with:
jobs: ${{ toJSON(needs) }}
build_wheels:
name: 📦 Build wheels on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
needs: check
if: github.event_name == 'release' && github.event.action == 'created'
strategy:
matrix:
os: [ubuntu-20.04, macos-13, macos-14]
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build wheels
uses: pypa/[email protected]
- uses: actions/upload-artifact@v3
with:
path: ./wheelhouse/*.whl
build_sdist:
name: 📦 Build the source distribution
runs-on: ubuntu-latest
needs: check
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- uses: actions/checkout@v4
name: Checkout source repository
with:
fetch-depth: 0
- uses: actions/setup-python@v5
- name: Build sdist
run: >
pip3 install pkgconfig cython --upgrade &&
python3 setup.py sdist
- uses: actions/upload-artifact@v3
name: Upload build artifacts
with:
path: dist/*.tar.gz
publish:
name: 📦 Publish to PyPI
runs-on: ubuntu-latest
needs: [build_wheels, build_sdist]
permissions:
id-token: write
environment: pypi
if: github.event_name == 'release' && github.event.action == 'created'
steps:
- name: Download the sdist artifact
uses: actions/download-artifact@v3
with:
name: artifact
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
with:
password: ${{ secrets.PYPI_API_TOKEN }}