Skip to content

Commit ec2ee23

Browse files
committed
ci: Fix trailing whitespace
Signed-off-by: Chaitanya Tata <[email protected]>
1 parent 76c7feb commit ec2ee23

File tree

1 file changed

+54
-54
lines changed

1 file changed

+54
-54
lines changed

.github/workflows/module-monitor.yml

Lines changed: 54 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -53,18 +53,18 @@ jobs:
5353
echo "DEBUG: Current HEAD is $(git rev-parse HEAD)" >&2
5454
echo "DEBUG: Available commits:" >&2
5555
git log --oneline -5 >&2
56-
56+
5757
# Get old and new module.yml content
5858
echo "DEBUG: Getting old module.yml from $BASE_REF" >&2
5959
git show $BASE_REF:zephyr/module.yml > old_module.yml
6060
echo "DEBUG: Getting new module.yml from pr-head" >&2
6161
git show pr-head:zephyr/module.yml > new_module.yml
62-
62+
6363
echo "DEBUG: Old module.yml content:" >&2
6464
head -5 old_module.yml >&2
6565
echo "DEBUG: New module.yml content:" >&2
6666
head -5 new_module.yml >&2
67-
67+
6868
# Parse YAML and generate comparison table
6969
echo "DEBUG: Starting Python script..." >&2
7070
python3 << 'PYTHON_SCRIPT_EOF'
@@ -90,7 +90,7 @@ jobs:
9090
"""Parse and fix version string format"""
9191
if version_str == 'N/A':
9292
return version_str
93-
93+
9494
# Split by dots and reverse the order if it looks like it's reversed
9595
parts = version_str.split('.')
9696
if len(parts) >= 4:
@@ -106,7 +106,7 @@ jobs:
106106
except ValueError:
107107
# If we can't parse as integers, return as is
108108
pass
109-
109+
110110
return version_str
111111
112112
def get_commit_info(commit_hash):
@@ -115,14 +115,14 @@ jobs:
115115
import subprocess
116116
import json
117117
import os
118-
118+
119119
# Use the cloned sdk-nrfxlib repository
120120
sdk_repo_dir = 'sdk-nrfxlib-repo'
121121
if not os.path.exists(sdk_repo_dir):
122122
return {'hash': commit_hash[:7] if commit_hash != "Unknown" else "Unknown"}
123-
123+
124124
# Get commit details from the sdk-nrfxlib repository
125-
result = subprocess.run(['git', 'log', '--format=%H|%s|%an|%ad', '--date=short', '-1', commit_hash],
125+
result = subprocess.run(['git', 'log', '--format=%H|%s|%an|%ad', '--date=short', '-1', commit_hash],
126126
cwd=sdk_repo_dir, capture_output=True, text=True, timeout=10)
127127
if result.returncode == 0 and result.stdout.strip():
128128
parts = result.stdout.strip().split('|')
@@ -135,7 +135,7 @@ jobs:
135135
}
136136
except:
137137
pass
138-
138+
139139
# Fallback: return basic info
140140
return {'hash': commit_hash[:7] if commit_hash != "Unknown" else "Unknown"}
141141
@@ -145,14 +145,14 @@ jobs:
145145
import subprocess
146146
import os
147147
import re
148-
148+
149149
# First, check if we have PR metadata in the new module.yml file
150150
try:
151151
with open(new_module_file, 'r') as f:
152152
content = f.read()
153153
print(f"DEBUG: Looking for PR metadata in module.yml for commit {commit_hash}", file=sys.stderr)
154154
print(f"DEBUG: Module.yml content starts with: {content[:200]}", file=sys.stderr)
155-
155+
156156
# Look for PR metadata comment (more flexible pattern)
157157
pr_match = re.search(r'# Generated from PR #(\d+) \(commit: ([a-f0-9]+)\)', content)
158158
if pr_match:
@@ -173,28 +173,28 @@ jobs:
173173
except Exception as e:
174174
print(f"DEBUG: Error reading module.yml: {e}", file=sys.stderr)
175175
pass
176-
176+
177177
# Change to sdk-nrfxlib repository directory
178178
sdk_repo_dir = 'sdk-nrfxlib-repo'
179179
if not os.path.exists(sdk_repo_dir):
180180
return {'display': commit_hash[:7] if commit_hash != "Unknown" else "Unknown"}
181-
181+
182182
# Get all branches containing this commit
183-
result = subprocess.run(['git', 'branch', '-r', '--contains', commit_hash],
183+
result = subprocess.run(['git', 'branch', '-r', '--contains', commit_hash],
184184
cwd=sdk_repo_dir, capture_output=True, text=True, timeout=10)
185185
if result.returncode == 0:
186186
branches = result.stdout.strip().split('\n')
187187
branch_names = []
188188
is_on_main = False
189-
189+
190190
for branch in branches:
191191
branch = branch.strip()
192192
if branch:
193193
branch_name = branch.replace('origin/', '')
194194
branch_names.append(branch_name)
195195
if branch_name in ['main', 'master']:
196196
is_on_main = True
197-
197+
198198
if is_on_main:
199199
return {
200200
'display': f"[{commit_hash[:7]} (main)](https://github.com/nrfconnect/sdk-nrfxlib/commit/{commit_hash})" if commit_hash != "Unknown" else "Unknown (main)"
@@ -206,7 +206,7 @@ jobs:
206206
}
207207
except:
208208
pass
209-
209+
210210
# Default: show short commit hash with clickable link
211211
if commit_hash != "Unknown":
212212
return {
@@ -221,7 +221,7 @@ jobs:
221221
"""Generate diff link for the source repository"""
222222
old_commit = extract_commit_from_url(old_url)
223223
new_commit = extract_commit_from_url(new_url)
224-
224+
225225
if old_commit != "Unknown" and new_commit != "Unknown" and old_commit != new_commit:
226226
return f"https://github.com/nrfconnect/sdk-nrfxlib/compare/{old_commit}...{new_commit}"
227227
elif new_commit != "Unknown":
@@ -236,60 +236,60 @@ jobs:
236236
print("DEBUG: Loading new_module.yml...", file=sys.stderr)
237237
with open('new_module.yml', 'r') as f:
238238
new_data = yaml.safe_load(f)
239-
239+
240240
old_blobs = {blob['path']: blob for blob in old_data.get('blobs', [])}
241241
new_blobs = {blob['path']: blob for blob in new_data.get('blobs', [])}
242-
242+
243243
# Generate comparison table
244244
table_rows = []
245245
table_rows.append("| Variant | Old Version | New Version | Old Commit | New Commit | Diff Link |")
246246
table_rows.append("|---------|-------------|-------------|------------|------------|-----------|")
247-
247+
248248
all_paths = set(old_blobs.keys()) | set(new_blobs.keys())
249-
249+
250250
for path in sorted(all_paths):
251251
old_blob = old_blobs.get(path, {})
252252
new_blob = new_blobs.get(path, {})
253-
253+
254254
old_version = parse_version(old_blob.get('version', 'N/A'))
255255
new_version = parse_version(new_blob.get('version', 'N/A'))
256256
old_commit_hash = extract_commit_from_url(old_blob.get('url', ''))
257257
new_commit_hash = extract_commit_from_url(new_blob.get('url', ''))
258-
258+
259259
# Get additional commit information
260260
old_commit_info = get_commit_info(old_commit_hash)
261261
new_commit_info = get_commit_info(new_commit_hash)
262-
262+
263263
# Check commit status (merged vs PR)
264264
old_commit_status = get_commit_status(old_commit_hash)
265265
new_commit_status = get_commit_status(new_commit_hash)
266-
266+
267267
# Format commit display with PR detection
268268
print(f"DEBUG: Processing {path} - old_commit: {old_commit_hash}, new_commit: {new_commit_hash}", file=sys.stderr)
269269
old_commit_status = get_commit_status(old_commit_hash, 'old_module.yml')
270270
new_commit_status = get_commit_status(new_commit_hash, 'new_module.yml')
271271
old_commit_display = old_commit_status['display']
272272
new_commit_display = new_commit_status['display']
273273
print(f"DEBUG: {path} - old_display: {old_commit_display}, new_display: {new_commit_display}", file=sys.stderr)
274-
274+
275275
diff_link = generate_diff_link(old_blob.get('url', ''), new_blob.get('url', ''))
276-
276+
277277
# Extract variant name from path
278278
variant = path.split('/')[-2] if '/' in path else path
279-
279+
280280
table_rows.append(f"| {variant} | {old_version} | {new_version} | {old_commit_display} | {new_commit_display} | {diff_link} |")
281-
281+
282282
# Check if there are any actual changes
283283
has_changes = False
284284
for path in sorted(all_paths):
285285
old_blob = old_blobs.get(path, {})
286286
new_blob = new_blobs.get(path, {})
287-
if (old_blob.get('version') != new_blob.get('version') or
287+
if (old_blob.get('version') != new_blob.get('version') or
288288
old_blob.get('sha256') != new_blob.get('sha256') or
289289
old_blob.get('url') != new_blob.get('url')):
290290
has_changes = True
291291
break
292-
292+
293293
# Output the table
294294
diff_content = []
295295
if has_changes:
@@ -306,20 +306,20 @@ jobs:
306306
summary_rows = []
307307
summary_rows.append("| Variant | Version | Commit |")
308308
summary_rows.append("|---------|---------|--------|")
309-
309+
310310
for path in sorted(all_paths):
311311
new_blob = new_blobs.get(path, {})
312312
version = parse_version(new_blob.get('version', 'N/A'))
313313
commit_hash = extract_commit_from_url(new_blob.get('url', ''))
314314
commit_display = commit_hash[:7] if commit_hash != "Unknown" else "Unknown"
315-
315+
316316
# Extract variant name from path
317317
variant = path.split('/')[-2] if '/' in path else path
318-
318+
319319
summary_rows.append(f"| {variant} | {version} | {commit_display} |")
320-
320+
321321
diff_content.extend(summary_rows)
322-
322+
323323
# Check for PR references to determine if DNM label should be added/removed
324324
has_pr_reference = False
325325
try:
@@ -332,18 +332,18 @@ jobs:
332332
print(f"DEBUG: Found PR reference: PR #{pr_match.group(1)}", file=sys.stderr)
333333
except Exception as e:
334334
print(f"DEBUG: Error checking for PR reference: {e}", file=sys.stderr)
335-
335+
336336
# Write PR reference status to file for GitHub Actions
337337
with open('pr_reference_status.txt', 'w') as f:
338338
f.write('true' if has_pr_reference else 'false')
339-
339+
340340
# Write to file for GitHub Actions output
341341
print(f"DEBUG: Writing {len(diff_content)} lines to diff_output.txt", file=sys.stderr)
342342
with open('diff_output.txt', 'w') as f:
343343
f.write('\n'.join(diff_content))
344-
344+
345345
print(f"DEBUG: Successfully wrote diff_output.txt", file=sys.stderr)
346-
346+
347347
except Exception as e:
348348
print(f"Error generating comparison: {e}", file=sys.stderr)
349349
print("DEBUG: Python script completed successfully", file=sys.stderr)
@@ -354,7 +354,7 @@ jobs:
354354
run: |
355355
echo "DEBUG: Checking if files exist..." >&2
356356
ls -la *.txt >&2 || echo "No .txt files found" >&2
357-
357+
358358
if [ -f diff_output.txt ]; then
359359
echo "DEBUG: diff_output.txt exists, size: $(wc -c < diff_output.txt)" >&2
360360
# Use base64 encoding to avoid delimiter conflicts
@@ -364,7 +364,7 @@ jobs:
364364
echo "DEBUG: diff_output.txt not found" >&2
365365
echo "diff_output_encoded=" >> $GITHUB_OUTPUT
366366
fi
367-
367+
368368
if [ -f pr_reference_status.txt ]; then
369369
echo "DEBUG: pr_reference_status.txt exists" >&2
370370
PR_REFERENCE_STATUS=$(cat pr_reference_status.txt)
@@ -373,7 +373,7 @@ jobs:
373373
echo "DEBUG: pr_reference_status.txt not found" >&2
374374
echo "has_pr_reference=false" >> $GITHUB_OUTPUT
375375
fi
376-
376+
377377
378378
379379
- name: Create or update comment
@@ -391,28 +391,28 @@ jobs:
391391
diffOutput = 'Error decoding output';
392392
}
393393
}
394-
394+
395395
console.log('DEBUG: diff_output length:', diffOutput.length);
396-
397-
const commentBody = '## Module Monitor\n\nChanges detected in module.yml\n\n' +
396+
397+
const commentBody = '## Module Monitor\n\nChanges detected in module.yml\n\n' +
398398
diffOutput + '\n\n' +
399399
'This comment was automatically generated.';
400400
401401
// Handle DNM label management
402402
const hasPrReference = process.env.has_pr_reference === 'true';
403403
console.log('DEBUG: has_pr_reference:', hasPrReference);
404-
404+
405405
try {
406406
// Get current labels
407407
const { data: currentLabels } = await github.rest.issues.listLabelsOnIssue({
408408
owner: context.repo.owner,
409409
repo: context.repo.repo,
410410
issue_number: context.issue.number
411411
});
412-
412+
413413
const hasDnmLabel = currentLabels.some(label => label.name === 'DNM');
414414
console.log('DEBUG: Current DNM label status:', hasDnmLabel);
415-
415+
416416
// Add DNM label if PR reference is found and label doesn't exist
417417
if (hasPrReference && !hasDnmLabel) {
418418
console.log('Adding DNM label due to PR reference');
@@ -447,11 +447,11 @@ jobs:
447447
repo: context.repo.repo,
448448
issue_number: context.issue.number
449449
});
450-
451-
const existingComment = comments.find(comment =>
450+
451+
const existingComment = comments.find(comment =>
452452
comment.body.includes('Module Monitor')
453453
);
454-
454+
455455
if (existingComment) {
456456
await github.rest.issues.updateComment({
457457
owner: context.repo.owner,
@@ -476,7 +476,7 @@ jobs:
476476
console.log('---');
477477
console.log(commentBody);
478478
console.log('---');
479-
479+
480480
// Don't fail the workflow - the PR detection worked correctly
481481
console.log('Workflow completed successfully - PR detection and diff generation worked correctly.');
482482
}

0 commit comments

Comments
 (0)