-
Notifications
You must be signed in to change notification settings - Fork 1
148 lines (126 loc) · 3.82 KB
/
ci.yml
File metadata and controls
148 lines (126 loc) · 3.82 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
name: CI
on:
push:
branches: ["**"]
pull_request:
release:
types: [published]
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
cancel-in-progress: true
env:
FORCE_COLOR: 1
jobs:
package:
name: Build & inspect our package
runs-on: ubuntu-latest
env:
# Avoid local version identifiers in built packages
SETUPTOOLS_SCM_NO_LOCAL: "1"
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- uses: hynek/build-and-inspect-python-package@v2
test:
needs: [package]
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
python-version: ["3.10","3.11","3.12","3.13"]
name: Test on Python ${{ matrix.python-version }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- name: Setup python
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
cache: pip
cache-dependency-path: pyproject.toml
- name: Install package + dev deps
run: |
python -m pip install --upgrade pip
pip install -e .[dev]
- name: Lint (ruff)
run: |
ruff --version
ruff check can_waveshare tests --output-format=github || true
- name: Run tests
run: pytest -q
- name: Verify entry point is discoverable
run: |
python - <<'PY'
import importlib.metadata as md, can
eps = md.entry_points().select(group='can.interface')
names = {ep.name for ep in eps}
assert 'waveshare' in names, names
cls = [ep for ep in eps if ep.name == 'waveshare'][0].load()
assert issubclass(cls, can.BusABC), cls
print("Entry point present and loadable:", cls)
PY
- name: Build sdist & wheel
run: |
python -m pip install --upgrade build
python -m build
- name: Check install from wheel
run: |
pip install --force-reinstall --no-deps dist/*.whl
python - <<'PY'
import importlib.metadata as md, can
eps = md.entry_points().select(group='can.interface')
assert any(ep.name=='waveshare' for ep in eps), eps
print("Installed wheel exposes entry point OK.")
PY
- uses: actions/download-artifact@v7
with:
name: Packages
path: dist
dist_upload:
runs-on: ubuntu-latest
if: (github.event_name == 'push' && startsWith(github.event.ref, 'refs/tags')) || (github.event_name == 'release' && github.event.action == 'published')
permissions:
id-token: write
needs: [test]
steps:
- uses: actions/download-artifact@v7
with:
name: Packages
path: dist
- name: Publish package to PyPI
uses: pypa/gh-action-pypi-publish@release/v1
upload-release-assets:
runs-on: ubuntu-latest
if: github.event_name == 'release' && github.event.action == 'published'
needs: [test]
permissions:
contents: write
steps:
- uses: actions/download-artifact@v7
with:
name: Packages
path: dist
- name: Upload release assets
uses: softprops/action-gh-release@v2
with:
files: dist/*
fail_on_unmatched_files: true
test-pypi-upload:
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
needs: [test]
runs-on: ubuntu-latest
name: Upload to Test PyPI
permissions:
id-token: write
steps:
- uses: actions/download-artifact@v7
with:
name: Packages
path: dist
- name: Publish release to PyPI
continue-on-error: true
uses: pypa/gh-action-pypi-publish@release/v1
with:
repository-url: https://test.pypi.org/legacy/