Skip to content

Commit f7a7eb2

Browse files
committed
run metrics with circleci
1 parent be377dc commit f7a7eb2

File tree

2 files changed

+48
-14
lines changed

2 files changed

+48
-14
lines changed

.circleci/config.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,11 +25,11 @@ jobs:
2525
2626
TOOLCHAIN_LIST=(
2727
"aarch64-gcc"
28-
"arm-clang"
29-
"arm-gcc"
30-
"esp-idf"
31-
"msp430-gcc"
32-
"riscv-gcc"
28+
# "arm-clang"
29+
# "arm-gcc"
30+
# "esp-idf"
31+
# "msp430-gcc"
32+
# "riscv-gcc"
3333
)
3434
3535
# only build IAR if not forked PR, since IAR token is not shared
@@ -77,7 +77,7 @@ jobs:
7777
gen_build_entry "$build_system" "$toolchain" "$FAMILY"
7878
7979
# Only add cmake builds: excluding esp-idf or build_args="--one-random" to metrics requirements
80-
if [ "$build_system" == "cmake" ] && [ "$toolchain" != "esp-idf" ] && [ "build_args" != "--one-random" ]; then
80+
if [ "$build_system" == "cmake" ] && [ "$toolchain" != "esp-idf" ] && [ "$toolchain" != "arm-iar" ]; then
8181
BUILD_ALIASES+=("build-${build_system}-${toolchain}")
8282
fi
8383
done

.circleci/config2.yml

Lines changed: 42 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -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

253287
workflows:
254288
build:

0 commit comments

Comments
 (0)