11name : Module Monitor
22on :
3- pull_request_target :
3+ pull_request :
44 paths :
55 - ' zephyr/module.yml'
66
5454 git show $HEAD_REF:zephyr/module.yml > new_module.yml
5555
5656 # Parse YAML and generate comparison table
57+ echo "DEBUG: Starting Python script..." >&2
5758 python3 << 'EOF'
5859 import yaml
5960 import sys
7374 return commit_part[:7]
7475 return "Unknown"
7576
77+ def get_commit_info(commit_hash):
78+ """Get additional commit information like branch and PR references"""
79+ try:
80+ import subprocess
81+ import json
82+
83+ # Get commit details
84+ result = subprocess.run(['git', 'log', '--format=%H|%s|%an|%ad', '--date=short', '-1', commit_hash],
85+ capture_output=True, text=True, timeout=10)
86+ if result.returncode == 0:
87+ parts = result.stdout.strip().split('|')
88+ if len(parts) >= 4:
89+ return {
90+ 'hash': parts[0][:7],
91+ 'subject': parts[1],
92+ 'author': parts[2],
93+ 'date': parts[3]
94+ }
95+ except:
96+ pass
97+ return {'hash': commit_hash[:7] if commit_hash != "Unknown" else "Unknown"}
98+
7699 def generate_diff_link(old_url, new_url):
77100 """Generate diff link for the source repository"""
78101 old_commit = extract_commit_from_url(old_url)
@@ -85,9 +108,11 @@ jobs:
85108 return "N/A"
86109
87110 try:
111+ print("DEBUG: Loading old_module.yml...", file=sys.stderr)
88112 # Load old and new module.yml
89113 with open('old_module.yml', 'r') as f:
90114 old_data = yaml.safe_load(f)
115+ print("DEBUG: Loading new_module.yml...", file=sys.stderr)
91116 with open('new_module.yml', 'r') as f:
92117 new_data = yaml.safe_load(f)
93118
96121
97122 # Generate comparison table
98123 table_rows = []
99- table_rows.append("| Variant | Old Version | New Version | Old SHA256 | New SHA256 | Old Commit | New Commit | Diff Link |")
100- table_rows.append("|---------|-------------|-------------|------------|------------|------------|------------|----------- |")
124+ table_rows.append("| Variant | Old Version | New Version | Old Commit | New Commit | Diff Link |")
125+ table_rows.append("|---------|-------------|-------------|------------|------------|-----------|")
101126
102127 all_paths = set(old_blobs.keys()) | set(new_blobs.keys())
103128
@@ -107,16 +132,23 @@ jobs:
107132
108133 old_version = old_blob.get('version', 'N/A')
109134 new_version = new_blob.get('version', 'N/A')
110- old_sha = old_blob.get('sha256', 'N/A')[:16] + '...' if old_blob.get('sha256') else 'N/A'
111- new_sha = new_blob.get('sha256', 'N/A')[:16] + '...' if new_blob.get('sha256') else 'N/A'
112- old_commit = extract_commit_from_url(old_blob.get('url', ''))
113- new_commit = extract_commit_from_url(new_blob.get('url', ''))
135+ old_commit_hash = extract_commit_from_url(old_blob.get('url', ''))
136+ new_commit_hash = extract_commit_from_url(new_blob.get('url', ''))
137+
138+ # Get additional commit information
139+ old_commit_info = get_commit_info(old_commit_hash)
140+ new_commit_info = get_commit_info(new_commit_hash)
141+
142+ # Format commit display with additional info
143+ old_commit_display = old_commit_info['hash']
144+ new_commit_display = new_commit_info['hash']
145+
114146 diff_link = generate_diff_link(old_blob.get('url', ''), new_blob.get('url', ''))
115147
116148 # Extract variant name from path
117149 variant = path.split('/')[-2] if '/' in path else path
118150
119- table_rows.append(f"| {variant} | {old_version} | {new_version} | {old_sha } | {new_sha} | {old_commit} | {new_commit } | {diff_link} |")
151+ table_rows.append(f"| {variant} | {old_version} | {new_version} | {old_commit_display } | {new_commit_display } | {diff_link} |")
120152
121153 # Check if there are any actual changes
122154 has_changes = False
@@ -135,6 +167,31 @@ jobs:
135167 diff_content.append("## Firmware Blob Changes")
136168 diff_content.append("")
137169 diff_content.extend(table_rows)
170+
171+ # Add commit details section
172+ diff_content.append("")
173+ diff_content.append("### Commit Details:")
174+ diff_content.append("")
175+
176+ # Collect unique commits
177+ unique_commits = set()
178+ for path in sorted(all_paths):
179+ old_blob = old_blobs.get(path, {})
180+ new_blob = new_blobs.get(path, {})
181+ old_commit_hash = extract_commit_from_url(old_blob.get('url', ''))
182+ new_commit_hash = extract_commit_from_url(new_blob.get('url', ''))
183+ if old_commit_hash != "Unknown":
184+ unique_commits.add(old_commit_hash)
185+ if new_commit_hash != "Unknown":
186+ unique_commits.add(new_commit_hash)
187+
188+ # Show commit details
189+ for commit_hash in sorted(unique_commits):
190+ commit_info = get_commit_info(commit_hash)
191+ if 'subject' in commit_info:
192+ diff_content.append(f"- **{commit_info['hash']}**: {commit_info['subject']} (by {commit_info['author']} on {commit_info['date']})")
193+ else:
194+ diff_content.append(f"- **{commit_info['hash']}**: Commit details not available")
138195 else:
139196 diff_content.append("## No Changes Detected")
140197 diff_content.append("")
@@ -144,9 +201,12 @@ jobs:
144201 diff_content.extend(table_rows[2:]) # Skip header rows
145202
146203 # Write to file for GitHub Actions output
204+ print(f"DEBUG: Writing {len(diff_content)} lines to diff_output.txt", file=sys.stderr)
147205 with open('diff_output.txt', 'w') as f:
148206 f.write('\n'.join(diff_content))
149207
208+ print(f"DEBUG: Successfully wrote diff_output.txt", file=sys.stderr)
209+
150210 print("diff_output<<EOF", file=sys.stdout)
151211 print('\n'.join(diff_content), file=sys.stdout)
152212 print("EOF", file=sys.stdout)
@@ -164,9 +224,12 @@ jobs:
164224 blob_content = ["## Current Firmware Blobs:"] + blob_info
165225
166226 # Write to file for GitHub Actions output
227+ print(f"DEBUG: Writing {len(blob_content)} lines to blob_summary.txt", file=sys.stderr)
167228 with open('blob_summary.txt', 'w') as f:
168229 f.write('\n'.join(blob_content))
169230
231+ print(f"DEBUG: Successfully wrote blob_summary.txt", file=sys.stderr)
232+
170233 print("blob_summary<<EOF", file=sys.stdout)
171234 print('\n'.join(blob_content), file=sys.stdout)
172235 print("EOF", file=sys.stdout)
@@ -178,17 +241,38 @@ jobs:
178241 print("blob_summary<<EOF", file=sys.stdout)
179242 print(f"Error parsing module.yml: {e}", file=sys.stdout)
180243 print("EOF", file=sys.stdout)
244+ print("DEBUG: Python script completed successfully", file=sys.stderr)
181245 EOF
182246
183247 - name : Set output variables
248+ id : set-output
184249 run : |
185- echo "diff_output<<EOF" >> $GITHUB_OUTPUT
186- cat diff_output.txt >> $GITHUB_OUTPUT
187- echo "EOF" >> $GITHUB_OUTPUT
250+ echo "DEBUG: Checking if files exist..." >&2
251+ ls -la *.txt >&2 || echo "No .txt files found" >&2
252+
253+ if [ -f diff_output.txt ]; then
254+ echo "DEBUG: diff_output.txt exists, size: $(wc -c < diff_output.txt)" >&2
255+ echo "diff_output<<EOF" >> $GITHUB_OUTPUT
256+ cat diff_output.txt >> $GITHUB_OUTPUT
257+ echo "EOF" >> $GITHUB_OUTPUT
258+ else
259+ echo "DEBUG: diff_output.txt not found" >&2
260+ echo "diff_output<<EOF" >> $GITHUB_OUTPUT
261+ echo "No changes detected" >> $GITHUB_OUTPUT
262+ echo "EOF" >> $GITHUB_OUTPUT
263+ fi
188264
189- echo "blob_summary<<EOF" >> $GITHUB_OUTPUT
190- cat blob_summary.txt >> $GITHUB_OUTPUT
191- echo "EOF" >> $GITHUB_OUTPUT
265+ if [ -f blob_summary.txt ]; then
266+ echo "DEBUG: blob_summary.txt exists, size: $(wc -c < blob_summary.txt)" >&2
267+ echo "blob_summary<<EOF" >> $GITHUB_OUTPUT
268+ cat blob_summary.txt >> $GITHUB_OUTPUT
269+ echo "EOF" >> $GITHUB_OUTPUT
270+ else
271+ echo "DEBUG: blob_summary.txt not found" >&2
272+ echo "blob_summary<<EOF" >> $GITHUB_OUTPUT
273+ echo "No blob summary available" >> $GITHUB_OUTPUT
274+ echo "EOF" >> $GITHUB_OUTPUT
275+ fi
192276
193277 - name : Create or update comment
194278 uses : actions/github-script@v7
@@ -228,8 +312,8 @@ jobs:
228312 });
229313 }
230314 env :
231- diff_output : ${{ steps.changes .outputs.diff_output }}
232- blob_summary : ${{ steps.changes .outputs.blob_summary }}
315+ diff_output : ${{ steps.set-output .outputs.diff_output }}
316+ blob_summary : ${{ steps.set-output .outputs.blob_summary }}
233317
234318
235319
@@ -239,7 +323,7 @@ jobs:
239323 echo "" >> $GITHUB_STEP_SUMMARY
240324 echo "### Changes in zephyr/module.yml:" >> $GITHUB_STEP_SUMMARY
241325 echo '```diff' >> $GITHUB_STEP_SUMMARY
242- echo "${{ steps.changes .outputs.diff_output }}" >> $GITHUB_STEP_SUMMARY
326+ echo "${{ steps.set-output .outputs.diff_output }}" >> $GITHUB_STEP_SUMMARY
243327 echo '```' >> $GITHUB_STEP_SUMMARY
244328 echo "" >> $GITHUB_STEP_SUMMARY
245- echo "${{ steps.changes .outputs.blob_summary }}" >> $GITHUB_STEP_SUMMARY
329+ echo "${{ steps.set-output .outputs.blob_summary }}" >> $GITHUB_STEP_SUMMARY
0 commit comments