Skip to content

nrf_wifi : Update Wi-Fi FW blobs and shared header file #19

nrf_wifi : Update Wi-Fi FW blobs and shared header file

nrf_wifi : Update Wi-Fi FW blobs and shared header file #19

name: Module Monitor
on:
pull_request_target:
paths:
- 'zephyr/module.yml'
permissions:
contents: read
pull-requests: write
issues: write
jobs:
module-monitor:
runs-on: ubuntu-24.04
name: Monitor Module Changes
steps:
- name: Checkout the code
uses: actions/checkout@v4
with:
fetch-depth: 0
persist-credentials: false
ref: ${{ github.event.pull_request.head.sha }}
- name: Fetch PR head
run: |
git fetch origin pull/${{ github.event.pull_request.number }}/head:pr-head
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: 3.12
- name: Install PyYAML
run: |
pip install pyyaml
- name: Get module.yml changes and blob info
id: changes
env:
GITHUB_EVENT_NAME: ${{ github.event_name }}
GITHUB_BASE_SHA: ${{ github.event.pull_request.base.sha || '' }}
GITHUB_HEAD_SHA: ${{ github.event.pull_request.head.sha || '' }}
run: |
# Compare with base branch for pull requests
BASE_REF="$GITHUB_BASE_SHA"
HEAD_REF="$GITHUB_HEAD_SHA"
echo "DEBUG: Comparing $BASE_REF to $HEAD_REF" >&2
echo "DEBUG: Current HEAD is $(git rev-parse HEAD)" >&2
echo "DEBUG: Available commits:" >&2
git log --oneline -5 >&2
# Get old and new module.yml content
git show $BASE_REF:zephyr/module.yml > old_module.yml
git show $HEAD_REF:zephyr/module.yml > new_module.yml
# Parse YAML and generate comparison table
python3 << 'EOF'
import yaml
import sys
import os
import re
from urllib.parse import urlparse
def extract_commit_from_url(url):
"""Extract commit hash from GitHub raw URL"""
if 'raw/' in url:
parts = url.split('raw/')
if len(parts) > 1:
commit_part = parts[1].split('/')[0]
if len(commit_part) == 40: # Full SHA
return commit_part
elif len(commit_part) >= 7: # Short SHA
return commit_part[:7]
return "Unknown"
def generate_diff_link(old_url, new_url):
"""Generate diff link for the source repository"""
old_commit = extract_commit_from_url(old_url)
new_commit = extract_commit_from_url(new_url)
if old_commit != "Unknown" and new_commit != "Unknown" and old_commit != new_commit:
return f"https://github.com/nrfconnect/sdk-nrfxlib/compare/{old_commit}...{new_commit}"
elif new_commit != "Unknown":
return f"https://github.com/nrfconnect/sdk-nrfxlib/commit/{new_commit}"
return "N/A"
try:
# Load old and new module.yml
with open('old_module.yml', 'r') as f:
old_data = yaml.safe_load(f)
with open('new_module.yml', 'r') as f:
new_data = yaml.safe_load(f)
old_blobs = {blob['path']: blob for blob in old_data.get('blobs', [])}
new_blobs = {blob['path']: blob for blob in new_data.get('blobs', [])}
# Generate comparison table
table_rows = []
table_rows.append("| Variant | Old Version | New Version | Old SHA256 | New SHA256 | Old Commit | New Commit | Diff Link |")
table_rows.append("|---------|-------------|-------------|------------|------------|------------|------------|-----------|")
all_paths = set(old_blobs.keys()) | set(new_blobs.keys())
for path in sorted(all_paths):
old_blob = old_blobs.get(path, {})
new_blob = new_blobs.get(path, {})
old_version = old_blob.get('version', 'N/A')
new_version = new_blob.get('version', 'N/A')
old_sha = old_blob.get('sha256', 'N/A')[:16] + '...' if old_blob.get('sha256') else 'N/A'
new_sha = new_blob.get('sha256', 'N/A')[:16] + '...' if new_blob.get('sha256') else 'N/A'
old_commit = extract_commit_from_url(old_blob.get('url', ''))
new_commit = extract_commit_from_url(new_blob.get('url', ''))
diff_link = generate_diff_link(old_blob.get('url', ''), new_blob.get('url', ''))
# Extract variant name from path
variant = path.split('/')[-2] if '/' in path else path
table_rows.append(f"| {variant} | {old_version} | {new_version} | {old_sha} | {new_sha} | {old_commit} | {new_commit} | {diff_link} |")
# Check if there are any actual changes
has_changes = False
for path in sorted(all_paths):
old_blob = old_blobs.get(path, {})
new_blob = new_blobs.get(path, {})
if (old_blob.get('version') != new_blob.get('version') or
old_blob.get('sha256') != new_blob.get('sha256') or
old_blob.get('url') != new_blob.get('url')):
has_changes = True
break
# Output the table
diff_content = []
if has_changes:
diff_content.append("## Firmware Blob Changes")
diff_content.append("")
diff_content.extend(table_rows)
else:
diff_content.append("## No Changes Detected")
diff_content.append("")
diff_content.append("All firmware blobs remain unchanged in this PR.")
diff_content.append("")
diff_content.append("### Current Firmware Blob Summary:")
diff_content.extend(table_rows[2:]) # Skip header rows
# Write to file for GitHub Actions output
with open('diff_output.txt', 'w') as f:
f.write('\n'.join(diff_content))
print("diff_output<<EOF", file=sys.stdout)
print('\n'.join(diff_content), file=sys.stdout)
print("EOF", file=sys.stdout)
# Also output current blob summary
blob_info = []
for blob in new_data.get('blobs', []):
info = f"- **{blob.get('path', 'Unknown')}**\n"
info += f" - Version: {blob.get('version', 'Unknown')}\n"
info += f" - SHA256: {blob.get('sha256', 'Unknown')[:16]}...\n"
info += f" - Type: {blob.get('type', 'Unknown')}\n"
info += f" - Description: {blob.get('description', 'No description')}\n"
blob_info.append(info)
blob_content = ["## Current Firmware Blobs:"] + blob_info
# Write to file for GitHub Actions output
with open('blob_summary.txt', 'w') as f:
f.write('\n'.join(blob_content))
print("blob_summary<<EOF", file=sys.stdout)
print('\n'.join(blob_content), file=sys.stdout)
print("EOF", file=sys.stdout)
except Exception as e:
print("diff_output<<EOF", file=sys.stdout)
print(f"Error generating comparison: {e}", file=sys.stdout)
print("EOF", file=sys.stdout)
print("blob_summary<<EOF", file=sys.stdout)
print(f"Error parsing module.yml: {e}", file=sys.stdout)
print("EOF", file=sys.stdout)
EOF
- name: Set output variables
run: |
echo "diff_output<<EOF" >> $GITHUB_OUTPUT
cat diff_output.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
echo "blob_summary<<EOF" >> $GITHUB_OUTPUT
cat blob_summary.txt >> $GITHUB_OUTPUT
echo "EOF" >> $GITHUB_OUTPUT
- name: Create or update comment
uses: actions/github-script@v7
with:
script: |
const { data: comments } = await github.rest.issues.listComments({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number
});
const existingComment = comments.find(comment =>
comment.body.includes('Module Monitor')
);
console.log('DEBUG: diff_output length:', process.env.diff_output ? process.env.diff_output.length : 0);
console.log('DEBUG: blob_summary length:', process.env.blob_summary ? process.env.blob_summary.length : 0);
const commentBody = 'Module Monitor\n\nChanges detected in module.yml\n\n' +
(process.env.diff_output || 'No changes detected') + '\n\n' +
(process.env.blob_summary || '') + '\n\n' +
'This comment was automatically generated.';
if (existingComment) {
await github.rest.issues.updateComment({
owner: context.repo.owner,
repo: context.repo.repo,
comment_id: existingComment.id,
body: commentBody
});
} else {
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
body: commentBody
});
}
env:
diff_output: ${{ steps.changes.outputs.diff_output }}
blob_summary: ${{ steps.changes.outputs.blob_summary }}
- name: Output summary
run: |
echo "## Module Monitor Summary" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "### Changes in zephyr/module.yml:" >> $GITHUB_STEP_SUMMARY
echo '```diff' >> $GITHUB_STEP_SUMMARY
echo "${{ steps.changes.outputs.diff_output }}" >> $GITHUB_STEP_SUMMARY
echo '```' >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "${{ steps.changes.outputs.blob_summary }}" >> $GITHUB_STEP_SUMMARY