Repository navigation
130 lines (110 loc) · 3.54 KB
/
Copy pathpython-ci.yml
File metadata and controls
130 lines (110 loc) · 3.54 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
name: Python CI
on:
workflow_dispatch:
inputs:
soak:
description: "Run long soak tests"
required: false
default: "false"
schedule:
- cron: "17 8 * * *"
pull_request:
push:
branches:
- main
jobs:
test:
name: Test and package (${{ matrix.os }})
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
- windows-latest
steps:
- name: Check out
uses: actions/checkout@v6.0.2
- name: Set up Python
uses: actions/setup-python@v6.2.0
with:
python-version: "3.13"
- name: Install uv
run: python -m pip install uv
- name: Sync dependencies
run: uv sync --group dev
- name: Audit dependencies
run: |
uv export --quiet --all-groups --no-emit-project --format requirements.txt --output-file audit-requirements.txt
uv run pip-audit -r audit-requirements.txt --require-hashes --disable-pip --strict --progress-spinner off
- name: Run tests
run: uv run pytest -vv -W error --cov=hsm --cov-report=term-missing --cov-fail-under=90
- name: Type check
run: uv run pyright
- name: Build package
run: uv build
- name: Check package metadata
run: uvx twine check dist/*
- name: Install built wheel smoke test
shell: bash
run: |
uv run --no-project --isolated --with dist/*.whl python - <<'PY'
import asyncio
import hsm
class Instance(hsm.Instance):
pass
async def main():
model = hsm.Define(
"Smoke",
hsm.Initial(hsm.Target("idle")),
hsm.State("idle", hsm.Transition(hsm.On("go"), hsm.Target("../done"))),
hsm.State("done"),
)
instance = Instance()
await hsm.Started(None, instance, model)
await hsm.Dispatch(None, instance, hsm.Event(name="go"))
assert instance.state() == "/Smoke/done"
assert hsm.ValidationError is not None
await hsm.Stop(instance)
asyncio.run(main())
PY
- name: Verify typed marker in wheel
shell: bash
run: |
python - <<'PY'
import glob
import zipfile
[wheel] = glob.glob("dist/*.whl")
with zipfile.ZipFile(wheel) as archive:
names = set(archive.namelist())
assert "hsm/py.typed" in names
PY
- name: Verify source distribution contents
shell: bash
run: |
python - <<'PY'
import glob
import tarfile
[sdist] = glob.glob("dist/*.tar.gz")
with tarfile.open(sdist) as archive:
names = set(archive.getnames())
root = next(name for name in names if name.endswith("/PKG-INFO")).rsplit("/", 1)[0]
required = {
f"{root}/README.md",
f"{root}/RELEASE.md",
f"{root}/SECURITY.md",
f"{root}/hsm/__init__.py",
f"{root}/hsm/hsm.py",
f"{root}/hsm/kind.py",
f"{root}/hsm/py.typed",
f"{root}/hsm/version.py",
f"{root}/pyproject.toml",
}
missing = required - names
assert not missing, sorted(missing)
PY
- name: Run soak tests
env:
HSM_SOAK: "1"
run: uv run pytest tests/test_soak.py -q -W error