nrf_wifi : Update Wi-Fi FW blobs and shared header file #15
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Module Monitor | |
| on: | |
| push: | |
| paths: | |
| - 'zephyr/module.yml' | |
| 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 | |
| - name: Fetch PR head | |
| if: github.event_name == 'pull_request_target' | |
| 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: | | |
| # For pull requests, compare with base branch | |
| if [ "$GITHUB_EVENT_NAME" = "pull_request" ]; then | |
| 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 | |
| DIFF_OUTPUT=$(git diff $BASE_REF $HEAD_REF -- zephyr/module.yml || echo "No changes found") | |
| echo "DEBUG: Diff result: $DIFF_OUTPUT" >&2 | |
| else | |
| # For push events, get the previous commit that modified module.yml | |
| PREV_COMMIT=$(git log --oneline --follow -- zephyr/module.yml | head -2 | tail -1 | cut -d' ' -f1) | |
| if [ -n "$PREV_COMMIT" ]; then | |
| DIFF_OUTPUT=$(git diff $PREV_COMMIT HEAD -- zephyr/module.yml || echo "No changes found") | |
| else | |
| DIFF_OUTPUT="No previous commit found for module.yml" | |
| fi | |
| fi | |
| echo "diff_output<<EOF" >> $GITHUB_OUTPUT | |
| echo "$DIFF_OUTPUT" >> $GITHUB_OUTPUT | |
| echo "EOF" >> $GITHUB_OUTPUT | |
| # Parse YAML and extract blob information | |
| python3 << 'EOF' | |
| import yaml | |
| import sys | |
| import os | |
| try: | |
| with open('zephyr/module.yml', 'r') as f: | |
| data = yaml.safe_load(f) | |
| if 'blobs' in data: | |
| blob_info = [] | |
| for blob in data['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) | |
| print("blob_summary<<EOF", file=sys.stdout) | |
| print("## Current Firmware Blobs:", file=sys.stdout) | |
| for info in blob_info: | |
| print(info, file=sys.stdout) | |
| print("EOF", file=sys.stdout) | |
| else: | |
| print("blob_summary<<EOF", file=sys.stdout) | |
| print("No blobs found in module.yml", file=sys.stdout) | |
| print("EOF", file=sys.stdout) | |
| except Exception as e: | |
| print("blob_summary<<EOF", file=sys.stdout) | |
| print(f"Error parsing module.yml: {e}", file=sys.stdout) | |
| print("EOF", file=sys.stdout) | |
| EOF | |
| - name: Create or update comment (Pull Request) | |
| if: github.event_name == 'pull_request' | |
| 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') | |
| ); | |
| 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.'; | |
| try { | |
| 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 | |
| }); | |
| } | |
| } catch (error) { | |
| console.log('Could not create/update comment due to permissions. This is normal for forks.'); | |
| console.log('Error:', error.message); | |
| } | |
| env: | |
| diff_output: ${{ steps.changes.outputs.diff_output }} | |
| blob_summary: ${{ steps.changes.outputs.blob_summary }} | |
| - name: Create commit comment (Push) | |
| if: github.event_name == 'push' | |
| uses: actions/github-script@v7 | |
| with: | |
| script: | | |
| 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.'; | |
| try { | |
| await github.rest.repos.createCommitComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| commit_sha: context.sha, | |
| body: commentBody | |
| }); | |
| } catch (error) { | |
| console.log('Could not create commit comment due to permissions. This is normal for forks.'); | |
| console.log('Error:', error.message); | |
| } | |
| 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 |