@@ -135,7 +135,7 @@ commands:
135135 - not :
136136 equal : [ esp-idf, << parameters.toolchain >> ]
137137 - not :
138- equal : [ --one-random , << parameters.build-args >> ]
138+ equal : [ arm-iar , << parameters.toolchain >> ]
139139 steps :
140140 - run :
141141 name : Collect Metrics
@@ -147,6 +147,7 @@ commands:
147147 if [ -f "$f" ]; then
148148 BOARD_DIR=$(dirname "$f" | xargs basename)
149149 cp "$f" "/tmp/metrics/${BOARD_DIR}.json"
150+ cat /tmp/metrics/${BOARD_DIR}.json
150151 fi
151152 done
152153
@@ -228,7 +229,7 @@ jobs:
228229 python tools/get_deps.py
229230 pip install tools/linkermap/
230231 # Combine all metrics files
231- tree /tmp/metrics
232+ ls /tmp/metrics
232233 if ls /tmp/metrics/*.json 1> /dev/null 2>&1; then
233234 mkdir -p cmake-build
234235 for f in /tmp/metrics/*.json; do
@@ -242,13 +243,46 @@ jobs:
242243 exit 1
243244 fi
244245
245- - store_artifacts :
246- path : metrics.json
247- destination : metrics.json
246+ # Store metrics.json artifact on master branch
247+ - when :
248+ condition :
249+ equal : [ master, << pipeline.git.branch >> ]
250+ steps :
251+ - store_artifacts :
252+ path : metrics.json
253+ destination : metrics.json
254+
255+ # Compare with base master metrics on PR branches
256+ - when :
257+ condition :
258+ not :
259+ equal : [ master, << pipeline.git.branch >> ]
260+ steps :
261+ - run :
262+ name : Download Base Branch Metrics
263+ command : |
264+ # Download metrics.json artifact from the latest successful build on master branch
265+ mkdir -p base-metrics
266+ # Use CircleCI API to get the latest artifact
267+ curl -s -L "https://dl.circleci.com/api/v2/project/gh/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/latest/artifacts?branch=master&filter=successful" \
268+ -H "Circle-Token: ${CIRCLE_TOKEN:-}" | \
269+ jq -r '.items[] | select(.path == "metrics.json") | .url' | \
270+ head -1 | xargs -I {} curl -s -L -o base-metrics/metrics.json {} || true
271+
272+ - run :
273+ name : Compare with Base Branch
274+ command : |
275+ if [ -f base-metrics/metrics.json ]; then
276+ python tools/metrics.py compare -f tinyusb/src base-metrics/metrics.json metrics.json
277+ cat metrics_compare.md
278+ else
279+ echo "No base metrics found, skipping comparison"
280+ cp metrics.md metrics_compare.md
281+ fi
248282
249- - store_artifacts :
250- path : metrics .md
251- destination : metrics .md
283+ - store_artifacts :
284+ path : metrics_compare .md
285+ destination : metrics_compare .md
252286
253287workflows :
254288 build :
0 commit comments