forked from xorq-labs/xorq
-
Notifications
You must be signed in to change notification settings - Fork 0
197 lines (169 loc) 路 6.25 KB
/
Copy pathci-test-install.yaml
File metadata and controls
197 lines (169 loc) 路 6.25 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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
name: ci-test-install
on:
push:
# Skip the backend suite if all changes are docs
paths-ignore:
- "docs/**"
- "**/*.md"
- "**/*.qmd"
- "*.md"
- "codecov.yml"
- ".envrc"
branches:
- main
- master
tags:
- '*'
pull_request:
workflow_dispatch:
permissions:
contents: read
jobs:
test-installation:
name: Test installation on ${{ matrix.os }} with Python ${{ matrix.python-version }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
include:
- os: ubuntu-latest
python-version: "3.10"
- os: ubuntu-latest
python-version: "3.11"
- os: ubuntu-latest
python-version: "3.12"
- os: ubuntu-latest
python-version: "3.13"
- os: windows-latest
python-version: "3.13"
- os: macos-latest
python-version: "3.13"
steps:
- uses: actions/checkout@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install uv
uses: astral-sh/setup-uv@v6
with:
enable-cache: true
- name: Install PostgreSQL on macOS
# https://stackoverflow.com/a/78269163
if: runner.os == 'macOS'
run: |
brew install postgresql@16
brew link postgresql@16
- name: Add PostgreSQL binaries to PATH
# https://stackoverflow.com/a/78269163
shell: bash
run: |
if [ "$RUNNER_OS" == "Windows" ]; then
echo "$PGBIN" >> $GITHUB_PATH
elif [ "$RUNNER_OS" == "Linux" ]; then
echo "$(pg_config --bindir)" >> $GITHUB_PATH
fi
- name: Get package extras
id: get-extras
shell: bash
run: |
python -c "
import configparser
import json
import os
try:
config = configparser.ConfigParser()
config.read('setup.cfg')
extras = list(config['options.extras_require'].keys())
except:
try:
import tomllib
with open('pyproject.toml', 'rb') as f:
data = tomllib.load(f)
extras = list(data.get('project', {}).get('optional-dependencies', {}).keys())
except:
extras = []
extras_json = json.dumps(extras)
print(f'extras={extras_json}')
with open(os.environ['GITHUB_OUTPUT'], 'a') as f:
f.write(f'extras={extras_json}\n')
"
- name: Build package
run: uv build
- name: Get wheel filename
id: wheel-name
shell: bash
run: |
wheel_file=$(ls dist/*.whl | head -1)
echo "wheel_file=$wheel_file" >> $GITHUB_OUTPUT
echo "Found wheel: $wheel_file"
- name: Test installation from wheel and source distribution
shell: bash
run: |
# Test wheel installation
python -m venv .venv-wheel
if [ "$RUNNER_OS" == "Windows" ]; then
source .venv-wheel/Scripts/activate
else
source .venv-wheel/bin/activate
fi
python -m pip install --upgrade pip
python -m pip install dist/*.whl
# Test basic import and version in separate directory
mkdir -p test-wheel && cd test-wheel
python -c "import pathlib; print(f'Current working directory: {pathlib.Path.cwd()}')"
python -c "import xorq; print(f'Successfully imported {xorq.__name__} version {xorq.__version__}')"
cd ..
deactivate
# Test source distribution installation
python -m venv .venv-sdist
if [ "$RUNNER_OS" == "Windows" ]; then
source .venv-sdist/Scripts/activate
else
source .venv-sdist/bin/activate
fi
python -m pip install --upgrade pip
python -m pip install dist/*.tar.gz
python -c "import xorq; print(f'Successfully installed xorq {xorq.__version__} from source distribution')"
deactivate
- name: Test extras installation from wheel
shell: bash
run: |
extras='${{ steps.get-extras.outputs.extras }}'
wheel_file='${{ steps.wheel-name.outputs.wheel_file }}'
echo "Testing extras: $extras"
echo "Using wheel: $wheel_file"
# Test each extra from the wheel file
python -c "
import json
import subprocess
import sys
import os
extras = json.loads('$extras')
wheel_file = '$wheel_file'
if not extras:
print('No extras found to test')
sys.exit(0)
for extra in extras:
print(f'Testing extra: {extra}')
try:
# Create fresh venv for each extra
venv_name = f'.venv-extra-{extra}'
subprocess.run([sys.executable, '-m', 'venv', venv_name], check=True)
# Determine activation script path
if os.name == 'nt': # Windows
pip_path = os.path.join(venv_name, 'Scripts', 'pip')
python_path = os.path.join(venv_name, 'Scripts', 'python')
else: # Unix-like
pip_path = os.path.join(venv_name, 'bin', 'pip')
python_path = os.path.join(venv_name, 'bin', 'python')
# Install package with extra from wheel
subprocess.run([python_path, '-m', 'pip', 'install', '--upgrade', 'pip'], check=True)
subprocess.run([pip_path, 'install', f'{wheel_file}[{extra}]'], check=True)
# Test import
subprocess.run([python_path, '-c', 'import xorq'], check=True)
print(f'Successfully tested extra: {extra}')
except subprocess.CalledProcessError as e:
print(f'Failed to test extra {extra}: {e}')
sys.exit(1)
"