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+
99+ def get_pr_info(commit_hash):
100+ """Check if commit is part of a PR and get PR information"""
101+ try:
102+ import subprocess
103+ import requests
104+
105+ # Try to find PRs containing this commit
106+ result = subprocess.run(['git', 'log', '--oneline', '--grep=^Merge pull request', '-i', commit_hash],
107+ capture_output=True, text=True, timeout=10)
108+
109+ if result.returncode == 0 and result.stdout.strip():
110+ # Look for PR number in merge commit messages
111+ import re
112+ pr_match = re.search(r'#(\d+)', result.stdout)
113+ if pr_match:
114+ pr_number = pr_match.group(1)
115+ return {
116+ 'is_pr': True,
117+ 'pr_number': pr_number,
118+ 'pr_url': f"https://github.com/nrfconnect/sdk-nrfxlib/pull/{pr_number}"
119+ }
120+
121+ # Alternative: check if commit is on a feature branch (not main/master)
122+ result = subprocess.run(['git', 'branch', '-r', '--contains', commit_hash],
123+ capture_output=True, text=True, timeout=10)
124+ if result.returncode == 0:
125+ branches = result.stdout.strip().split('\n')
126+ for branch in branches:
127+ branch = branch.strip()
128+ if branch and not any(main_branch in branch for main_branch in ['origin/main', 'origin/master']):
129+ # This is likely a feature branch, might have a PR
130+ return {
131+ 'is_pr': True,
132+ 'pr_number': '?',
133+ 'pr_url': f"https://github.com/nrfconnect/sdk-nrfxlib/pulls?q=is:pr+{commit_hash}"
134+ }
135+ except:
136+ pass
137+
138+ return {'is_pr': False}
139+
76140 def generate_diff_link(old_url, new_url):
77141 """Generate diff link for the source repository"""
78142 old_commit = extract_commit_from_url(old_url)
@@ -85,9 +149,11 @@ jobs:
85149 return "N/A"
86150
87151 try:
152+ print("DEBUG: Loading old_module.yml...", file=sys.stderr)
88153 # Load old and new module.yml
89154 with open('old_module.yml', 'r') as f:
90155 old_data = yaml.safe_load(f)
156+ print("DEBUG: Loading new_module.yml...", file=sys.stderr)
91157 with open('new_module.yml', 'r') as f:
92158 new_data = yaml.safe_load(f)
93159
96162
97163 # Generate comparison table
98164 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("|---------|-------------|-------------|------------|------------|------------|------------|----------- |")
165+ table_rows.append("| Variant | Old Version | New Version | Old Commit | New Commit | Diff Link |")
166+ table_rows.append("|---------|-------------|-------------|------------|------------|-----------|")
101167
102168 all_paths = set(old_blobs.keys()) | set(new_blobs.keys())
103169
@@ -107,16 +173,34 @@ jobs:
107173
108174 old_version = old_blob.get('version', 'N/A')
109175 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', ''))
176+ old_commit_hash = extract_commit_from_url(old_blob.get('url', ''))
177+ new_commit_hash = extract_commit_from_url(new_blob.get('url', ''))
178+
179+ # Get additional commit information
180+ old_commit_info = get_commit_info(old_commit_hash)
181+ new_commit_info = get_commit_info(new_commit_hash)
182+
183+ # Check for PR information
184+ old_pr_info = get_pr_info(old_commit_hash)
185+ new_pr_info = get_pr_info(new_commit_hash)
186+
187+ # Format commit display with PR links when available
188+ if old_pr_info['is_pr']:
189+ old_commit_display = f"[{old_commit_info['hash']}]({old_pr_info['pr_url']})"
190+ else:
191+ old_commit_display = old_commit_info['hash']
192+
193+ if new_pr_info['is_pr']:
194+ new_commit_display = f"[{new_commit_info['hash']}]({new_pr_info['pr_url']})"
195+ else:
196+ new_commit_display = new_commit_info['hash']
197+
114198 diff_link = generate_diff_link(old_blob.get('url', ''), new_blob.get('url', ''))
115199
116200 # Extract variant name from path
117201 variant = path.split('/')[-2] if '/' in path else path
118202
119- table_rows.append(f"| {variant} | {old_version} | {new_version} | {old_sha } | {new_sha} | {old_commit} | {new_commit } | {diff_link} |")
203+ table_rows.append(f"| {variant} | {old_version} | {new_version} | {old_commit_display } | {new_commit_display } | {diff_link} |")
120204
121205 # Check if there are any actual changes
122206 has_changes = False
@@ -135,6 +219,39 @@ jobs:
135219 diff_content.append("## Firmware Blob Changes")
136220 diff_content.append("")
137221 diff_content.extend(table_rows)
222+
223+ # Add commit details section
224+ diff_content.append("")
225+ diff_content.append("### Commit Details:")
226+ diff_content.append("")
227+
228+ # Collect unique commits
229+ unique_commits = set()
230+ for path in sorted(all_paths):
231+ old_blob = old_blobs.get(path, {})
232+ new_blob = new_blobs.get(path, {})
233+ old_commit_hash = extract_commit_from_url(old_blob.get('url', ''))
234+ new_commit_hash = extract_commit_from_url(new_blob.get('url', ''))
235+ if old_commit_hash != "Unknown":
236+ unique_commits.add(old_commit_hash)
237+ if new_commit_hash != "Unknown":
238+ unique_commits.add(new_commit_hash)
239+
240+ # Show commit details
241+ for commit_hash in sorted(unique_commits):
242+ commit_info = get_commit_info(commit_hash)
243+ pr_info = get_pr_info(commit_hash)
244+
245+ if 'subject' in commit_info:
246+ commit_line = f"- **{commit_info['hash']}**: {commit_info['subject']} (by {commit_info['author']} on {commit_info['date']})"
247+ if pr_info['is_pr']:
248+ commit_line += f" - [PR #{pr_info['pr_number']}]({pr_info['pr_url']})"
249+ diff_content.append(commit_line)
250+ else:
251+ commit_line = f"- **{commit_info['hash']}**: Commit details not available"
252+ if pr_info['is_pr']:
253+ commit_line += f" - [PR #{pr_info['pr_number']}]({pr_info['pr_url']})"
254+ diff_content.append(commit_line)
138255 else:
139256 diff_content.append("## No Changes Detected")
140257 diff_content.append("")
@@ -144,9 +261,12 @@ jobs:
144261 diff_content.extend(table_rows[2:]) # Skip header rows
145262
146263 # Write to file for GitHub Actions output
264+ print(f"DEBUG: Writing {len(diff_content)} lines to diff_output.txt", file=sys.stderr)
147265 with open('diff_output.txt', 'w') as f:
148266 f.write('\n'.join(diff_content))
149267
268+ print(f"DEBUG: Successfully wrote diff_output.txt", file=sys.stderr)
269+
150270 print("diff_output<<EOF", file=sys.stdout)
151271 print('\n'.join(diff_content), file=sys.stdout)
152272 print("EOF", file=sys.stdout)
@@ -164,9 +284,12 @@ jobs:
164284 blob_content = ["## Current Firmware Blobs:"] + blob_info
165285
166286 # Write to file for GitHub Actions output
287+ print(f"DEBUG: Writing {len(blob_content)} lines to blob_summary.txt", file=sys.stderr)
167288 with open('blob_summary.txt', 'w') as f:
168289 f.write('\n'.join(blob_content))
169290
291+ print(f"DEBUG: Successfully wrote blob_summary.txt", file=sys.stderr)
292+
170293 print("blob_summary<<EOF", file=sys.stdout)
171294 print('\n'.join(blob_content), file=sys.stdout)
172295 print("EOF", file=sys.stdout)
@@ -178,17 +301,38 @@ jobs:
178301 print("blob_summary<<EOF", file=sys.stdout)
179302 print(f"Error parsing module.yml: {e}", file=sys.stdout)
180303 print("EOF", file=sys.stdout)
304+ print("DEBUG: Python script completed successfully", file=sys.stderr)
181305 EOF
182306
183307 - name : Set output variables
308+ id : set-output
184309 run : |
185- echo "diff_output<<EOF" >> $GITHUB_OUTPUT
186- cat diff_output.txt >> $GITHUB_OUTPUT
187- echo "EOF" >> $GITHUB_OUTPUT
310+ echo "DEBUG: Checking if files exist..." >&2
311+ ls -la *.txt >&2 || echo "No .txt files found" >&2
312+
313+ if [ -f diff_output.txt ]; then
314+ echo "DEBUG: diff_output.txt exists, size: $(wc -c < diff_output.txt)" >&2
315+ echo "diff_output<<EOF" >> $GITHUB_OUTPUT
316+ cat diff_output.txt >> $GITHUB_OUTPUT
317+ echo "EOF" >> $GITHUB_OUTPUT
318+ else
319+ echo "DEBUG: diff_output.txt not found" >&2
320+ echo "diff_output<<EOF" >> $GITHUB_OUTPUT
321+ echo "No changes detected" >> $GITHUB_OUTPUT
322+ echo "EOF" >> $GITHUB_OUTPUT
323+ fi
188324
189- echo "blob_summary<<EOF" >> $GITHUB_OUTPUT
190- cat blob_summary.txt >> $GITHUB_OUTPUT
191- echo "EOF" >> $GITHUB_OUTPUT
325+ if [ -f blob_summary.txt ]; then
326+ echo "DEBUG: blob_summary.txt exists, size: $(wc -c < blob_summary.txt)" >&2
327+ echo "blob_summary<<EOF" >> $GITHUB_OUTPUT
328+ cat blob_summary.txt >> $GITHUB_OUTPUT
329+ echo "EOF" >> $GITHUB_OUTPUT
330+ else
331+ echo "DEBUG: blob_summary.txt not found" >&2
332+ echo "blob_summary<<EOF" >> $GITHUB_OUTPUT
333+ echo "No blob summary available" >> $GITHUB_OUTPUT
334+ echo "EOF" >> $GITHUB_OUTPUT
335+ fi
192336
193337 - name : Create or update comment
194338 uses : actions/github-script@v7
@@ -228,8 +372,8 @@ jobs:
228372 });
229373 }
230374 env :
231- diff_output : ${{ steps.changes .outputs.diff_output }}
232- blob_summary : ${{ steps.changes .outputs.blob_summary }}
375+ diff_output : ${{ steps.set-output .outputs.diff_output }}
376+ blob_summary : ${{ steps.set-output .outputs.blob_summary }}
233377
234378
235379
@@ -239,7 +383,7 @@ jobs:
239383 echo "" >> $GITHUB_STEP_SUMMARY
240384 echo "### Changes in zephyr/module.yml:" >> $GITHUB_STEP_SUMMARY
241385 echo '```diff' >> $GITHUB_STEP_SUMMARY
242- echo "${{ steps.changes .outputs.diff_output }}" >> $GITHUB_STEP_SUMMARY
386+ echo "${{ steps.set-output .outputs.diff_output }}" >> $GITHUB_STEP_SUMMARY
243387 echo '```' >> $GITHUB_STEP_SUMMARY
244388 echo "" >> $GITHUB_STEP_SUMMARY
245- echo "${{ steps.changes .outputs.blob_summary }}" >> $GITHUB_STEP_SUMMARY
389+ echo "${{ steps.set-output .outputs.blob_summary }}" >> $GITHUB_STEP_SUMMARY
0 commit comments