nrf_wifi : Update Wi-Fi FW blobs and shared header file #9
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: | |
| paths: | |
| - 'zephyr/module.yml' | |
| permissions: | |
| contents: read | |
| pull-requests: 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: 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" | |
| DIFF_OUTPUT=$(git diff $BASE_REF $HEAD_REF -- zephyr/module.yml || echo "No changes found") | |
| 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.'; | |
| 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: 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.'; | |
| await github.rest.repos.createCommitComment({ | |
| owner: context.repo.owner, | |
| repo: context.repo.repo, | |
| commit_sha: context.sha, | |
| 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 |