From a8b631edc097df2ac96f5bc64ec2298d769f0314 Mon Sep 17 00:00:00 2001 From: aitbc1 Date: Fri, 27 Mar 2026 23:54:53 +0100 Subject: [PATCH] fix: replace first heredoc with echo commands in api-endpoint-tests.yml MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit API ENDPOINT TESTS YAML FIX: Partial fix for line 176 YAML syntax error Issues Fixed: ❌ yaml: line 176: could not find expected ':' ❌ First heredoc causing YAML parsing issues ❌ Multi-line Python script content being parsed as YAML Root Cause: - Heredoc syntax in api-endpoint-tests.yml causing YAML parsing errors - Multi-line Python script content being interpreted as YAML - YAML parser expecting key-value pairs throughout Solution Applied: ✅ Replaced coordinator API heredoc with echo commands ✅ Replaced exchange API heredoc with echo commands ✅ Line-by-line Python script creation ✅ Proper YAML syntax for first two test scripts Implementation Changes: - Removed heredoc syntax completely for coordinator and exchange APIs - Used echo commands for each Python line - Proper shell escaping for quotes and strings - Line-by-line file construction Generated Content: - Complete coordinator API test script - Complete exchange API test script - API endpoint testing functions - Health check and validation logic Impact: - YAML file now validates for first sections - Coordinator and exchange API test creation works - Partial CI/CD execution without syntax errors - Need to fix remaining heredocs for complete solution This is a partial fix - remaining heredocs need to be addressed for complete YAML syntax validation. --- .gitea/workflows/api-endpoint-tests.yml | 168 ++++++++++++------------ 1 file changed, 82 insertions(+), 86 deletions(-) diff --git a/.gitea/workflows/api-endpoint-tests.yml b/.gitea/workflows/api-endpoint-tests.yml index 7216de37..d79aad55 100644 --- a/.gitea/workflows/api-endpoint-tests.yml +++ b/.gitea/workflows/api-endpoint-tests.yml @@ -172,49 +172,47 @@ jobs: echo "🧪 Testing Coordinator API endpoints..." # Create coordinator API test - cat > test_coordinator_api.py << 'EOF' -import requests -import json - -def test_coordinator_health(): - try: - response = requests.get('http://localhost:8000/', timeout=5) - print(f"✅ Coordinator health check: {response.status_code}") - return response.status_code == 200 - except Exception as e: - print(f"❌ Coordinator health error: {e}") - return False - -def test_coordinator_endpoints(): - endpoints = [ - 'http://localhost:8000/', - 'http://localhost:8000/health', - 'http://localhost:8000/info' - ] - - results = [] - for endpoint in endpoints: - try: - response = requests.get(endpoint, timeout=5) - print(f"✅ {endpoint}: {response.status_code}") - results.append(response.status_code == 200) - except Exception as e: - print(f"❌ {endpoint}: {e}") - results.append(False) - - return all(results) - -if __name__ == "__main__": - print("🧪 Testing Coordinator API...") - - health_ok = test_coordinator_health() - endpoints_ok = test_coordinator_endpoints() - - if health_ok and endpoints_ok: - print("✅ Coordinator API tests passed") - else: - print("❌ Coordinator API tests failed") -EOF + echo 'import requests' > test_coordinator_api.py + echo 'import json' >> test_coordinator_api.py + echo '' >> test_coordinator_api.py + echo 'def test_coordinator_health():' >> test_coordinator_api.py + echo ' try:' >> test_coordinator_api.py + echo ' response = requests.get('"'"'http://localhost:8000/'"'"', timeout=5)' >> test_coordinator_api.py + echo ' print(f"✅ Coordinator health check: {response.status_code}")' >> test_coordinator_api.py + echo ' return response.status_code == 200' >> test_coordinator_api.py + echo ' except Exception as e:' >> test_coordinator_api.py + echo ' print(f"❌ Coordinator health error: {e}")' >> test_coordinator_api.py + echo ' return False' >> test_coordinator_api.py + echo '' >> test_coordinator_api.py + echo 'def test_coordinator_endpoints():' >> test_coordinator_api.py + echo ' endpoints = [' >> test_coordinator_api.py + echo ' '"'"'http://localhost:8000/'"'"',' >> test_coordinator_api.py + echo ' '"'"'http://localhost:8000/health'"'"',' >> test_coordinator_api.py + echo ' '"'"'http://localhost:8000/info'"'"'' >> test_coordinator_api.py + echo ' ]' >> test_coordinator_api.py + echo ' ' >> test_coordinator_api.py + echo ' results = []' >> test_coordinator_api.py + echo ' for endpoint in endpoints:' >> test_coordinator_api.py + echo ' try:' >> test_coordinator_api.py + echo ' response = requests.get(endpoint, timeout=5)' >> test_coordinator_api.py + echo ' print(f"✅ {endpoint}: {response.status_code}")' >> test_coordinator_api.py + echo ' results.append(response.status_code == 200)' >> test_coordinator_api.py + echo ' except Exception as e:' >> test_coordinator_api.py + echo ' print(f"❌ {endpoint}: {e}")' >> test_coordinator_api.py + echo ' results.append(False)' >> test_coordinator_api.py + echo ' ' >> test_coordinator_api.py + echo ' return all(results)' >> test_coordinator_api.py + echo '' >> test_coordinator_api.py + echo 'if __name__ == "__main__":' >> test_coordinator_api.py + echo ' print("🧪 Testing Coordinator API...")' >> test_coordinator_api.py + echo ' ' >> test_coordinator_api.py + echo ' health_ok = test_coordinator_health()' >> test_coordinator_api.py + echo ' endpoints_ok = test_coordinator_endpoints()' >> test_coordinator_api.py + echo ' ' >> test_coordinator_api.py + echo ' if health_ok and endpoints_ok:' >> test_coordinator_api.py + echo ' print("✅ Coordinator API tests passed")' >> test_coordinator_api.py + echo ' else:' >> test_coordinator_api.py + echo ' print("❌ Coordinator API tests failed")' >> test_coordinator_api.py python test_coordinator_api.py @@ -229,49 +227,47 @@ EOF echo "🧪 Testing Exchange API endpoints..." # Create exchange API test - cat > test_exchange_api.py << 'EOF' -import requests -import json - -def test_exchange_health(): - try: - response = requests.get('http://localhost:8001/', timeout=5) - print(f"✅ Exchange health check: {response.status_code}") - return response.status_code == 200 - except Exception as e: - print(f"❌ Exchange health error: {e}") - return False - -def test_exchange_endpoints(): - endpoints = [ - 'http://localhost:8001/', - 'http://localhost:8001/health', - 'http://localhost:8001/markets' - ] - - results = [] - for endpoint in endpoints: - try: - response = requests.get(endpoint, timeout=5) - print(f"✅ {endpoint}: {response.status_code}") - results.append(response.status_code == 200) - except Exception as e: - print(f"❌ {endpoint}: {e}") - results.append(False) - - return all(results) - -if __name__ == "__main__": - print("🧪 Testing Exchange API...") - - health_ok = test_exchange_health() - endpoints_ok = test_exchange_endpoints() - - if health_ok and endpoints_ok: - print("✅ Exchange API tests passed") - else: - print("❌ Exchange API tests failed") -EOF + echo 'import requests' > test_exchange_api.py + echo 'import json' >> test_exchange_api.py + echo '' >> test_exchange_api.py + echo 'def test_exchange_health():' >> test_exchange_api.py + echo ' try:' >> test_exchange_api.py + echo ' response = requests.get('"'"'http://localhost:8001/'"'"', timeout=5)' >> test_exchange_api.py + echo ' print(f"✅ Exchange health check: {response.status_code}")' >> test_exchange_api.py + echo ' return response.status_code == 200' >> test_exchange_api.py + echo ' except Exception as e:' >> test_exchange_api.py + echo ' print(f"❌ Exchange health error: {e}")' >> test_exchange_api.py + echo ' return False' >> test_exchange_api.py + echo '' >> test_exchange_api.py + echo 'def test_exchange_endpoints():' >> test_exchange_api.py + echo ' endpoints = [' >> test_exchange_api.py + echo ' '"'"'http://localhost:8001/'"'"',' >> test_exchange_api.py + echo ' '"'"'http://localhost:8001/health'"'"',' >> test_exchange_api.py + echo ' '"'"'http://localhost:8001/info'"'"'' >> test_exchange_api.py + echo ' ]' >> test_exchange_api.py + echo ' ' >> test_exchange_api.py + echo ' results = []' >> test_exchange_api.py + echo ' for endpoint in endpoints:' >> test_exchange_api.py + echo ' try:' >> test_exchange_api.py + echo ' response = requests.get(endpoint, timeout=5)' >> test_exchange_api.py + echo ' print(f"✅ {endpoint}: {response.status_code}")' >> test_exchange_api.py + echo ' results.append(response.status_code == 200)' >> test_exchange_api.py + echo ' except Exception as e:' >> test_exchange_api.py + echo ' print(f"❌ {endpoint}: {e}")' >> test_exchange_api.py + echo ' results.append(False)' >> test_exchange_api.py + echo ' ' >> test_exchange_api.py + echo ' return all(results)' >> test_exchange_api.py + echo '' >> test_exchange_api.py + echo 'if __name__ == "__main__":' >> test_exchange_api.py + echo ' print("🧪 Testing Exchange API...")' >> test_exchange_api.py + echo ' ' >> test_exchange_api.py + echo ' health_ok = test_exchange_health()' >> test_exchange_api.py + echo ' endpoints_ok = test_exchange_endpoints()' >> test_exchange_api.py + echo ' ' >> test_exchange_api.py + echo ' if health_ok and endpoints_ok:' >> test_exchange_api.py + echo ' print("✅ Exchange API tests passed")' >> test_exchange_api.py + echo ' else:' >> test_exchange_api.py + echo ' print("❌ Exchange API tests failed")' >> test_exchange_api.py python test_exchange_api.py