Skip to content

Commit cb19d62

Browse files
committed
Merge branch 'refs/heads/master' into musb_fix
2 parents 8ef8ee1 + be5e234 commit cb19d62

File tree

17 files changed

+833
-38
lines changed

17 files changed

+833
-38
lines changed

.github/membrowse-targets.json

Lines changed: 494 additions & 0 deletions
Large diffs are not rendered by default.

.github/pull_request_template.md

Lines changed: 0 additions & 5 deletions
This file was deleted.

.github/workflows/build.yml

Lines changed: 50 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ name: Build
33
on:
44
workflow_dispatch:
55
push:
6+
branches: [master]
67
paths:
78
- 'src/**'
89
- 'examples/**'
@@ -29,6 +30,7 @@ on:
2930
- '.github/workflows/ci_set_matrix.py'
3031
release:
3132
types: [ published ]
33+
3234
concurrency:
3335
group: ${{ github.workflow }}-${{ github.ref }}
3436
cancel-in-progress: true
@@ -82,6 +84,7 @@ jobs:
8284
build-args: ${{ toJSON(fromJSON(needs.set-matrix.outputs.json)[matrix.toolchain]) }}
8385
build-options: '--one-first'
8486
upload-metrics: true
87+
upload-artifacts: true
8588

8689
code-metrics:
8790
needs: cmake
@@ -181,7 +184,6 @@ jobs:
181184
# Build Make/CMake on Windows/MacOS
182185
# ---------------------------------------
183186
build-os:
184-
if: github.event_name == 'pull_request'
185187
uses: ./.github/workflows/build_util.yml
186188
strategy:
187189
fail-fast: false
@@ -198,7 +200,8 @@ jobs:
198200
# Zephyr
199201
# ---------------------------------------
200202
zephyr:
201-
if: github.event_name == 'push'
203+
# skip zephyr build due to failed build, fix later
204+
if: false
202205
runs-on: ubuntu-latest
203206
steps:
204207
- name: Checkout TinyUSB
@@ -220,10 +223,8 @@ jobs:
220223
# Run on PR only (hil-tinyusb), hil-hfp only run on non-forked PR
221224
# ---------------------------------------
222225
hil-build:
223-
if: |
224-
github.repository_owner == 'hathach' &&
225-
(github.event_name == 'pull_request' || github.event_name == 'workflow_dispatch')
226226
needs: set-matrix
227+
if: github.repository_owner == 'hathach'
227228
uses: ./.github/workflows/build_util.yml
228229
strategy:
229230
fail-fast: false
@@ -242,7 +243,6 @@ jobs:
242243
# self-hosted on local VM, for attached hardware checkout HIL_JSON
243244
# ---------------------------------------
244245
hil-tinyusb:
245-
if: github.repository_owner == 'hathach' && github.event_name != 'push'
246246
needs: hil-build
247247
runs-on: [ self-hosted, X64, hathach, hardware-in-the-loop ]
248248
steps:
@@ -285,8 +285,7 @@ jobs:
285285
hil-hfp:
286286
if: |
287287
github.repository_owner == 'hathach' &&
288-
github.event.pull_request.head.repo.fork == false &&
289-
github.event_name != 'push'
288+
!(github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true)
290289
runs-on: [ self-hosted, Linux, X64, hifiphile ]
291290
env:
292291
IAR_LMS_BEARER_TOKEN: ${{ secrets.IAR_LMS_BEARER_TOKEN }}
@@ -319,3 +318,46 @@ jobs:
319318

320319
- name: Test on actual hardware (hardware in the loop)
321320
run: python3 test/hil/hil_test.py hfp.json
321+
322+
# ---------------------------------------
323+
# Membrowse Memory Analysis
324+
# Push: always runs (uses identical for doc-only to maintain commit chain)
325+
# PR: only runs if code changed (doc-only PRs skip entirely)
326+
# ---------------------------------------
327+
membrowse:
328+
needs: cmake
329+
permissions:
330+
contents: read
331+
actions: read
332+
uses: ./.github/workflows/membrowse-report.yml
333+
with:
334+
code_changed: true
335+
secrets: inherit
336+
337+
membrowse-comment:
338+
needs: membrowse
339+
# skip membrowse comment since it is too verbal
340+
if: false && github.event_name == 'pull_request'
341+
runs-on: ubuntu-latest
342+
permissions:
343+
contents: read
344+
actions: read
345+
steps:
346+
- name: Checkout repository
347+
uses: actions/checkout@v6
348+
349+
- name: Download report artifacts
350+
id: download
351+
uses: actions/download-artifact@v5
352+
with:
353+
pattern: membrowse-report-*
354+
path: reports
355+
merge-multiple: true
356+
continue-on-error: true
357+
358+
- name: Upload Membrowse Comment Artifact
359+
if: steps.download.outcome == 'success'
360+
uses: actions/upload-artifact@v5
361+
with:
362+
name: membrowse-comment
363+
path: reports/

