-
Notifications
You must be signed in to change notification settings - Fork 83
Expand file tree
/
Copy pathgithub-actions-build-python.yaml
More file actions
136 lines (124 loc) · 4.41 KB
/
Copy pathgithub-actions-build-python.yaml
File metadata and controls
136 lines (124 loc) · 4.41 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
name: Development Build & Test
on:
pull_request:
push:
jobs:
"Lint":
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip' # caching pip dependencies
cache-dependency-path: |
**/pyproject.toml
- name: Install library and dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Lint
run: ruff check spflow tests
continue-on-error: true
"Check_Format":
name: "Check Format"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip' # caching pip dependencies
cache-dependency-path: |
**/pyproject.toml
- name: Install library and dependencies
run: |
python -m pip install --upgrade pip
pip install .[dev]
- name: Checking formatting with black
run: black --check --diff spflow tests
continue-on-error: true
"Package":
name: "Package"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v5
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
cache: 'pip'
- name: Install packaging tools
run: |
python -m pip install --upgrade pip
python -m pip install build twine
- name: Build distribution artifacts
run: python -m build
- name: Check distribution metadata
run: twine check dist/*
- name: Validate wheel contents
run: |
python - <<'PY'
import pathlib
import zipfile
wheel_path = next(pathlib.Path("dist").glob("*.whl"))
with zipfile.ZipFile(wheel_path) as wheel:
names = set(wheel.namelist())
expected = "spflow/py.typed"
if expected not in names:
raise SystemExit(f"Missing required typing marker: {expected}")
forbidden_prefixes = ("tests/", "docs/", "scripts/")
leaked = sorted(name for name in names if name.startswith(forbidden_prefixes))
if leaked:
leaked_preview = ", ".join(leaked[:10])
raise SystemExit(f"Unexpected files in wheel: {leaked_preview}")
PY
- name: Smoke install built wheel
run: |
python -m venv .pkg-smoke
. .pkg-smoke/bin/activate
python -m pip install --upgrade pip
python -m pip install --no-deps dist/*.whl
python - <<'PY'
import importlib.metadata
import spflow
version = importlib.metadata.version("spflow")
assert version == spflow.__version__, (version, spflow.__version__)
print(version)
PY
# We do not want to waste too many resources on testing all combinations. Thus we test:
# - on the oldest and the two most recent version of Python that we support (see README.md)
# - with the oldest version of the backend we support plus the two most recent major ones
# (to catch if only the newest version breaks something)
# - A single test on Windows and macOS to catch if something breaks there
# - We only test on the most recent version of macOS and Windows to save resources
# - We test even fewer combinations for TensorFlow and Jax to save resources
"test_python":
name: "Python ${{ matrix.version-python }}"
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
version-python: ['3.10', '3.11', '3.12']
steps:
- uses: actions/checkout@v5
- uses: "./.github/actions/run_tests"
with:
version-python: ${{ matrix.version-python }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}
"Test_OS":
name: "Test: Py ${{ matrix.version-python }} @ OS ${{ matrix.os }}"
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
version-python: ['3.12']
os: ['macos-latest', 'windows-latest'] # No ubuntu-latest since the different python version tests already cover this
steps:
- uses: actions/checkout@v5
- uses: "./.github/actions/run_tests"
with:
version-python: ${{ matrix.version-python }}
codecov-token: ${{ secrets.CODECOV_TOKEN }}