1+ #!/usr/bin/env python3
2+ """Test script for verifying Test PyPI and Docker releases"""
3+
4+ import subprocess
5+ import sys
6+
7+ def test_pypi ():
8+ print ("=== Testing Test PyPI Package ===" )
9+ print ("1. Creating virtual environment..." )
10+ subprocess .run ([sys .executable , "-m" , "venv" , "test_env" ], check = True )
11+
12+ print ("2. Installing from Test PyPI..." )
13+ pip_cmd = "./test_env/bin/pip" if sys .platform != "win32" else "test_env\\ Scripts\\ pip"
14+ subprocess .run ([
15+ pip_cmd , "install" , "-i" , "https://test.pypi.org/simple/" ,
16+ "--extra-index-url" , "https://pypi.org/simple/" , # For dependencies
17+ "crawl4ai==0.7.1"
18+ ], check = True )
19+
20+ print ("3. Testing import..." )
21+ python_cmd = "./test_env/bin/python" if sys .platform != "win32" else "test_env\\ Scripts\\ python"
22+ result = subprocess .run ([
23+ python_cmd , "-c" ,
24+ "from crawl4ai import AsyncWebCrawler; print('✅ Import successful!'); print(f'Version: {__import__(\" crawl4ai\" ).__version__}')"
25+ ], capture_output = True , text = True )
26+ print (result .stdout )
27+ if result .returncode != 0 :
28+ print (f"❌ Error: { result .stderr } " )
29+ return False
30+
31+ print ("4. Cleaning up..." )
32+ import shutil
33+ shutil .rmtree ("test_env" )
34+ print ("✅ Test PyPI package test passed!\n " )
35+ return True
36+
37+ def test_docker ():
38+ print ("=== Testing Docker Image ===" )
39+ print ("1. Pulling test image..." )
40+ subprocess .run (["docker" , "pull" , "unclecode/crawl4ai:test-0.7.1" ], check = True )
41+
42+ print ("2. Running version check..." )
43+ result = subprocess .run ([
44+ "docker" , "run" , "--rm" , "unclecode/crawl4ai:test-0.7.1" ,
45+ "python" , "-c" , "import crawl4ai; print(f'Version: {crawl4ai.__version__}')"
46+ ], capture_output = True , text = True )
47+ print (result .stdout )
48+
49+ print ("3. Testing crawl4ai-doctor command..." )
50+ result = subprocess .run ([
51+ "docker" , "run" , "--rm" , "unclecode/crawl4ai:test-0.7.1" ,
52+ "crawl4ai-doctor"
53+ ], capture_output = True , text = True )
54+ print (result .stdout [:500 ] + "..." if len (result .stdout ) > 500 else result .stdout )
55+
56+ print ("✅ Docker image test passed!\n " )
57+ return True
58+
59+ if __name__ == "__main__" :
60+ print ("🧪 Testing Crawl4AI Release Artifacts\n " )
61+
62+ pypi_ok = False
63+ docker_ok = False
64+
65+ try :
66+ pypi_ok = test_pypi ()
67+ except Exception as e :
68+ print (f"❌ Test PyPI test failed: { e } " )
69+
70+ try :
71+ docker_ok = test_docker ()
72+ except Exception as e :
73+ print (f"❌ Docker test failed: { e } " )
74+
75+ print ("\n 📊 Summary:" )
76+ print (f"Test PyPI: { '✅ Passed' if pypi_ok else '❌ Failed' } " )
77+ print (f"Docker Hub: { '✅ Passed' if docker_ok else '❌ Failed' } " )
78+
79+ if pypi_ok and docker_ok :
80+ print ("\n 🎉 All tests passed! Ready for production release." )
81+ else :
82+ print ("\n ⚠️ Some tests failed. Please fix before production release." )
83+ sys .exit (1 )
0 commit comments