|
| 1 | +name: Membrowse Zephyr Report |
| 2 | + |
| 3 | +# Triggered after the heavy Zephyr 4.x test workflow completes. Pulls the |
| 4 | +# pre-built zephyr.elf, zephyr.map and linker.cmd artifacts staged by |
| 5 | +# zephyr-test.sh and feeds them to the Membrowse memory-tracking service. |
| 6 | +# This avoids duplicating the (slow) Zephyr build inside the Membrowse |
| 7 | +# matrix. |
| 8 | + |
| 9 | +on: |
| 10 | + workflow_run: |
| 11 | + workflows: [Zephyr 4.x tests] |
| 12 | + types: |
| 13 | + - completed |
| 14 | + |
| 15 | +concurrency: |
| 16 | + group: ${{ github.workflow }}-${{ github.event.workflow_run.head_sha }} |
| 17 | + cancel-in-progress: true |
| 18 | + |
| 19 | +jobs: |
| 20 | + analyze: |
| 21 | + runs-on: ubuntu-24.04 |
| 22 | + timeout-minutes: 10 |
| 23 | + # Only run from the wolfssl org to avoid burning forks' CI minutes |
| 24 | + # and reporting fork builds to the membrowse backend. |
| 25 | + if: > |
| 26 | + github.event.workflow_run.conclusion == 'success' && |
| 27 | + github.repository_owner == 'wolfssl' |
| 28 | + permissions: |
| 29 | + contents: read |
| 30 | + actions: read |
| 31 | + strategy: |
| 32 | + fail-fast: false |
| 33 | + matrix: |
| 34 | + include: |
| 35 | + - target_name: zephyr-native_sim |
| 36 | + artifact: membrowse-zephyr-native_sim |
| 37 | + - target_name: zephyr-frdm_rw612 |
| 38 | + artifact: membrowse-zephyr-frdm_rw612 |
| 39 | + steps: |
| 40 | + # Check out the commit the Zephyr workflow actually built so Membrowse |
| 41 | + # attributes the report to the right commit. Only the last 2 commits |
| 42 | + # are needed (current + parent) to resolve the base for comparison. |
| 43 | + - name: Checkout repository |
| 44 | + uses: actions/checkout@v5 |
| 45 | + with: |
| 46 | + ref: ${{ github.event.workflow_run.head_sha }} |
| 47 | + fetch-depth: 2 |
| 48 | + |
| 49 | + - name: Download Zephyr build artifact |
| 50 | + id: download |
| 51 | + uses: actions/download-artifact@v4 |
| 52 | + with: |
| 53 | + name: ${{ matrix.artifact }} |
| 54 | + path: zephyr-artifacts/${{ matrix.target_name }} |
| 55 | + run-id: ${{ github.event.workflow_run.id }} |
| 56 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 57 | + continue-on-error: true |
| 58 | + |
| 59 | + - name: Verify artifact present |
| 60 | + id: verify |
| 61 | + run: | |
| 62 | + ELF="zephyr-artifacts/${{ matrix.target_name }}/zephyr.elf" |
| 63 | + LD="zephyr-artifacts/${{ matrix.target_name }}/linker.cmd" |
| 64 | + MAP="zephyr-artifacts/${{ matrix.target_name }}/zephyr.map" |
| 65 | + if [[ -f "$ELF" && -f "$LD" ]]; then |
| 66 | + echo "have_artifacts=true" >> "$GITHUB_OUTPUT" |
| 67 | + else |
| 68 | + echo "have_artifacts=false" >> "$GITHUB_OUTPUT" |
| 69 | + echo "::warning::Membrowse artifact for ${{ matrix.target_name }} not found; the matching cell of zephyr-4.x.yml may have been skipped or excluded." |
| 70 | + fi |
| 71 | + # The map file is optional; it enables library/object attribution. |
| 72 | + if [[ -f "$MAP" ]]; then |
| 73 | + echo "map_file=$MAP" >> "$GITHUB_OUTPUT" |
| 74 | + else |
| 75 | + echo "map_file=" >> "$GITHUB_OUTPUT" |
| 76 | + fi |
| 77 | +
|
| 78 | + - name: Run Membrowse PR Action |
| 79 | + if: steps.verify.outputs.have_artifacts == 'true' |
| 80 | + uses: membrowse/membrowse-action@v1 |
| 81 | + with: |
| 82 | + target_name: ${{ matrix.target_name }} |
| 83 | + elf: zephyr-artifacts/${{ matrix.target_name }}/zephyr.elf |
| 84 | + ld: zephyr-artifacts/${{ matrix.target_name }}/linker.cmd |
| 85 | + map_file: ${{ steps.verify.outputs.map_file }} |
| 86 | + linker_vars: "" |
| 87 | + api_key: ${{ secrets.MEMBROWSE_API_KEY }} |
| 88 | + api_url: ${{ vars.MEMBROWSE_API_URL }} |
| 89 | + verbose: INFO |
| 90 | + |
| 91 | + # Refresh the consolidated Membrowse PR comment after the Zephyr targets |
| 92 | + # have been submitted, mirroring membrowse-comment.yml. |
| 93 | + post-comment: |
| 94 | + needs: analyze |
| 95 | + runs-on: ubuntu-24.04 |
| 96 | + timeout-minutes: 10 |
| 97 | + if: > |
| 98 | + github.event.workflow_run.event == 'pull_request' && |
| 99 | + github.repository_owner == 'wolfssl' |
| 100 | + permissions: |
| 101 | + contents: read |
| 102 | + pull-requests: write |
| 103 | + steps: |
| 104 | + - name: Checkout repository |
| 105 | + uses: actions/checkout@v5 |
| 106 | + |
| 107 | + - name: Post Membrowse PR comment |
| 108 | + if: ${{ env.MEMBROWSE_API_KEY != '' }} |
| 109 | + uses: membrowse/membrowse-action/comment-action@v1 |
| 110 | + with: |
| 111 | + api_key: ${{ secrets.MEMBROWSE_API_KEY }} |
| 112 | + commit: ${{ github.event.workflow_run.head_sha }} |
| 113 | + env: |
| 114 | + MEMBROWSE_API_KEY: ${{ secrets.MEMBROWSE_API_KEY }} |
| 115 | + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
0 commit comments