-
Notifications
You must be signed in to change notification settings - Fork 40
126 lines (105 loc) · 4.4 KB
/
Copy pathunit-tests.yml
File metadata and controls
126 lines (105 loc) · 4.4 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
name: Unit Tests
on: [push, pull_request]
jobs:
test:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ["3.11", "3.14"]
steps:
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }} and uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
version: "0.12.8"
python-version: ${{ matrix.python-version }}
- name: Sync locked environment
run: uv sync --locked
- name: Run unittest with coverage
run: |
uv run --locked coverage run -m unittest discover . --pattern '*test.py'
uv run --locked coverage report
package:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up Python 3.11 and uv
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
with:
version: "0.12.8"
python-version: "3.11"
- name: Sync locked environment
run: uv sync --locked
- name: Build source and wheel distributions
run: uv build --no-sources
- name: Inspect distribution metadata and payload
run: |
uv run --locked python - <<'EOF'
import email.parser
import pathlib
import tarfile
import tomllib
import zipfile
expected_dependencies = [
"observable==0.3.*",
"requests==2.*",
"websockets==15.*",
]
expected_classifiers = [
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: 3 :: Only",
"Programming Language :: Python :: Implementation :: CPython",
]
dist = pathlib.Path("dist")
wheel_path = next(dist.glob("ringcentral-*.whl"))
sdist_path = next(dist.glob("ringcentral-*.tar.gz"))
with zipfile.ZipFile(wheel_path) as wheel:
wheel_names = wheel.namelist()
wheel_metadata_path = next(
name for name in wheel_names if name.endswith(".dist-info/METADATA")
)
wheel_metadata = email.parser.Parser().parsestr(
wheel.read(wheel_metadata_path).decode()
)
with open("pyproject.toml", "rb") as file:
project = tomllib.load(file)["project"]
assert wheel_metadata["Name"] == "ringcentral"
assert wheel_metadata["Version"] == project["version"]
assert wheel_metadata["Requires-Python"] == ">=3.11"
assert wheel_metadata.get_all("Requires-Dist") == expected_dependencies
assert wheel_metadata.get_all("Classifier") == expected_classifiers
wheel_top_levels = {name.split("/")[0] for name in wheel_names}
assert wheel_top_levels == {"ringcentral", wheel_metadata_path.split("/")[0]}
assert "ringcentral/test/testcase.py" in wheel_names
assert "ringcentral/test/spy.py" in wheel_names
assert any(name.endswith("_test.py") for name in wheel_names)
assert not any("demo" in name.lower() for name in wheel_names)
with tarfile.open(sdist_path) as sdist:
sdist_files = {
member.name.split("/", 1)[1]
for member in sdist.getmembers()
if member.isfile()
}
sdist_names = sdist.getnames()
assert sdist_files == {
"PKG-INFO",
"README.md",
"LICENSE.md",
"MANIFEST.in",
"pyproject.toml",
"requirements.txt",
"setup.cfg",
"setup.py",
"ringcentral.egg-info/PKG-INFO",
"ringcentral.egg-info/SOURCES.txt",
"ringcentral.egg-info/dependency_links.txt",
"ringcentral.egg-info/requires.txt",
"ringcentral.egg-info/top_level.txt",
} | {name for name in wheel_names if name.startswith("ringcentral/")}
assert not any("demo" in name.lower() for name in sdist_names)
EOF
- name: Install and import the wheel in a clean environment
run: |
wheel=$(ls dist/ringcentral-*.whl)
uv run --no-project --with "$wheel" python -c "import ringcentral; from importlib.metadata import version; print('imported', version('ringcentral'))"