-
-
Notifications
You must be signed in to change notification settings - Fork 1
142 lines (123 loc) · 5.3 KB
/
Copy pathtest-tensorflow-switching.yml
File metadata and controls
142 lines (123 loc) · 5.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
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
name: TensorFlow Complex Dependency Switching
on:
push:
branches: [ main ]
pull_request:
branches: [ main ]
workflow_dispatch:
jobs:
test:
runs-on: ubuntu-latest
services:
redis:
image: redis:7
options: >-
--health-cmd "redis-cli ping"
--health-interval 10s
--health-timeout 5s
--health-retries 5
ports:
- 6379:6379
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Python 3.11
uses: actions/setup-python@v5
with:
python-version: '3.11'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -e . redis tensorflow==2.13.0
- name: Configure omnipkg for non-interactive use
run: |
python - << 'EOF'
import sys
import site
import json
from pathlib import Path
import os
import sysconfig
try:
site_packages_path = site.getsitepackages()[0]
except (IndexError, AttributeError):
site_packages_path = sysconfig.get_paths()['purelib']
project_root = Path(os.environ['GITHUB_WORKSPACE'])
builder_script = project_root / 'omnipkg' / 'package_meta_builder.py'
if not builder_script.exists():
print(f"Error: {builder_script} does not exist")
sys.exit(1)
config_data = {
'site_packages_path': site_packages_path,
'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
'python_executable': sys.executable,
'builder_script_path': str(builder_script),
'redis_host': 'localhost',
'redis_port': 6379,
'redis_key_prefix': 'omnipkg:pkg:',
'paths_to_index': [str(Path(sys.executable).parent), '/usr/local/bin', '/usr/bin', '/bin', '/usr/sbin', '/sbin'],
'auto_cleanup': True,
'cleanup_threshold_days': 30
}
config_dir = Path.home() / '.config' / 'omnipkg'
config_dir.mkdir(parents=True, exist_ok=True)
config_path = config_dir / 'config.json'
try:
with open(config_path, 'w') as f:
json.dump(config_data, f, indent=2)
print(f'omnipkg config created at {config_path}:')
print(json.dumps(config_data, indent=2))
except Exception as e:
print(f"Error writing config: {e}")
sys.exit(1)
EOF
- name: Run the Demo - TensorFlow
id: run_demo
run: |
echo "--- Running Omnipkg Demo for TensorFlow (Complex Dependencies) ---"
mkdir -p /tmp/omnipkg-artifacts
# Clear output file and track run count
rm -f /tmp/omnipkg-artifacts/tensorflow_demo_output.txt
echo "Starting demo run" > /tmp/omnipkg-artifacts/run_count.txt
# Run demo once
timeout 900 bash -c 'echo "4" | omnipkg demo 2>&1 | tee /tmp/omnipkg-artifacts/tensorflow_demo_output.txt'
DEMO_EXIT_CODE=$?
# Check run count
RUN_COUNT=$(grep -c "Starting demo run" /tmp/omnipkg-artifacts/run_count.txt)
echo "DEBUG: Demo run count: $RUN_COUNT"
if [ "$RUN_COUNT" -ne 1 ]; then
echo "Error: Demo ran $RUN_COUNT times instead of once."
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt
exit 1
fi
echo "## TensorFlow Demo Output" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
if [ $DEMO_EXIT_CODE -eq 0 ] || \
(grep -q "ALL TENSORFLOW TESTS PASSED" /tmp/omnipkg-artifacts/tensorflow_demo_output.txt && \
grep -q "Demo completed successfully" /tmp/omnipkg-artifacts/tensorflow_demo_output.txt); then
echo "Demo completed successfully (exit code $DEMO_EXIT_CODE, logs verified)."
echo "demo_outcome=success" >> $GITHUB_OUTPUT
PASSED_COUNT=$(grep -c "PASSED" /tmp/omnipkg-artifacts/tensorflow_demo_output.txt || echo "0")
if [ "$PASSED_COUNT" -ge 4 ] && grep -q "tensorflow==2.13.0" /tmp/omnipkg-artifacts/tensorflow_demo_output.txt; then
echo "TensorFlow demo verified: Found $PASSED_COUNT PASSED results (expected at least 4) and tensorflow==2.13.0!"
else
echo "Error: Expected at least 4 PASSED results and tensorflow==2.13.0, but found only $PASSED_COUNT or missing tensorflow version."
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt
exit 1
fi
else
echo "Demo failed with exit code $DEMO_EXIT_CODE."
echo "demo_outcome=failure" >> $GITHUB_OUTPUT
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt
exit 1
fi
- name: Archive Demo Output
if: always()
uses: actions/upload-artifact@v4
with:
name: omnipkg-tensorflow-demo-output
path: /tmp/omnipkg-artifacts/
retention-days: 7
compression-level: 6