Skip to content

Commit f9a2432

Browse files
authored
Update test-tensorflow-switching.yml
1 parent ad6020d commit f9a2432

1 file changed

Lines changed: 99 additions & 33 deletions

File tree

Lines changed: 99 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
# .github/workflows/test-tensorflow-switching.yml
21
name: 🧠 TensorFlow Complex Dependency Switching Test
32

43
on:
@@ -11,6 +10,16 @@ jobs:
1110
runs-on: ubuntu-latest
1211
permissions:
1312
contents: write
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
1423

1524
steps:
1625
- name: 🏁 Checkout code
@@ -21,18 +30,11 @@ jobs:
2130
with:
2231
python-version: '3.11'
2332

24-
- name: 🔧 Install Redis for omnipkg
25-
run: |
26-
sudo apt-get update
27-
sudo apt-get install -y redis-server
28-
sudo systemctl start redis-server
29-
redis-cli ping
30-
31-
- name: 📦 Install omnipkg (editable)
33+
- name: 📦 Install dependencies
3234
run: |
3335
python -m pip install --upgrade pip
34-
pip install -e .
35-
36+
pip install -e . redis tensorflow==2.13.0
37+
3638
- name: ⚙️ Configure omnipkg for non-interactive use
3739
run: |
3840
python - << 'EOF'
@@ -41,15 +43,28 @@ jobs:
4143
import json
4244
from pathlib import Path
4345
import os
46+
import sysconfig
4447
45-
site_packages_path = site.getsitepackages()[0]
48+
# Get site-packages path safely
49+
try:
50+
site_packages_path = site.getsitepackages()[0]
51+
except (IndexError, AttributeError):
52+
site_packages_path = sysconfig.get_paths()['purelib']
53+
54+
# Determine project root (where pyproject.toml is)
4655
project_root = Path(os.environ['GITHUB_WORKSPACE'])
56+
57+
# Verify builder script exists
58+
builder_script = project_root / 'omnipkg' / 'package_meta_builder.py'
59+
if not builder_script.exists():
60+
print(f"Error: {builder_script} does not exist")
61+
sys.exit(1)
4762
4863
config_data = {
4964
'site_packages_path': site_packages_path,
5065
'multiversion_base': str(Path(site_packages_path) / '.omnipkg_versions'),
5166
'python_executable': sys.executable,
52-
'builder_script_path': str(project_root / 'omnipkg' / 'package_meta_builder.py'),
67+
'builder_script_path': str(builder_script),
5368
'redis_host': 'localhost',
5469
'redis_port': 6379,
5570
'redis_key_prefix': 'omnipkg:pkg:',
@@ -61,38 +76,75 @@ jobs:
6176
config_dir = Path.home() / '.config' / 'omnipkg'
6277
config_dir.mkdir(parents=True, exist_ok=True)
6378
config_path = config_dir / 'config.json'
64-
65-
with open(config_path, 'w') as f:
66-
json.dump(config_data, f, indent=2)
67-
68-
print(f'omnipkg config created at {config_path}:')
69-
print(json.dumps(config_data, indent=2))
79+
80+
try:
81+
with open(config_path, 'w') as f:
82+
json.dump(config_data, f, indent=2)
83+
print(f'omnipkg config created at {config_path}:')
84+
print(json.dumps(config_data, indent=2))
85+
except Exception as e:
86+
print(f"Error writing config: {e}")
87+
sys.exit(1)
7088
EOF
7189
72-
- name: 🧪 Run the Demo: TensorFlow Test (Complex Dependencies)
90+
- name: 🧪 Run the Demo - TensorFlow Test (Complex Dependencies)
7391
id: run_demo
7492
run: |
7593
echo "--- Running Omnipkg Demo for TensorFlow Test (Complex Dependencies) ---"
76-
# Simulate user input '4' for TensorFlow test
77-
DEMO_OUTPUT=$(echo "4" | omnipkg demo 2>&1)
94+
mkdir -p /tmp/omnipkg-artifacts
95+
96+
timeout 600 bash -c 'echo "4" | omnipkg demo 2>&1 | tee /tmp/omnipkg-artifacts/tensorflow_demo_output.txt'
7897
DEMO_EXIT_CODE=$?
7998
80-
echo "$DEMO_OUTPUT" > /tmp/demo_output.txt
99+
echo "## TensorFlow Demo Output" >> $GITHUB_STEP_SUMMARY
100+
echo '```' >> $GITHUB_STEP_SUMMARY
101+
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt >> $GITHUB_STEP_SUMMARY
102+
echo '```' >> $GITHUB_STEP_SUMMARY
81103
82104
if [ $DEMO_EXIT_CODE -eq 0 ]; then
83-
echo "demo_outcome=success" >> $GITHUB_OUTPUT
84105
echo "Demo completed successfully."
106+
echo "demo_outcome=success" >> $GITHUB_OUTPUT
107+
if grep -q "tensorflow==2.13.0" /tmp/omnipkg-artifacts/tensorflow_demo_output.txt && \
108+
grep -q "typing_extensions==4.5.0" /tmp/omnipkg-artifacts/tensorflow_demo_output.txt && \
109+
grep -q "ALL TENSORFLOW TESTS PASSED" /tmp/omnipkg-artifacts/tensorflow_demo_output.txt; then
110+
echo "TensorFlow demo verified: tensorflow==2.13.0, typing_extensions==4.5.0, and all tests passed!"
111+
else
112+
echo "Error: Expected TensorFlow demo output not found."
113+
echo "Missing one of: 'tensorflow==2.13.0', 'typing_extensions==4.5.0', or 'ALL TENSORFLOW TESTS PASSED'"
114+
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt
115+
exit 1
116+
fi
85117
else
86-
echo "demo_outcome=failure" >> $GITHUB_OUTPUT
87118
echo "Demo failed with exit code $DEMO_EXIT_CODE."
88-
echo "$DEMO_OUTPUT" # Output to job log on failure
89-
exit 1
119+
echo "demo_outcome=failure" >> $GITHUB_OUTPUT
120+
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt
121+
exit 1
122+
fi
123+
124+
- name: 📊 Check Omnipkg Status
125+
id: check_status
126+
run: |
127+
echo "--- Checking Omnipkg Status ---"
128+
mkdir -p /tmp/omnipkg-artifacts
129+
omnipkg status > /tmp/omnipkg-artifacts/status_output.txt
130+
echo "## Omnipkg Status Output" >> $GITHUB_STEP_SUMMARY
131+
echo '```' >> $GITHUB_STEP_SUMMARY
132+
cat /tmp/omnipkg-artifacts/status_output.txt >> $GITHUB_STEP_SUMMARY
133+
echo '```' >> $GITHUB_STEP_SUMMARY
134+
135+
if grep -q "tensorflow-2.13.0" /tmp/omnipkg-artifacts/status_output.txt && \
136+
grep -q "typing_extensions-4.5.0" /tmp/omnipkg-artifacts/status_output.txt; then
137+
echo "Status verified: TensorFlow bubbles found!"
138+
else
139+
echo "Error: Expected TensorFlow bubbles not found in status output."
140+
cat /tmp/omnipkg-artifacts/status_output.txt
141+
exit 1
90142
fi
91143
92144
- name: 📊 Generate Report
93145
if: always()
94146
run: |
95-
REPORT_FILE="tensorflow_test_report.md"
147+
REPORT_FILE="/tmp/omnipkg-artifacts/tensorflow_test_report.md"
96148
echo "# 🧠 TensorFlow Complex Dependency Switching Test Report" > $REPORT_FILE
97149
echo "" >> $REPORT_FILE
98150
echo "**Workflow Run:** [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }})" >> $REPORT_FILE
@@ -101,7 +153,13 @@ jobs:
101153
102154
echo "## Demo Execution Output" >> $REPORT_FILE
103155
echo "\`\`\`" >> $REPORT_FILE
104-
cat /tmp/demo_output.txt 2>/dev/null || echo 'N/A: Demo output missing.' >> $REPORT_FILE
156+
cat /tmp/omnipkg-artifacts/tensorflow_demo_output.txt 2>/dev/null || echo 'N/A: Demo output missing.' >> $REPORT_FILE
157+
echo "\`\`\`" >> $REPORT_FILE
158+
echo "" >> $REPORT_FILE
159+
160+
echo "## Omnipkg Status Output" >> $REPORT_FILE
161+
echo "\`\`\`" >> $REPORT_FILE
162+
cat /tmp/omnipkg-artifacts/status_output.txt 2>/dev/null || echo 'N/A: Status output missing.' >> $REPORT_FILE
105163
echo "\`\`\`" >> $REPORT_FILE
106164
echo "" >> $REPORT_FILE
107165
@@ -112,10 +170,18 @@ jobs:
112170
echo "❌ The TensorFlow Complex Dependency Switching Test failed. Review workflow logs for detailed output and errors." >> $REPORT_FILE
113171
fi
114172
echo "" >> $REPORT_FILE
115-
116-
- name: 📤 Upload Report Artifact
173+
174+
- name: 🧹 Clean Up Redis
175+
if: always()
176+
run: |
177+
echo "--- Cleaning Up Redis ---"
178+
redis-cli -h localhost -p 6379 KEYS "omnipkg:pkg:*" | xargs -r redis-cli -h localhost -p 6379 DEL
179+
180+
- name: 📦 Upload Artifacts
181+
if: always()
117182
uses: actions/upload-artifact@v4
118183
with:
119-
name: tensorflow-test-report
120-
path: tensorflow_test_report.md
184+
name: omnipkg-tensorflow-outputs
185+
path: /tmp/omnipkg-artifacts/
121186
retention-days: 30
187+
compression-level: 6

0 commit comments

Comments
 (0)