Skip to content

Commit 7ed8dd8

Browse files
committed
fix: Correct YAML syntax in harmony-check workflow with proper heredoc indentation
Fixed critical YAML syntax error in harmony-check.yml caused by incorrect heredoc indentation: **Problem:** - Python heredoc content and terminators were unindented (column 0) - This broke YAML's literal block (run: |) parsing - YAML parser failed with "could not find expected ':'" error - GitHub Actions workflows would not run **Root Cause:** In YAML literal blocks (|), all lines must maintain consistent base indentation. The heredoc pattern `python3 << 'EOF'` with unindented Python code and EOF terminator violated this requirement. **Solution:** 1. Changed `<< 'PYTHON_SCRIPT'` to `<<'PYTHON_SCRIPT'` (no space) 2. Indented all Python code to match surrounding bash code (10 spaces) 3. Indented PYTHON_SCRIPT terminators to match (10 spaces) This preserves YAML structure while bash correctly strips the indentation when processing the heredoc. **Files Fixed:** - Job 2 (harmony-json-report), Step 3: Generate JSON Harmony Report - Job 2 (harmony-json-report), Step 5: Display Top 5 Disharmonious Functions **Testing:** - ✅ YAML validates with Python yaml.safe_load() - ✅ Extracted bash script executes correctly - ✅ JSON parsing works as expected - ✅ All heredoc syntax functional This resolves the CI workflow failures reported by the user.
1 parent 89c805e commit 7ed8dd8

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

.github/workflows/harmony-check.yml

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -82,23 +82,23 @@ jobs:
8282
if [ -f harmony-report.json ] && [ -s harmony-report.json ]; then
8383
echo ""
8484
echo "📊 Harmony Summary:"
85-
python3 << 'PYTHON_SCRIPT'
86-
import json
87-
try:
88-
with open('harmony-report.json') as f:
89-
data = json.load(f)
90-
summary = data.get('summary', {})
91-
print(f" Total files: {summary.get('total_files', 0)}")
92-
print(f" Total functions: {summary.get('total_functions', 0)}")
93-
print(" Severity breakdown:")
94-
for sev, count in summary.get('severity_counts', {}).items():
95-
if count > 0:
96-
emoji = {'critical': '🔴', 'high': '🟠', 'medium': '🟡', 'low': '🔵', 'excellent': '🟢'}.get(sev, '⚪')
97-
print(f" {emoji} {sev.capitalize()}: {count}")
98-
print(f" Highest severity: {summary.get('highest_severity', 'unknown')}")
99-
except Exception as e:
100-
print(f"Error parsing report: {e}")
101-
PYTHON_SCRIPT
85+
python3 <<'PYTHON_SCRIPT'
86+
import json
87+
try:
88+
with open('harmony-report.json') as f:
89+
data = json.load(f)
90+
summary = data.get('summary', {})
91+
print(f" Total files: {summary.get('total_files', 0)}")
92+
print(f" Total functions: {summary.get('total_functions', 0)}")
93+
print(" Severity breakdown:")
94+
for sev, count in summary.get('severity_counts', {}).items():
95+
if count > 0:
96+
emoji = {'critical': '🔴', 'high': '🟠', 'medium': '🟡', 'low': '🔵', 'excellent': '🟢'}.get(sev, '⚪')
97+
print(f" {emoji} {sev.capitalize()}: {count}")
98+
print(f" Highest severity: {summary.get('highest_severity', 'unknown')}")
99+
except Exception as e:
100+
print(f"Error parsing report: {e}")
101+
PYTHON_SCRIPT
102102
else
103103
echo "⚠️ No harmony report generated"
104104
fi
@@ -116,31 +116,31 @@ PYTHON_SCRIPT
116116
if [ -f harmony-report.json ] && [ -s harmony-report.json ]; then
117117
echo ""
118118
echo "🎯 Top 5 Functions to Refactor:"
119-
python3 << 'PYTHON_SCRIPT'
120-
import json
121-
try:
122-
with open('harmony-report.json') as f:
123-
data = json.load(f)
124-
funcs = []
125-
for file_data in data.get('files', []):
126-
for func in file_data.get('functions', []):
127-
if func.get('disharmonious'):
128-
funcs.append((
129-
func.get('score', 0),
130-
func.get('name', 'unknown'),
131-
file_data.get('file', 'unknown'),
132-
func.get('severity', 'unknown')
133-
))
134-
funcs.sort(reverse=True)
135-
if funcs:
136-
for i, (score, name, filepath, sev) in enumerate(funcs[:5], 1):
137-
emoji = {'critical': '🔴', 'high': '🟠', 'medium': '🟡'}.get(sev, '⚪')
138-
print(f" {i}. {emoji} {name} ({score:.2f}) in {filepath}")
139-
else:
140-
print(' 🎉 No disharmonious functions found!')
141-
except Exception as e:
142-
print(f"Error parsing report: {e}")
143-
PYTHON_SCRIPT
119+
python3 <<'PYTHON_SCRIPT'
120+
import json
121+
try:
122+
with open('harmony-report.json') as f:
123+
data = json.load(f)
124+
funcs = []
125+
for file_data in data.get('files', []):
126+
for func in file_data.get('functions', []):
127+
if func.get('disharmonious'):
128+
funcs.append((
129+
func.get('score', 0),
130+
func.get('name', 'unknown'),
131+
file_data.get('file', 'unknown'),
132+
func.get('severity', 'unknown')
133+
))
134+
funcs.sort(reverse=True)
135+
if funcs:
136+
for i, (score, name, filepath, sev) in enumerate(funcs[:5], 1):
137+
emoji = {'critical': '🔴', 'high': '🟠', 'medium': '🟡'}.get(sev, '⚪')
138+
print(f" {i}. {emoji} {name} ({score:.2f}) in {filepath}")
139+
else:
140+
print(' 🎉 No disharmonious functions found!')
141+
except Exception as e:
142+
print(f"Error parsing report: {e}")
143+
PYTHON_SCRIPT
144144
fi
145145
if: success() || failure()
146146

0 commit comments

Comments
 (0)