Repository navigation
80 lines (73 loc) · 3 KB
/
Copy pathci.yml
File metadata and controls
80 lines (73 loc) · 3 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
name: CI
on:
push:
branches: [main]
pull_request:
permissions:
contents: read
jobs:
check:
name: Check (Python ${{ matrix.python }})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
# The oldest version pyproject.toml allows, up to the latest release.
python: ['3.10', '3.11', '3.12', '3.13', '3.14']
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: ${{ matrix.python }}
cache: pip
cache-dependency-path: requirements-dev.txt
- run: python -m pip install --upgrade pip
- run: python -m pip install -e . -r requirements-dev.txt
- run: ruff check .
- run: ruff format --check .
- run: mypy --strict src tests
- run: python -X dev -m unittest discover -s tests -t . -v
package:
name: Package
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v7
with:
python-version: '3.14'
cache: pip
cache-dependency-path: requirements-dev.txt
- run: python -m pip install -r requirements-dev.txt
- run: python -m build
- run: twine check --strict dist/*
- name: Only the package and its metadata are in the wheel, and the tests travel in the sdist
run: |
python - <<'PY'
import glob, sys, tarfile, zipfile
(wheel,) = glob.glob("dist/*.whl")
names = zipfile.ZipFile(wheel).namelist()
stray = [n for n in names if not n.startswith(("flightbyte/", "flightbyte-"))]
if stray or "flightbyte/py.typed" not in names:
sys.exit(f"::error::Unexpected wheel contents: {stray or 'no py.typed'}")
print(f"{len(names)} files in {wheel}")
(sdist,) = glob.glob("dist/*.tar.gz")
members = [m.split("/", 1)[1] for m in tarfile.open(sdist).getnames() if "/" in m]
allowed = ("src/flightbyte/", "tests/", "spec/")
extra = {"README.md", "CHANGELOG.md", "LICENSE", "pyproject.toml", "PKG-INFO", ".gitignore"}
stray = [m for m in members if not m.startswith(allowed) and m not in extra]
if stray:
sys.exit(f"::error::Unexpected sdist contents: {stray}")
print(f"{len(members)} files in {sdist}")
PY
# The built wheel, installed alone on the oldest supported Python: the
# tests run against it, not against the source tree.
- uses: actions/setup-python@v7
with:
python-version: '3.10'
- name: Python 3.10, from the wheel
run: |
python -m venv "$RUNNER_TEMP/wheel"
"$RUNNER_TEMP/wheel/bin/python" -m pip install dist/*.whl
"$RUNNER_TEMP/wheel/bin/python" -m pip list
"$RUNNER_TEMP/wheel/bin/python" -c "import flightbyte, sys; print('flightbyte', flightbyte.__version__, 'on Python', sys.version.split()[0], 'from', flightbyte.__file__)"
"$RUNNER_TEMP/wheel/bin/python" -m unittest discover -s tests -t .