fix: replace heredoc with echo commands in integration-tests.yml
All checks were successful
security-scanning / audit (push) Successful in 1m35s

INTEGRATION TESTS YAML FIX: Resolve line 218 could not find expected ':' error

Issues Fixed:
 yaml: line 218: could not find expected ':'
 Heredoc causing YAML parsing issues in integration-tests.yml
 Workflow config file invalid
 Multi-line content being parsed as YAML

Root Cause:
- Heredoc syntax in integration-tests.yml causing YAML parsing errors
- Multi-line Python script content being interpreted as YAML
- YAML parser expecting key-value pairs throughout
- Heredoc syntax incompatible with YAML structure

Solution Applied:
 Replaced heredoc with echo commands
 Line-by-line Python script creation
 Proper YAML syntax throughout
 Valid shell script commands

Implementation Changes:
- Removed heredoc syntax completely
- Used echo commands for each Python line
- Proper shell escaping for quotes and strings
- Line-by-line file construction

Generated Content:
- Complete Python integration test script
- Service-to-service communication tests
- API endpoint testing functions
- Cross-service validation logic

Impact:
- YAML file now validates correctly
- Workflow config file is valid
- Integration test script creation works
- CI/CD execution without syntax errors
- Complete test functionality preserved

This resolves the YAML syntax error that was preventing
the integration tests workflow from being parsed correctly.
This commit is contained in:
2026-03-27 23:47:12 +01:00
parent a759810085
commit 620f3c70fb

View File

@@ -214,64 +214,62 @@ jobs:
echo "🔗 Testing service-to-service communication..." echo "🔗 Testing service-to-service communication..."
# Create test script # Create test script
cat > test_integration.py << 'EOF' echo 'import requests' > test_integration.py
import requests echo 'import json' >> test_integration.py
import json echo 'import time' >> test_integration.py
import time echo '' >> test_integration.py
echo 'def test_coordinator_api():' >> test_integration.py
def test_coordinator_api(): echo ' try:' >> test_integration.py
try: echo ' response = requests.get('"'"'http://localhost:8000/'"'"', timeout=5)' >> test_integration.py
response = requests.get('http://localhost:8000/', timeout=5) echo ' print(f"✅ Coordinator API responded: {response.status_code}")' >> test_integration.py
print(f"✅ Coordinator API responded: {response.status_code}") echo ' return True' >> test_integration.py
return True echo ' except Exception as e:' >> test_integration.py
except Exception as e: echo ' print(f"❌ Coordinator API error: {e}")' >> test_integration.py
print(f"❌ Coordinator API error: {e}") echo ' return False' >> test_integration.py
return False echo '' >> test_integration.py
echo 'def test_blockchain_rpc():' >> test_integration.py
def test_blockchain_rpc(): echo ' try:' >> test_integration.py
try: echo ' payload = {' >> test_integration.py
payload = { echo ' "jsonrpc": "2.0",' >> test_integration.py
"jsonrpc": "2.0", echo ' "method": "eth_blockNumber",' >> test_integration.py
"method": "eth_blockNumber", echo ' "params": [],' >> test_integration.py
"params": [], echo ' "id": 1' >> test_integration.py
"id": 1 echo ' }' >> test_integration.py
} echo ' response = requests.post('"'"'http://localhost:8545'"'"', json=payload, timeout=5)' >> test_integration.py
response = requests.post('http://localhost:8545', json=payload, timeout=5) echo ' if response.status_code == 200:' >> test_integration.py
if response.status_code == 200: echo ' result = response.json()' >> test_integration.py
result = response.json() echo ' print(f"✅ Blockchain RPC responded: {result.get('"'"'result'"'"', '"'"'Unknown'"'"')}")' >> test_integration.py
print(f"✅ Blockchain RPC responded: {result.get('result', 'Unknown')}") echo ' return True' >> test_integration.py
return True echo ' except Exception as e:' >> test_integration.py
except Exception as e: echo ' print(f"❌ Blockchain RPC error: {e}")' >> test_integration.py
print(f"❌ Blockchain RPC error: {e}") echo ' return False' >> test_integration.py
return False echo '' >> test_integration.py
echo 'def test_marketplace():' >> test_integration.py
def test_marketplace(): echo ' try:' >> test_integration.py
try: echo ' response = requests.get('"'"'http://localhost:3001/'"'"', timeout=5)' >> test_integration.py
response = requests.get('http://localhost:3001/', timeout=5) echo ' print(f"✅ Marketplace responded: {response.status_code}")' >> test_integration.py
print(f"✅ Marketplace responded: {response.status_code}") echo ' return True' >> test_integration.py
return True echo ' except Exception as e:' >> test_integration.py
except Exception as e: echo ' print(f"❌ Marketplace error: {e}")' >> test_integration.py
print(f"❌ Marketplace error: {e}") echo ' return False' >> test_integration.py
return False echo '' >> test_integration.py
echo 'if __name__ == "__main__":' >> test_integration.py
if __name__ == "__main__": echo ' print("🧪 Running cross-service communication tests...")' >> test_integration.py
print("🧪 Running cross-service communication tests...") echo ' ' >> test_integration.py
echo ' results = []' >> test_integration.py
results = [] echo ' results.append(test_coordinator_api())' >> test_integration.py
results.append(test_coordinator_api()) echo ' results.append(test_blockchain_rpc())' >> test_integration.py
results.append(test_blockchain_rpc()) echo ' results.append(test_marketplace())' >> test_integration.py
results.append(test_marketplace()) echo ' ' >> test_integration.py
echo ' success_count = sum(results)' >> test_integration.py
success_count = sum(results) echo ' total_count = len(results)' >> test_integration.py
total_count = len(results) echo ' ' >> test_integration.py
echo ' print(f"\n📊 Test Results: {success_count}/{total_count} services working")' >> test_integration.py
print(f"\n📊 Test Results: {success_count}/{total_count} services working") echo ' ' >> test_integration.py
echo ' if success_count == total_count:' >> test_integration.py
if success_count == total_count: echo ' print("✅ All services communicating successfully")' >> test_integration.py
print("✅ All services communicating successfully") echo ' else:' >> test_integration.py
else: echo ' print("⚠️ Some services not communicating properly")' >> test_integration.py
print("⚠️ Some services not communicating properly")
EOF
# Run integration test # Run integration test
python test_integration.py python test_integration.py