.github/workflows/build_util.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,19 @@ jobs:
7373
name: metrics-${{ matrix.arg }}
7474
path: cmake-build/cmake-build-*/metrics.json
7575

76+
- name: Copy linker scripts for artifacts
77+
if: ${{ inputs.upload-artifacts }}
78+
run: |
79+
for dir in cmake-build/cmake-build-*; do
80+
board=$(basename "$dir" | sed 's/cmake-build-//')
81+
ld_path=$(jq -r --arg b "$board" '.targets[] | select(.board == $b) | .ld // empty' .github/membrowse-targets.json)
82+
if [ -n "$ld_path" ] && [ -f "$ld_path" ]; then
83+
mkdir -p "cmake-build/$(dirname "$ld_path")"
84+
cp "$ld_path" "cmake-build/$ld_path"
85+
fi
86+
done
87+
shell: bash
88+
7689
- name: Upload Artifacts for Hardware Testing
7790
if: ${{ inputs.upload-artifacts }}
7891
uses: actions/upload-artifact@v5
@@ -86,3 +99,4 @@ jobs:
8699
cmake-build/cmake-build-*/*/*/partition_table/partition-table.bin
87100
cmake-build/cmake-build-*/*/*/config.env
88101
cmake-build/cmake-build-*/*/*/flash_args
102+
cmake-build/hw/mcu/**/*.ld
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
name: Membrowse Comment
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Build"]
6+
types:
7+
- completed
8+
9+
jobs:
10+
post-comment:
11+
runs-on: ubuntu-latest
12+
if: >
13+
github.event.workflow_run.event == 'pull_request' &&
14+
github.event.workflow_run.conclusion != 'cancelled'
15+
permissions:
16+
actions: read
17+
pull-requests: write
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v6
21+
22+
- name: Download Artifacts
23+
id: download
24+
uses: actions/download-artifact@v5
25+
with:
26+
run-id: ${{ github.event.workflow_run.id }}
27+
github-token: ${{ secrets.GITHUB_TOKEN }}
28+
name: membrowse-comment
29+
path: reports
30+
continue-on-error: true
31+
32+
- name: Post Membrowse PR comment
33+
if: steps.download.outcome == 'success'
34+
uses: membrowse/membrowse-action/comment-action@v1
35+
with:
36+
json_files: 'reports/*.json'
37+
env:
38+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
name: Onboard to Membrowse
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
num_commits:
7+
description: 'Number of commits to process'
8+
required: true
9+
default: '10'
10+
type: string
11+
12+
jobs:
13+
load-targets:
14+
runs-on: ubuntu-22.04
15+
outputs:
16+
targets: ${{ steps.load.outputs.targets }}
17+
toolchains: ${{ steps.load.outputs.toolchains }}
18+
steps:
19+
- name: Checkout repository
20+
uses: actions/checkout@v5
21+
22+
- name: Load target matrix
23+
id: load
24+
run: |
25+
echo "targets=$(jq -c '.targets' .github/membrowse-targets.json)" >> $GITHUB_OUTPUT
26+
echo "toolchains=$(jq -c '.toolchains' .github/membrowse-targets.json)" >> $GITHUB_OUTPUT
27+
28+
onboard:
29+
needs: load-targets
30+
runs-on: ubuntu-22.04
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include: ${{ fromJson(needs.load-targets.outputs.targets) }}
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v5
39+
with:
40+
fetch-depth: 0
41+
submodules: recursive
42+
43+
- name: Install packages
44+
run: |
45+
${{ fromJson(needs.load-targets.outputs.toolchains)[matrix.toolchain].setup_cmd }} && python3 tools/get_deps.py ${{ matrix.get_deps || matrix.port }}
46+
47+
- name: Setup ccache
48+
uses: hendrikmuhs/ccache-action@v1.2
49+
with:
50+
key: ${{ matrix.port }}-${{ matrix.board }}
51+
52+
- name: Run Membrowse Onboard Action
53+
uses: membrowse/membrowse-action/onboard-action@v1
54+
with:
55+
target_name: ${{ matrix.port }}-${{ matrix.board }}-${{ matrix.example }}
56+
num_commits: ${{ github.event.inputs.num_commits }}
57+
build_script: python3 tools/build.py -s cmake -b ${{ matrix.board }}
58+
elf: cmake-build/cmake-build-${{ matrix.board }}/device/${{ matrix.example }}/${{ matrix.example }}.elf
59+
ld: ${{ matrix.ld }}
60+
linker_vars: ${{ matrix.linker_vars || '' }}
61+
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
62+
api_url: ${{ vars.MEMBROWSE_API_URL }}
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
name: Membrowse Memory Report
2+
3+
on:
4+
workflow_call:
5+
inputs:
6+
code_changed:
7+
description: 'Whether code paths changed (true) or doc-only (false)'
8+
type: boolean
9+
required: true
10+
11+
permissions:
12+
contents: read
13+
actions: read
14+
15+
jobs:
16+
load-targets:
17+
runs-on: ubuntu-latest
18+
outputs:
19+
targets: ${{ steps.load.outputs.targets }}
20+
steps:
21+
- name: Checkout repository
22+
uses: actions/checkout@v6
23+
24+
- name: Load target matrix
25+
id: load
26+
run: echo "targets=$(jq -c '.targets' .github/membrowse-targets.json)" >> $GITHUB_OUTPUT
27+
28+
analyze:
29+
needs: [load-targets]
30+
runs-on: ubuntu-latest
31+
strategy:
32+
fail-fast: false
33+
matrix:
34+
include: ${{ fromJson(needs.load-targets.outputs.targets) }}
35+
36+
steps:
37+
- name: Checkout repository
38+
uses: actions/checkout@v6
39+
with:
40+
fetch-depth: 0
41+
submodules: recursive
42+
43+
# Download artifacts when code changed (build artifacts available)
44+
- name: Download build artifacts
45+
if: inputs.code_changed
46+
id: download
47+
uses: actions/download-artifact@v5
48+
with:
49+
pattern: binaries-*
50+
path: cmake-build
51+
merge-multiple: true
52+
continue-on-error: true
53+
54+
- name: Restore linker scripts
55+
if: inputs.code_changed
56+
run: cp -r cmake-build/hw . 2>/dev/null || true
57+
58+
- name: Check if ELF exists
59+
id: check-elf
60+
run: |
61+
if [ -f "cmake-build/cmake-build-${{ matrix.board }}/device/${{ matrix.example }}/${{ matrix.example }}.elf" ]; then
62+
echo "exists=true" >> $GITHUB_OUTPUT
63+
else
64+
echo "exists=false" >> $GITHUB_OUTPUT
65+
fi
66+
67+
# Run with actual ELF analysis when build artifacts available
68+
- name: Run Membrowse Analysis
69+
if: steps.check-elf.outputs.exists == 'true'
70+
id: membrowse
71+
continue-on-error: true
72+
uses: membrowse/membrowse-action@v1
73+
with:
74+
target_name: ${{ matrix.port }}-${{ matrix.board }}-${{ matrix.example }}
75+
elf: cmake-build/cmake-build-${{ matrix.board }}/device/${{ matrix.example }}/${{ matrix.example }}.elf
76+
ld: ${{ matrix.ld }}
77+
linker_vars: ${{ matrix.linker_vars || '' }}
78+
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
79+
api_url: ${{ vars.MEMBROWSE_API_URL }}
80+
verbose: INFO
81+
82+
# Run with identical=true when no ELF (doc-only push)
83+
# Preserves the chain of commits in membrowse tracking
84+
- name: Run Membrowse Identical Report
85+
if: steps.check-elf.outputs.exists == 'false'
86+
id: membrowse-identical
87+
continue-on-error: true
88+
uses: membrowse/membrowse-action@v1
89+
with:
90+
target_name: ${{ matrix.port }}-${{ matrix.board }}-${{ matrix.example }}
91+
identical: true
92+
api_key: ${{ secrets.MEMBROWSE_API_KEY }}
93+
api_url: ${{ vars.MEMBROWSE_API_URL }}
94+
verbose: INFO
95+
96+
- name: Upload report artifact
97+
if: steps.membrowse.outcome == 'success' || steps.membrowse-identical.outcome == 'success'
98+
uses: actions/upload-artifact@v5
99+
with:
100+
name: membrowse-report-${{ matrix.port }}-${{ matrix.board }}-${{ matrix.example }}
101+
path: ${{ steps.membrowse.outputs.report_path || steps.membrowse-identical.outputs.report_path }}

.idea/cmake.xml

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.rst

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
TinyUSB
22
=======
33

4-
|Build Status| |CircleCI Status| |Documentation Status| |Static Analysis| |Fuzzing Status| |License|
4+
|Build Status| |CircleCI Status| |Documentation Status| |Static Analysis| |Fuzzing Status| |Membrowse| |License|
55

66
Sponsors
77
--------
@@ -293,6 +293,8 @@ The following tools are provided freely to support the development of the TinyUS
293293
:target: https://github.com/hathach/tinyusb/actions/workflows/static_analysis.yml
294294
.. |Fuzzing Status| image:: https://oss-fuzz-build-logs.storage.googleapis.com/badges/tinyusb.svg
295295
:target: https://oss-fuzz-build-logs.storage.googleapis.com/index.html#tinyusb
296+
.. |Membrowse| image:: https://membrowse.com/badge.svg
297+
:target: https://membrowse.com/public/hathach/tinyusb
296298
.. |License| image:: https://img.shields.io/badge/license-MIT-brightgreen.svg
297299
:target: https://opensource.org/licenses/MIT
298300

0 commit comments

Comments
 (0)