forked from akaihola/darkgraylib
-
Notifications
You must be signed in to change notification settings - Fork 0
148 lines (141 loc) · 4.21 KB
/
python-package.yml
File metadata and controls
148 lines (141 loc) · 4.21 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: Build and test
on: # yamllint disable-line rule:truthy
push:
branches:
- main
pull_request:
branches:
- main
env:
PY_IGNORE_IMPORTMISMATCH: 1
jobs:
build-wheel:
runs-on: ubuntu-latest
outputs:
wheel-path: ${{ steps.get-darkgraylib-version.outputs.wheel-path }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
cache-dependency-glob: |
**/setup.cfg
**/pyproject.toml
- name: Build wheel distribution
run: |
uv build --wheel
- name: Upload wheel for other jobs
uses: actions/upload-artifact@v4
with:
name: dist
path: dist/
if-no-files-found: error
- name: Find out darkgraylib version and output it for test jobs
id: get-darkgraylib-version
shell: python
run: |
from os import environ
from pathlib import Path
from runpy import run_path
version = run_path("src/darkgraylib/version.py")["__version__"]
Path(environ["GITHUB_OUTPUT"]).open("a").write(
f"wheel-path=dist/darkgraylib-{version}-py3-none-any.whl\n"
)
test-nixos:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- macos-latest
needs:
- build-wheel
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
with:
nix_path: nixpkgs=channel:nixos-unstable
- name: Download wheel uploaded by the build-wheel job
uses: actions/download-artifact@v4
- name: Run tests in nix-shell
run: |
nix-shell \
--pure \
--run '
cert_file=/nix/var/nix/profiles/default/etc/ssl/certs/ca-bundle.crt
export NIX_SSL_CERT_FILE=$cert_file
uv venv
uv pip install "${{needs.build-wheel.outputs.wheel-path}}"
uv export --only-group=dev | uv pip install --requirements=-
PY_IGNORE_IMPORTMISMATCH=1 uv run pytest
' \
./default.nix
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os:
- ubuntu-latest
- windows-latest
- macos-latest
python-version:
- '3.9'
- '3.10'
- '3.11'
- '3.12'
- '3.13'
- '3.14'
- '3.15-dev'
resolution: ['']
post_install: ['']
include:
- os: ubuntu-latest
python-version: '3.9'
resolution: --resolution lowest-direct
- os: ubuntu-latest
python-version: '3.14'
post_install: uv sync --upgrade
needs:
- build-wheel
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Download wheel uploaded by the build-wheel job
uses: actions/download-artifact@v4
- name: Create virtual environment
run: uv venv
- name: Install darkgraylib and dependencies from wheel built earlier
run: uv pip install "${{needs.build-wheel.outputs.wheel-path}}"
${{ matrix.resolution }}
- name: Install test dependencies
run: uv export --only-group=dev ${{ matrix.resolution }}
| uv pip install --requirements=-
- name: Run Pytest
run: uv run pytest
build-sdist-validate-dists:
runs-on: ubuntu-latest
needs:
- build-wheel
steps:
- uses: actions/checkout@v4
- name: Install uv
uses: astral-sh/setup-uv@v6
- uses: actions/setup-python@v5
- name: Download wheel uploaded by the build-wheel job
uses: actions/download-artifact@v4
- name: Build source distribution
run: uv build --sdist
- name: Validate distributions
run: uvx twine check dist/*