@@ -135,25 +135,26 @@ 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
142142 command : |
143- # Create metrics directory for this build
144- mkdir -p /tmp/metrics
145- # Copy all metrics.json files, rename to include family info
143+ # Create unique directory per toolchain to avoid workspace conflicts
144+ METRICS_DIR="/tmp/metrics/<< parameters.toolchain >>"
145+ mkdir -p "${METRICS_DIR}"
146+ # Copy all metrics.json files
146147 for f in cmake-build/cmake-build-*/metrics.json; do
147148 if [ -f "$f" ]; then
148149 BOARD_DIR=$(dirname "$f" | xargs basename)
149- cp "$f" "/tmp/metrics /${BOARD_DIR}.json"
150+ cp "$f" "${METRICS_DIR} /${BOARD_DIR}.json"
150151 fi
151152 done
152153
153154 - persist_to_workspace :
154155 root : /tmp
155156 paths :
156- - metrics
157+ - metrics/<< parameters.toolchain >>
157158
158159jobs :
159160 # Build using docker
@@ -227,16 +228,10 @@ jobs:
227228 command : |
228229 python tools/get_deps.py
229230 pip install tools/linkermap/
230- # Combine all metrics files
231- tree /tmp/metrics
232- if ls /tmp/metrics/*.json 1> /dev/null 2>&1; then
233- mkdir -p cmake-build
234- for f in /tmp/metrics/*.json; do
235- BOARD_NAME=$(basename "$f" .json)
236- mkdir -p "cmake-build/${BOARD_NAME}"
237- cp "$f" "cmake-build/${BOARD_NAME}/metrics.json"
238- done
239- python tools/metrics.py combine -j -m -f tinyusb/src cmake-build/*/metrics.json
231+ # Combine all metrics files from all toolchain subdirectories
232+ ls -R /tmp/metrics
233+ if ls /tmp/metrics/*/*.json 1> /dev/null 2>&1; then
234+ python tools/metrics.py combine -j -m -f tinyusb/src /tmp/metrics/*/*.json
240235 else
241236 echo "No metrics files found"
242237 exit 1
@@ -246,9 +241,37 @@ jobs:
246241 path : metrics.json
247242 destination : metrics.json
248243
249- - store_artifacts :
250- path : metrics.md
251- destination : metrics.md
244+ # Compare with base master metrics on PR branches
245+ - when :
246+ condition :
247+ not :
248+ equal : [ master, << pipeline.git.branch >> ]
249+ steps :
250+ - run :
251+ name : Download Base Branch Metrics
252+ command : |
253+ # Download metrics.json artifact from the latest successful build on master branch
254+ mkdir -p base-metrics
255+ # Use CircleCI API to get the latest artifact
256+ curl -s -L "https://dl.circleci.com/api/v2/project/gh/${CIRCLE_PROJECT_USERNAME}/${CIRCLE_PROJECT_REPONAME}/latest/artifacts?branch=master&filter=successful" \
257+ -H "Circle-Token: ${CIRCLE_TOKEN:-}" | \
258+ jq -r '.items[] | select(.path == "metrics.json") | .url' | \
259+ head -1 | xargs -I {} curl -s -L -o base-metrics/metrics.json {} || true
260+
261+ - run :
262+ name : Compare with Base Branch
263+ command : |
264+ if [ -f base-metrics/metrics.json ]; then
265+ python tools/metrics.py compare -f tinyusb/src base-metrics/metrics.json metrics.json
266+ cat metrics_compare.md
267+ else
268+ echo "No base metrics found, skipping comparison"
269+ cp metrics.md metrics_compare.md
270+ fi
271+
272+ - store_artifacts :
273+ path : metrics_compare.md
274+ destination : metrics_compare.md
252275
253276workflows :
254277 build :
0 commit comments