Skip to content

Commit b9fa6dc

Browse files
authored
Update numpy-scipy-c-extension-test.yml
1 parent f9559b0 commit b9fa6dc

1 file changed

Lines changed: 114 additions & 125 deletions

File tree

Lines changed: 114 additions & 125 deletions
Original file line numberDiff line numberDiff line change
@@ -1,135 +1,124 @@
1-
name: NumPy + SciPy C-Extension Switching
1+
name: Omnipkg Demo Tests
22

33
on:
44
push:
5-
branches: [ main ]
5+
branches: [ main, develop ]
66
pull_request:
77
branches: [ main ]
88
workflow_dispatch:
99

1010
jobs:
11-
test:
11+
test-numpy-scipy:
1212
runs-on: ubuntu-latest
13-
services:
14-
redis:
15-
image: redis:7
16-
options: >-
17-
--health-cmd "redis-cli ping"
18-
--health-interval 10s
19-
--health-timeout 5s
20-
--health-retries 5
21-
ports:
22-
- 6379:6379
23-
13+
timeout-minutes: 30
14+
2415
steps:
25-
- name: Checkout repository
26-
uses: actions/checkout@v4
27-
28-
- name: Set up Python 3.11
29-
uses: actions/setup-python@v5
30-
with:
31-
python-version: '3.11'
32-
33-
- name: Install dependencies
34-
run: |
35-
python -m pip install --upgrade pip
36-
pip install -e . redis numpy==1.26.4 scipy==1.13.0
37-
38-
- name: Configure omnipkg for non-interactive use
39-
run: |
40-
python - << 'EOF'
41-
import sys
42-
import site
43-
import json
44-
from pathlib import Path
45-
import os
46-
import sysconfig
47-
48-
try:
49-
site_packages_path = site.getsitepackages()[0]
50-
except (IndexError, AttributeError):
51-
site_packages_path = sysconfig.get_paths()['purelib']
52-
53-
project_root = Path(os.environ['GITHUB_WORKSPACE'])
54-
55-
builder_script = project_root / 'omnipkg' / 'package_meta_builder.py'
56-
if not builder_script.exists():
57-
print(f"Error: {builder_script} does not exist")
58-
sys.exit(1)
59-
60-
config_data = {
61-
'site_packages_path': site_packages_path,
62-
'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
63-
'python_executable': sys.executable,
64-
'builder_script_path': str(builder_script),
65-
'redis_host': 'localhost',
66-
'redis_port': 6379,
67-
'redis_key_prefix': 'omnipkg:pkg:',
68-
'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'],
69-
'auto_cleanup': True,
70-
'cleanup_threshold_days': 30
71-
}
72-
73-
config_dir = Path.home() / '.config' / 'omnipkg'
74-
config_dir.mkdir(parents=True, exist_ok=True)
75-
config_path = config_dir / 'config.json'
76-
77-
try:
78-
with open(config_path, 'w') as f:
79-
json.dump(config_data, f, indent=2)
80-
print(f'omnipkg config created at {config_path}:')
81-
print(json.dumps(config_data, indent=2))
82-
except Exception as e:
83-
print(f"Error writing config: {e}")
84-
sys.exit(1)
85-
EOF
86-
87-
- name: Run the Demo - NumPy + SciPy Stress Test
88-
id: run_demo
89-
run: |
90-
echo "--- Running Omnipkg Demo for NumPy + SciPy Stress Test (C-Extensions) ---"
91-
mkdir -p /tmp/omnipkg-artifacts
92-
93-
timeout 900 bash -c 'echo "3" | omnipkg demo 2>&1 | tee /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt'
94-
DEMO_EXIT_CODE=$?
95-
96-
echo "DEBUG: omnipkg demo exit code: $DEMO_EXIT_CODE"
97-
echo "## NumPy + SciPy Demo Output" >> $GITHUB_STEP_SUMMARY
98-
echo '```' >> $GITHUB_STEP_SUMMARY
99-
cat /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt >> $GITHUB_STEP_SUMMARY
100-
echo '```' >> $GITHUB_STEP_SUMMARY
101-
102-
if [ $DEMO_EXIT_CODE -eq 0 ] || \
103-
(grep -q "ALL TESTS PASSED!" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt && \
104-
grep -q "OMNIPKG SURVIVED NUCLEAR TESTING" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt && \
105-
grep -q "Demo completed successfully" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt); then
106-
echo "Demo completed successfully (exit code $DEMO_EXIT_CODE, logs verified)."
107-
echo "demo_outcome=success" >> $GITHUB_OUTPUT
108-
if grep -q "numpy==1.26.4" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt && \
109-
grep -q "scipy==1.16.1" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt && \
110-
grep -q "numpy==1.24.3" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt && \
111-
grep -q "scipy==1.12.0" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt && \
112-
grep -q "ALL TESTS PASSED!" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt && \
113-
grep -q "OMNIPKG SURVIVED NUCLEAR TESTING" /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt; then
114-
echo "NumPy + SciPy demo verified: numpy==1.26.4, 1.24.3, scipy==1.16.1, 1.12.0, all tests passed!"
115-
else
116-
echo "Error: Expected NumPy + SciPy demo output not found."
117-
echo "Missing one of: 'numpy==1.26.4', 'scipy==1.16.1', 'numpy==1.24.3', 'scipy==1.12.0', 'ALL TESTS PASSED!', or 'OMNIPKG SURVIVED NUCLEAR TESTING'"
118-
cat /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt
119-
exit 1
120-
fi
121-
else
122-
echo "Demo failed with exit code $DEMO_EXIT_CODE."
123-
echo "demo_outcome=failure" >> $GITHUB_OUTPUT
124-
cat /tmp/omnipkg-artifacts/numpy_scipy_demo_output.txt
125-
exit 1
126-
fi
127-
128-
- name: Archive Demo Output
129-
if: always()
130-
uses: actions/upload-artifact@v4
131-
with:
132-
name: omnipkg-numpy-scipy-demo-output
133-
path: /tmp/omnipkg-artifacts/
134-
retention-days: 7
135-
compression-level: 6
16+
- uses: actions/checkout@v4
17+
18+
- name: Set up Python 3.11
19+
uses: actions/setup-python@v4
20+
with:
21+
python-version: '3.11'
22+
23+
- name: Start Redis
24+
uses: supercharge/redis-github-action@1.7.0
25+
with:
26+
redis-version: 6
27+
redis-port: 6379
28+
29+
- name: Install Omnipkg
30+
run: |
31+
python -m pip install --upgrade pip
32+
pip install -e .
33+
34+
- name: Configure Omnipkg
35+
run: |
36+
python -c "
37+
import omnipkg
38+
config = omnipkg.create_config()
39+
print(f'omnipkg config created at {config}')
40+
with open(config, 'r') as f:
41+
print(f.read())
42+
"
43+
44+
- name: Run NumPy + SciPy Demo Test
45+
id: numpy_scipy_test
46+
run: |
47+
echo "--- Running Omnipkg Demo for NumPy + SciPy Stress Test (C-Extensions) ---"
48+
49+
# Run the demo with input "3" for NumPy + SciPy test
50+
# Capture all output to a file for validation
51+
python -c "
52+
import subprocess
53+
import sys
54+
55+
# Run the demo with automated input
56+
process = subprocess.Popen(
57+
[sys.executable, '-c', '''
58+
import omnipkg.demo
59+
import sys
60+
# Monkey patch input to automatically select option 3
61+
original_input = input
62+
def mock_input(prompt=\"\"):
63+
print(prompt + \"3\") # Print the prompt + our choice
64+
return \"3\"
65+
input = mock_input
66+
omnipkg.demo.main()
67+
'''],
68+
stdout=subprocess.PIPE,
69+
stderr=subprocess.STDOUT,
70+
text=True,
71+
bufsize=1
72+
)
73+
74+
output_lines = []
75+
# Stream output in real-time while capturing it
76+
for line in process.stdout:
77+
print(line, end='', flush=True)
78+
output_lines.append(line)
79+
80+
process.wait()
81+
full_output = ''.join(output_lines)
82+
83+
# Write output to file for validation
84+
with open('demo_output.txt', 'w') as f:
85+
f.write(full_output)
86+
87+
print(f'DEBUG: omnipkg demo exit code: {process.returncode}')
88+
89+
# Validate the output contains expected strings
90+
required_strings = [
91+
'numpy==1.26.4',
92+
'scipy==1.16.1',
93+
'numpy==1.24.3',
94+
'scipy==1.12.0',
95+
'OMNIPKG SURVIVED NUCLEAR TESTING'
96+
]
97+
98+
missing_strings = []
99+
for required in required_strings:
100+
if required not in full_output:
101+
missing_strings.append(required)
102+
103+
if missing_strings:
104+
print(f'Error: Expected NumPy + SciPy demo output not found.')
105+
print(f'Missing: {missing_strings}')
106+
print('--- FULL OUTPUT FOR DEBUGGING ---')
107+
print(full_output)
108+
print('--- END FULL OUTPUT ---')
109+
sys.exit(1)
110+
else:
111+
print('Demo completed successfully (exit code {}, logs verified).'.format(process.returncode))
112+
113+
# Exit with the same code as the demo
114+
sys.exit(process.returncode)
115+
" 2>&1
116+
117+
- name: Upload test artifacts
118+
uses: actions/upload-artifact@v4
119+
if: always()
120+
with:
121+
name: numpy-scipy-test-logs
122+
path: |
123+
demo_output.txt
124+
retention-days: 7

0 commit comments

Comments
 (0)